Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Referencing it's own Indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Referencing it's own Indicator

    the line in red is in question
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Variables[/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] BoolSeries kees_short_bar_indication;[/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] exposedVariable;[/SIZE][/FONT]
     
     
    [SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT]
    [/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]kees_short_bar_indication = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] BoolSeries([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Add([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Plot([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Pen(Color.LightPink, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]), PlotStyle.Bar, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Kees_Short_Bar"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]));[/SIZE][/FONT]
     
     
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]([/FONT][/SIZE][FONT=Courier New][SIZE=2]Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]< Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=red][B][SIZE=4][FONT=Courier New]&& Bar_Kees().Kees_Short_Bar[[/FONT][FONT=Courier New]1[/FONT][FONT=Courier New]] != [/FONT][FONT=Courier New].5[/FONT][/SIZE][/B][/COLOR]
    [FONT=Courier New][SIZE=2][COLOR=#800080])[/COLOR][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#800080]{[/COLOR][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2]BarColor = Color.LightPink ;[/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2]kees_short_bar_indication.Set([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Kees_Short_Bar.Set([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080].5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2]{ [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]kees_short_bar_indication.Set([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Kees_Short_Bar.Set([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
     
    [SIZE=2][FONT=Courier New][FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Properties[/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][Browsable([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
    [SIZE=2][FONT=Courier New][XmlIgnore()][/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DataSeries Kees_Short_Bar[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Values[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]; }[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
    [SIZE=2][FONT=Courier New][Browsable([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
    [SIZE=2][FONT=Courier New][XmlIgnore()][/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] BoolSeries Kees_Short_Bar_indication[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] kees_short_bar_indication; }[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
    [SIZE=2][FONT=Courier New][Browsable([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
    [SIZE=2][FONT=Courier New][XmlIgnore()][/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ExposedVariable[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#008000]// We need to call the Update() method to ensure our exposed variable is in up-to-date.[/COLOR][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { Update(); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] exposedVariable; }[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
    [/FONT][/SIZE]
    [/FONT][/SIZE][/COLOR][/SIZE][/FONT][/SIZE][/FONT]
    [/SIZE][/FONT]
    [/SIZE][/FONT][/SIZE][/FONT][/FONT][/SIZE][/SIZE][/FONT]
    Will this code work correctly or creat problems?
    Code:
    [FONT=Courier New][B][SIZE=4][COLOR=#ff0000]&& Bar_Kees().Kees_Short_Bar[[FONT=Courier New]1[/FONT][FONT=Courier New]] != [/FONT][FONT=Courier New].5[/FONT][/COLOR][/SIZE][/B][/FONT]
    My goal is to paint the first bar that meets the above conditions but not any bars (or at least the next bar) after that even when the same conditions are met.

    #2
    duck_CA,

    Unfortunately I have no way to evaluate this for you since we have no idea what Bar_Kees() is or how to use it. Right now what your code is saying is when that particular indicator's value on the previous bar is not equal to 0.5, do something.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Bar Kees

      Hey Josh,
      Bar_Kees() is the name of this indicator. so it's referencing itself.

      which is
      Code:
      ([FONT=Courier New][SIZE=2]Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]< Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]][/SIZE][/FONT]

      Comment


        #4
        Originally posted by duck_CA View Post
        Hey Josh,
        Bar_Kees() is the name of this indicator. so it's referencing itself.

        which is
        Code:
        ([FONT=Courier New][SIZE=2]Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]< Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]][/SIZE][/FONT]
        for referencing the indicator itself you can use c# keyword "this"
        For example
        this.Name will return the name of the indicator.

        Comment


          #5
          this.

          what's the diff between using
          Code:
          && this.Bar_Kees().Kees_Short_Bar[1] != .5
          and
          Code:
          [B][SIZE=4][COLOR=#ff0000]&& Bar_Kees().Kees_Short_Bar[[FONT=Courier New]1[/FONT][FONT=Courier New]] != [/FONT][FONT=Courier New].5[/FONT][/COLOR][/SIZE][/B]
          please keep in mind that i'm trying to reference the very same indicator that is also being built here

          Comment


            #6
            Originally posted by duck_CA View Post
            what's the diff between using
            Code:
            && this.Bar_Kees().Kees_Short_Bar[1] != .5
            and
            Code:
            [B][SIZE=4][COLOR=#ff0000]&& Bar_Kees().Kees_Short_Bar[[FONT=Courier New]1[/FONT][FONT=Courier New]] != [/FONT][FONT=Courier New].5[/FONT][/COLOR][/SIZE][/B]
            please keep in mind that i'm trying to reference the very same indicator that is also being built here
            Why don't you just use Kees_Short_Bar[1] != .5 ?
            or Values[0] [1] != .5 ?
            or Value[1] != .5 ?
            Last edited by roonius; 03-21-2009, 06:48 PM.

            Comment


              #7
              thanks

              trying to learn how all this code stuff works

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ETFVoyageur, Today, 02:10 AM
              0 responses
              7 views
              0 likes
              Last Post ETFVoyageur  
              Started by rayyyu12, Today, 12:47 AM
              0 responses
              7 views
              0 likes
              Last Post rayyyu12  
              Started by ETFVoyageur, 05-07-2024, 07:05 PM
              17 responses
              136 views
              0 likes
              Last Post ETFVoyageur  
              Started by ETFVoyageur, Yesterday, 10:13 PM
              1 response
              10 views
              0 likes
              Last Post ETFVoyageur  
              Started by somethingcomplex, Yesterday, 10:36 PM
              0 responses
              10 views
              0 likes
              Last Post somethingcomplex  
              Working...
              X