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

Trouble initiating my strategy

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

    Trouble initiating my strategy

    I have a second data series 1d added under configure, and daysToLoad = 4, but I'm getting hung at "Bars Count Requirement Not Satasfied, Waiting to load bars...". Any idea what may be the issue?

    Code:
    if (CurrentBar == 0 && CurrentBars[0] == 0)
                {
                    // Initialize series at the first bar
                    haCloseSeries[0]     = Close[0];
                    haOpenSeries[0]     = Open[0];
                    haHighSeries[0]     = High[0];
                    haLowSeries[0]         = Low[0];
                    HAOpen[0]             = Open[0];
                    HAHigh[0]             = High[0];
                    HALow[0]             = Low[0];
                    HAClose[0]             = Close[0];
                    if (showOutput && !backTest)
                    {
                        Print("Strategy initializing..., Bar 0 set.");                
                        Print("Bars loaded for Chart series: " + CurrentBar);
                        Print("Bars loaded for primary series: " + CurrentBars[0]);
                        Print("Bars loaded for secondary series: " + CurrentBars[1]); return;
                    }
                }
                if (Bars.IsFirstBarOfSession)
                {
                    if (CurrentBars[1] < 3) { Print("Setting Historical Bar Reference point..."); return; }
                    openOfDay            = Opens[1][0];
                    closeOfPreviousDay     = Closes[1][1];
                    openOfPreviousDay     = Opens[1][1];
                    closeOfPriorDay     = Closes[1][2];
                    openOfPriorDay         = Opens[1][2];
                }
                int barsToLoad = daysToLoad * 1380;
                if (CurrentBar < barsToLoad || CurrentBars[0] < barsToLoad || CurrentBars[1] < 3)
                    {
                    if (showOutput && !backTest)
                        {
                            Print("Bars Count Requirement Not Satasfied, Waiting to load bars...");                    
                            Print("Bars loaded for Chart series: " + CurrentBar);
                            Print("Bars loaded for primary series: " + CurrentBars[0]);                            
                            Print("Bars loaded for secondary series: " + CurrentBars[1]);  
                        }
                        return;
                    }
                if (showOutput && !backTest) Print("loading Logic... Good Luck!"); PrintSettings();​
    ​
    prints are:

    Strategy enabled: 3/11/2024 12:22:51 PM
    Strategy Settings...
    Bars: panel=0 MNQ 03-24 1 Minute; Moving average over a Volume [7309-7609] time(0)=3/4/2024 1:34:00 AM time(count-1)=3/11/2024 12:23:00 PM
    Instrument: MNQ 03-24
    Timeframe: Minute Type #4 Value: 1 Time Period: 1 Value 2: 1
    Bars on chart: 7610
    ---------------------------------------------------------
    Setup...
    Account: Sim101
    Calculate: OnEachTick
    Maximum bars look back: Infinite
    Bars required to trade: 20
    Start behhavior: WaitUntilFlat
    ---------------------------------------------------------
    Historical fill processing...
    Order fill resolution: Standard
    Fill limit orders on touch: False
    Slippage: 0
    ---------------------------------------------------------
    Order handling...
    Entries per direction: 1
    Entry handling: UniqueEntries
    Exit on session close: False
    Stop & target submission: PerEntryExecution
    ---------------------------------------------------------
    Order properties...
    Set order quantity: Strategy
    Time in force: Gtc
    ---------------------------------------------------------
    Backtest: False
    NinjaScript Output: True
    Trace Orders: True
    Version: v0.0.0.1-Last updated: 29-Feb-2024
    Long 1 Quantity: 3
    Short 1 Quantity: 3
    Long 2 Quantity: 3
    Short 2 Quantity: 3
    ---------------------------------------------------------
    Bars Count Requirement Not Satasfied, Waiting to load bars...
    Bars loaded for Chart series: 1253
    Bars loaded for primary series: 7609
    Bars loaded for secondary series: 1253​​
    Last edited by Conceptzx; 03-11-2024, 05:54 AM.

    #2
    Hello Conceptzx,

    Thank you for your post.

    Since your condition that results in the print "Bars Count Requirement Not Satasfied, Waiting to load bars..." checks if (CurrentBar < barsToLoad || CurrentBars[0] < barsToLoad || CurrentBars[1] < 3) I suggest printing the value for barsToLoad as well. You are printing the CurrentBar for each series, but not the barsToLoad int to know what number the current bar is being compared to. This should help you to better understand why that value has not been met yet. When working with multi-series scripts, it can also be helpful to print the BarsInProgress somewhere to understand which bars object is calling OnBarUpdate(), such as the primary series or your added 1-day series. For more info on BarsInProgress:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    17 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    5 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Started by poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Working...
    X