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 frslvr, 04-11-2024, 07:26 AM
    9 responses
    123 views
    1 like
    Last Post caryc123  
    Started by rocketman7, Today, 09:41 AM
    4 responses
    15 views
    0 likes
    Last Post rocketman7  
    Started by selu72, Today, 02:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by WHICKED, Today, 02:02 PM
    2 responses
    16 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Working...
    X