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

Inconsistent Backtesting Results

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

    Inconsistent Backtesting Results

    Hello,

    I was backtesting a strategy and getting inconsistent results. The only thing I changed between the tests was the timeframe I was testing over.

    If I just tested over the last 22 days (1/2/23 to 1/25/23) it would show 8 trades. However, if I increased the time window to cover the last four months there was only 3 trades. And when I increased it to test over all of 2022 there was 0 trades executed.

    I used the same code, the same settings, etc. Just changed the timeframe.

    I haven't seen this with other strategies and am at a loss at what could cause this, so I'm not sure how to troubleshoot it. Any advice of where to start is appreciated.

    Click image for larger version

Name:	image.png
Views:	29
Size:	81.9 KB
ID:	1233120

    #2
    Hello BQuinton,

    Thanks for your post.

    As a general rule for backtesting: Same Input data + Same strategy code and parameters + Same timeframe = Same results.

    I've included some additional resources on the differences between historical and realtime data and further reading on these discrepancies that should be minded while backtesting. My colleague Chelsea's forum post goes into depth on creating strategies and backtests that produce consistent results.

    Discrepancies between backtesting and realtime data — https://ninjatrader.com/support/help...ime_vs_bac.htm

    Comparing real-time, historical, and replay performance — https://ninjatrader.com/support/foru...d.php?t=102504

    Also, re-download the historical data you are testing on to ensure you have historical data for the timeframe you are backtesting by going to Control Center > Tools > Historical Data > Download.

    Download historical data: https://ninjatrader.com/support/help...8/download.htm

    To fully understand how a strategy is behaving and placing orders, debugging prints should be added to the script to see exactly how the logic is processing.

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

    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I may be of further assistance.​
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by QuantKey_Bruce, Today, 02:31 PM
    2 responses
    9 views
    0 likes
    Last Post QuantKey_Bruce  
    Started by Cedalgo, Today, 01:41 AM
    1 response
    20 views
    0 likes
    Last Post NinjaTrader_Emily  
    Started by javiertraderpro, 03-27-2023, 11:23 AM
    4 responses
    40 views
    0 likes
    Last Post UnSuccessfulTrader  
    Started by Waxavi, Yesterday, 03:19 PM
    4 responses
    18 views
    0 likes
    Last Post kpoulis
    by kpoulis
     
    Started by markdshark, Today, 12:37 PM
    4 responses
    14 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X