• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsRequiredToPlot

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

    BarsRequiredToPlot

    Hi,

    I had a question regarding BarsRequiredToPlot.

    When I look at the standard SMA indicator (provided by NT8) in the NT editor, it doesn't appears to have a BarsRequiredToPlot defined.

    But when I drop the standard SMA indicator on a chart with a parameter of 10, it appears to skips the first 20 bars.

    I wrote a replica of the standard SMA indicator, with BarsRequiredToPlot equal to the Period and even that indicator skips the first 20 bars (for a SMA parameter of 10).

    Why is this so?

    See attached graph.
    Attached Files

    #2
    Hello uday12,

    Thanks for the note.

    The developers made the default 20 bars if no BarsReqiredToPlot is defined. The MA will always begin plotting at the 20th bar. You can set the BarsReqiredToPlot = 0 if you want to override the property.

    Please let us know if we may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello uday12,

      Thanks for the note.

      The developers made the default 20 bars if no BarsReqiredToPlot is defined. The MA will always begin plotting at the 20th bar. You can set the BarsReqiredToPlot = 0 if you want to override the property.

      Please let us know if we may be of any further assistance.
      Chris,

      I had another question. Suppose I want to set the BarsRequiredToPlot as a function of some parameter Period.

      Suppose I set BarsRequiredToPlot within OnStateChange() such as

      ----

      if (State == State.SetDefaults)
      {
      BarsRequiredToPlot = (int)Math.Sqrt(Period);
      }

      ----

      the code compiles fine.

      But then when I try the indicator on a chart, I get an error in the log "Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.".

      Removing the BarsRequiredToPlot line from the code seems to remover the error during plot the indicator.

      In which State can I assign a value to BarsRequiredToPlot when the value of BarsRequiredToPlot is a function of input parameters?

      Comment


        #4
        Hello uday12,

        Thanks for the reply.

        I was able to do this in State.Configure. You would need to make sure that the Period property is set before you try to use it in a formula.

        Please let us know if we may be of any further assistance.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by supermht, Today, 07:59 PM
        0 responses
        2 views
        0 likes
        Last Post supermht  
        Started by mohdhm, Today, 05:13 PM
        1 response
        12 views
        0 likes
        Last Post nkhoi
        by nkhoi
         
        Started by 3lliot, Today, 05:55 PM
        0 responses
        2 views
        0 likes
        Last Post 3lliot
        by 3lliot
         
        Started by Fargo, Today, 04:57 PM
        0 responses
        11 views
        0 likes
        Last Post Fargo
        by Fargo
         
        Started by Johnny Santiago, Today, 03:57 PM
        0 responses
        10 views
        0 likes
        Last Post Johnny Santiago  
        Working...
        X