backtest not same result as live
Forums › ProRealTime English forum › ProOrder support › backtest not same result as live
- This topic has 6 replies, 3 voices, and was last updated 1 year ago by
ullle73.
-
-
07/12/2022 at 8:23 PM #197190
can someone tell me why backtest does not show nearly the same results as live?
test is on dax40, 2 points spread.
code12345678910111213141516171819202122232425262728293031323334353637383940414243444546// adr: 40, TP: 130, SL: 60, trail: 50, 3,19 gain to loss, 45% win, 24 break even, 2500 euro. 11,73% DDDEFPARAM CumulateOrders = FALSEIF Not OnMarket THENMyExit = 0ELSEc1 = 0ENDIF// ADR Average Daily RangeMyADR = average[20,0](Dhigh(1) - Dlow(1))//IF (Time = 000000) OR ((Time > 000000) AND (Time < Time[1])) THENMyHI = highMyLO = lowc1 = 0ENDIFIF Time <= 090000 THENMyHI = max(MyHI,high)MyLO = min(MyLO,low)MyRange = MyHI - MyLOc1 = ((MyRange / MyADR) * 100) < x //75ENDIFIF Time >= 090000 AND c1 THENBUY 0.5 Contract AT MyHI + y * pipsize STOPSELLSHORT 0.5 Contract AT MyLO - y * pipsize STOPSET TARGET pPROFIT PL //40SET STOP pLOSS SL //80ENDIFIF MyExit = 0 THENIF (LongOnMarket AND (close - TradePrice) >= t * pipsize) OR (ShortOnMarket AND (TradePrice - close) >= tS * pipsize) THEN //27.5 37.5MyExit = TradePriceENDIFENDIFIF MyExit > 0 THENSELL AT MyExit STOPEXITSHORT AT MyExit STOPENDIF//GraphOnPrice TradePrice coloured(0,0,255,255)//GraphOnPrice MyHI coloured(0,128,0,200)//GraphOnPrice MyLO coloured(255,0,0,255)//Graph close - TradePrice//Graph c1//Graph MyADR//Graph MyRange07/13/2022 at 8:44 AM #197203This has been addressed many times.
Here you can find an answer by Nicolas https://www.prorealcode.com/topic/backtesting-and-demo-account-algo-doesnt-match-live-algo/#post-175691, which I am posting:
This is a non-exhaustive list of the elements that can impact a live trading strategy and create differences with a demo account and/or backtests, that could help you:
- Spread
- Slippage
- Orders rejections due to one of the above reason, but also because of the allowed distance from current price to put pending orders (known as “minimal distance”)
- Different trading hours (ProOrder code launched in a different time zone / custom hours, by the user)
- Coding problem: division by zero error, null or negative periods for indicators, ..
- Lack of responsiveness of IG demo servers (if IG is the broker), although this has improved considerably since last year.
- Make backtests without tick-by-tick option
- “set stop trailing” instruction that give IG the total control of your stoploss, can be moved differently between accounts due to points above
- Limited risk accounts and their rules
- Guaranteed stoploss rules and fees
- Starting a strategy at a different time (1 hour or even 1 minute later): depending on the code of the strategy, the results of some calculations could be different.
- Margin required on the trading account (no demo or backtest tests are made on this subject)
- Overnight and overweekend fees
Because backtests are only tested on history with no connection to live market , you may encounter differences with real live trading environment subject to spread enlargement, slippage, etc. If your stop hasn’t move, there must be information of an error into your orders rejected list you can consult with CTRL+O.
IG orders list history may be also helpful!07/13/2022 at 10:47 AM #197214yes ive seen that one before, cut cant see why backtest only takes 1 pos and live took 5?
what i can see is my system is ok on all points:
- Spread – OK
- Slippage – OK
- Orders rejections due to one of the above reason, but also because of the allowed distance from current price to put pending orders (known as “minimal distance”) – NONE
- Different trading hours (ProOrder code launched in a different time zone / custom hours, by the user) – SAME
- Coding problem: division by zero error, null or negative periods for indicators, .. – NO?
- Lack of responsiveness of IG demo servers (if IG is the broker), although this has improved considerably since last year.
- Make backtests without tick-by-tick option – USED WITH TICK-BY-TICK
- “set stop trailing” instruction that give IG the total control of your stoploss, can be moved differently between accounts due to points above – NOT USING
- Limited risk accounts and their rules – NO
- Guaranteed stoploss rules and fees – NOT USING
- Starting a strategy at a different time (1 hour or even 1 minute later): depending on the code of the strategy, the results of some calculations could be different.
- Margin required on the trading account (no demo or backtest tests are made on this subject) – MARGIN OK
- Overnight and overweekend fees – NEVER HELD OVERNIGHT
07/13/2022 at 12:38 PM #19722007/13/2022 at 8:16 PM #19724607/13/2022 at 9:14 PM #197250Launch BT and Live again at the exact same time?
A possible answer to above question would be … Yes I started both Backtest and Live on Wednesday 13 July at 21:00 hrs (UTC+1).
I’m not being facetious 🙂 above is the quickest way (for me) to show that the 3rd from bottom in Nicolas List is not about Timeframe. The bullett point is referring to clock time.
Mostly it makes no difference, but it just might … if your code contains certain calculations etc.
1 user thanked author for this post.
07/13/2022 at 10:02 PM #197253 -
AuthorPosts
Find exclusive trading pro-tools on