Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily data - multi timeframe strategy

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

    Daily data - multi timeframe strategy

    All,

    I thought it worth posting a lesson learned for everyone’s benefit.

    Scenario

    · You are developing an intra-day strategy, which uses daily data.
    · You need to ensure you have sufficient data to prime indicators on the daily data – e.g. SMA(14).


    I’ve recently been working with an intra-day strategy which uses daily data as an input. I have been using the multi-time frame method and backtesting across historical data:

    http://www.ninjatrader-support.com/HelpGuideV6/MultiTimeFrameInstruments.html

    http://www.ninjatrader-support.com/HelpGuideV6/HistoricalData.html

    (N.B. daily data is treated differently than tick or minute data.)

    Solution

    (Assumes you have lower timeframe data in initial BarsArray[0] position. And daily data in the BarsArray[1] position.)

    I have recently found something with the daily data BarsArray. When calling this in a backtest, the BarsArray is actually filled at the start of the backtest – I suspect from the Initialise() function. This means that if you use:

    Code:
    [COLOR=blue][FONT=Courier New]if[/FONT][/COLOR][COLOR=black][FONT=Courier New] (BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=Courier New]1[/FONT][/COLOR][COLOR=black][FONT=Courier New]].Count > [/FONT][/COLOR][COLOR=purple][FONT=Courier New]14[/FONT][/COLOR][COLOR=black][FONT=Courier New])[/FONT][/COLOR]
    [COLOR=blue][FONT=Courier New]return[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
    to ensure the strategy has enough into the data, then this code will never execute. That is, the count with be the number of days you have set to be brought in the strategy. For example, if the settings are as per the backtest set-up (see the attached screenshot), then the BarsArray[1].Count will be 85; which is the number of days of daily data in the backtest (from dates 03/02/2009 to 01/06/2009 – dates in UK format). You would obviously do this if you had assumed that the array is populated as the strategy executes (i.e. at day 14 the array is 14 elements in length).

    Therefore, you should use:

    Code:
    [COLOR=blue][FONT=Courier New]if[/FONT][/COLOR][COLOR=black][FONT=Courier New] (BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=Courier New]1[/FONT][/COLOR][COLOR=black][FONT=Courier New]].CurrentBar < [/FONT][/COLOR][COLOR=purple][FONT=Courier New]14[/FONT][/COLOR][COLOR=black][FONT=Courier New]) {[/FONT][/COLOR]
    [COLOR=blue][FONT=Courier New]return[/FONT][/COLOR][COLOR=black][FONT=Courier New];[/FONT][/COLOR]
    [COLOR=black][FONT=Courier New]}[/FONT][/COLOR]
    Additionally, it would appear that the setting in the backtest dialogue box (see attached screenshot) applies to the longest timeframe within the strategy – i.e. in this case daily data. That is, the strategy will bring in the set number of days of data before executing.

    Could someone from NT support confirm the above statements are correct?

    Kind regards,

    Dan
    Attached Files

    #2
    Dan,

    The setting requires not only the longest time frame, but all time frames and instruments. By default, you need at least 20 bars on all of your series before anything will happen.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    646 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    367 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    570 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X