Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

simple question on Charting, first 20 bars missing?

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

    simple question on Charting, first 20 bars missing?

    Just created a simple indicator to plot the closing price of each bar, on the chart, the plot always starts from the 21st bar, the first 20 bars are not plotted, why is that?

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Plot0.Set(Close[0]);
    }
    Attached Files

    #2
    redartanjin,

    I am happy to assist you.

    This is due to the fact that by default the indicator is waiting for 20 bars before it will allow it to start calculating. This is to prevent accessing elements in a dataseries that do not exist yet, which can cause indicators to throw exceptions and not work at all. You can right click your chart > go to data series > set bars or days to load to a larger number to plot these values.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      can you clarify how those first 20 bars are handled in the application, are they skipped altogether, so the calculation in the script will completely ignore them and start from whatever the 21st bar is?

      is it 20 bars regardless of the bar time? (20 days in daily bars and 20 min in 1-min bars)

      on a multi-time frame chart, for example, a 1-min and 15-min multi-time chart, how is that handled internally?

      Comment


        #4
        redartajnin,

        They are still used in any future calculations that need them but they are skipped to prevent out-of-bounds exceptions in arrays.

        On multi-time frame you need to be careful, as you can have out of bounds exceptions if you do not check for BarsInProgress, which is equal to 0 when OnBarUpdate is called for the primary dataseries, 1 when for the secondary, etc.
        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, Today, 09:28 AM
        0 responses
        6 views
        0 likes
        Last Post Geovanny Suaza  
        Started by mtamaku, 12-30-2024, 08:56 AM
        1 response
        35 views
        0 likes
        Last Post mtamaku
        by mtamaku
         
        Started by Johnny, Today, 08:54 AM
        0 responses
        8 views
        0 likes
        Last Post Johnny
        by Johnny
         
        Started by MattD888, Today, 08:49 AM
        0 responses
        5 views
        0 likes
        Last Post MattD888  
        Started by cutzpr, 02-13-2025, 05:24 PM
        3 responses
        14 views
        0 likes
        Last Post cutzpr
        by cutzpr
         
        Working...
        X