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

How to backtest a MTF strategy

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

    How to backtest a MTF strategy

    I have a strategy that runs on M2 as its main chart. My strategy uses some indicators, including my custom indicators, on M2 and M5 and M10. I use AddDataSeries to add a 1 tick series (for orders) and I also add M5 and M10 as additional data series.

    Now I would like to backtest the strategy. I do not need links to sample code, I believe my code is implemented properly. I just need to know what settings to select in Strategy Analyzer for backtesting my MTF strategy. Currently I am using these settings:

    Data Series:
    Instrument: (My instrument, currently m6e)
    Price Based on: Last
    Type: Minute
    Value: 2
    Time Frame:
    Start Date: 01/01/2020
    End Date: 01/23/2020
    Trading Hours: Use Instrument
    Break at EOD: checked
    Setup:
    Include commission: unchecked
    Maximum bars lookback: 256
    Bars required to trade: 20
    Historical fill processing:
    Order fill resolution: Standard: (fastest)
    Fill limit orders on touch: unchecked
    Slippage: 0
    Order Handling
    Entries Per Direction: 1
    Entry Handling: All entries
    Exit on Session Close: checked
    Order Properties:
    Set Order Quantity: Strategy
    Time in Force: GTC

    Are these settings correct? I am not getting the results I expected. Please advise.

    #2
    Originally posted by westofpluto View Post
    Are these settings correct?
    Well, unless you get an error, they are, strictly speaking, not wrong.

    But knowing if they are correct for your strategy is another issue.

    Originally posted by westofpluto View Post
    I believe my code is implemented properly.
    And just how do you know that?

    Originally posted by westofpluto View Post
    I am not getting the results I expected. Please advise.
    Have you added a ton Print statements to prove everything is correct?
    Have you stepped through every line of code in Visual Studio?

    What are the results you expect?
    What are the results you are getting?

    I advise you to go back into your code and add Print statements
    to prove everything is correct, that all values are as expected, and
    that all code paths for all BarsInProgress values are taken as expected.

    I have never seen an issue that couldn't be solved using some very well
    placed Print statements.

    Some additional thoughts:

    Do you have all the Tick & Minute historical data for M6E for the period,
    Start Date: 01/01/2020
    End Date: 01/23/2020
    already downloaded?

    Does your Strategy do its own AddDataSeries for every data series your
    indicators are adding under the hood?

    Comment


      #3
      Hello westofpluto,

      If the results are not what you expect, it is necessary to enable TraceOrders and use prints to understand the behavior.

      Enable TraceOrders, print all values used in the conditions that place orders along with the time of the bar, print the order object in OnOrderUpdate().

      Below is a link to a forum post that demonstrates how to use prints to understand behavior.


      With the information the script is using, you can use this to understand why an order was or was not placed at a specific time you are expecting.

      Save the output from the output window (right-click, Save As) to a text file and include this with your next post.
      I would be happy to assist with analyzing the output.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,605 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      13 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X