Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with a Strategy

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

    Help with a Strategy

    Hi, Sorry for the generic title but I just need someone to help me understand why the attached strategy I have written requires 21 days of data loaded when I expect it to require 14. I have three timeframes in the script, 1 Minute, 5 Minute and Daily. The Daily is used to calculate the ATR 14 period and hence I would expect to need 14 days of data loaded but the script won't work with less than 21 days of data. Can you please take a look at the attached .cs file and advise?
    Attached Files

    #2
    Hello, thanks for writing in. This is coming from the weekends being ignored. E.g. if you load 15 days of 1 minute data until today, you will get 12 bars because the weekends are ignored. You can test it out with this code:
    Code:
    if(BarsInProgress == 0)
                {
                    if(Bars.IsFirstBarOfSession)
                    {
                        Print("Minute Series " + CurrentBars[0] + " " + Times[0][0]);
                    }
                }
                if(BarsInProgress == 1)
                {
                    Print("Daily Series " + CurrentBars[1] + " " + Times[1][0]);
                    Print(" ");
                    if(CurrentBars[1] < 14)
                    return;
                    Print("CurrentBar " + CurrentBars[1]);
                    Print("Daily ATR Value " + ATR(BarsArray[1], 14)[0]);
    
                }​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    46 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X