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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    52 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    38 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    99 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    60 views
    0 likes
    Last Post PaulMohn  
    Working...
    X