Announcement

Collapse
No announcement yet.

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X