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

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 NRITV, Today, 01:15 PM
    2 responses
    6 views
    0 likes
    Last Post NRITV
    by NRITV
     
    Started by frankthearm, Today, 09:08 AM
    7 responses
    30 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by maybeimnotrader, Yesterday, 05:46 PM
    5 responses
    25 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by quantismo, Yesterday, 05:13 PM
    2 responses
    18 views
    0 likes
    Last Post quantismo  
    Started by adeelshahzad, Today, 03:54 AM
    5 responses
    33 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X