{"id":219,"date":"2014-05-07T06:01:33","date_gmt":"2014-05-07T11:01:33","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=219"},"modified":"2021-04-09T14:44:56","modified_gmt":"2021-04-09T13:44:56","slug":"why-do-backtest-results-change","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2014\/05\/07\/why-do-backtest-results-change\/","title":{"rendered":"Why do backtest results change?"},"content":{"rendered":"
From time to time we receive questions about why you can get different results back-testing the same code.<\/p>
There are many reasons for differences in backtest results:<\/p>
For example if past history is updated\/changed due to splits for example or backfill or external data update.<\/li>
May happen if your formula uses Param() functions that output values that may be changed from the Parameter window.<\/p>
Note that Parameters in Analysis window use shared ChartID=0, which means that if two formulas use same parameter names they would share parameter values as well.<\/li>
Sometimes even slight change to the formula causes big change in the results, for example if your formula uses #include and included code has changed<\/p><\/li>
Such code produces some data that is later used to produce next run output (for example your code produces composites that are later used<\/strong> – if those composites change – the input data change so the results change, or if your formula uses previous backtest equity<\/strong> or if your formula uses STATIC variables<\/strong> without deleting\/clearing them at the beginning)<\/p> This occurs when your formula directly or indirectly calls any function that produces random numbers<\/strong> such as Random or mtRandom<\/p> This occurs when your formula directly or indirectly calls any functions that read external files or data that have changed between backtests. It can be as trivial as using current time in your formula.<\/p> This one is subtle and can be easily overlooked by non-experienced users. One has to understand that global (per-backtest) settings are applied to entire portfolio. If one changes those settings on per-symbol basis, then “last write” counts, and it means that result of your backtest will depend on which execution thread ended last. In Windows OS, it is generally unpredicatable which thread ends first because of so many factors that affect execution time. So your backtest may use different settings in different runs as a result of this. Bottom line: never change global settings in your formula to non-constant value.<\/li><\/ol>","protected":false},"excerpt":{"rendered":" From time to time we receive questions about why you can get different results back-testing the same code.There are many reasons for differences in backtest results:Different data For example if past history is updated\/changed due to splits for example or backfill or external data update.Different settings \/ parameters May happen if your formula uses Param() […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[14,15],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/219"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=219"}],"version-history":[{"count":3,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"predecessor-version":[{"id":1581,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/219\/revisions\/1581"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}