Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Loading a day background data series

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

    Loading a day background data series

    I'm trying to write an indicator that gives the point of control on a daily basis and I need to load a daily background data series.

    Code:
     AddDataSeries( BarsPeriodType.Day, 1 );
    The problem is no matter how many days I load on the chart with this indicator I'm trying to write running, the value for CurrentBars[1] is always -1, which means that

    [CODE]
    if (CurrentBars[0] < BarsRequiredToPlot
    || CurrentBars[1] < BarsRequiredToPlot) return;
    [/CODE

    OnBarUpdate gets bounced out of at the beginning.

    Why in the world wouldn't I be able to load a daily background data series?

    #2
    Hello traderpards,

    Your code checks if either CurrentBars[0] is greater than BarsRequiredToPlot OR CurrentBars[1] is greater than BarsRequiredToPlot.

    Since you are using an or '||' either can be true. Both don't have to be true because you are not using an and '&&'.

    If CurrentBars[0] is greater than BarsRequiredToPlot and CurrentBars[0] is -1, the condition is still going to evaluate as true since CurrentBars[0] is greater than BarsRequiredToPlot.


    My guess is that it is loading a 1 day series, but your script is hitting an error before getting to the data of that series.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    55 views
    0 likes
    Last Post CarlTrading  
    Working...
    X