PaulParticipant
Master
just a test to compare the visual differences real- vs backtest price.
Even in this case below, when buying higher then in the backtest, I want to maintain its exit-scenario i.e. when backtest gain >= 0.25%. The only way is manual interference.
// dax 1min
once enterdate= 20190909
once entertime=090000
once closedate=enterdate
once closetime=155500
// backtest price
once BTbuyprice=12209.4
once BTsellprice=0
// real live price
once RLbuyprice =12215.2
once RLsellprice=0
// check when trade starts
if date=enterdate and time=entertime then
TradeOn=1
endif
// check when trade ends
if date=closedate and time=closetime then
TradeOFF=1
endif
if TradeOn then
if TradeOff=0 then
if (RLbuyprice>0 and RLsellprice=0) and (BTbuyprice>0 and BTsellprice=0) then
BTpositionperformance=((close/BTbuyprice)-1)*100
RLpositionperformance=((close/RLbuyprice)-1)*100
Offset=RLpositionperformance-BTpositionperformance
elsif (RLbuyprice=0 and RLsellprice>0) and (BTbuyprice=0 and BTsellprice>0) then
BTpositionperformance=((close/BTsellprice)-1)*100
RLpositionperformance=((close/RLsellprice)-1)*100
Offset=RLpositionperformance-BTpositionperformance
endif
endif
endif
if TradeOn=1 and TradeOFF=1 then
RLpositionperformance=0
BTpositionperformance=0
TradeOn=0
TradeOff=0
Offset=0
endif
return BTpositionperformance as "BTpositionperformance",RLpositionperformance as "RLpositionperformance", Offset as "Offset %"
Sorry I don’t understand, what do you mean exactly?
PaulParticipant
Master
As example, the backtest had 3 trades today and all won. Say the total is 100%. The 3 winning live trades produced 62% compared to the backtest. I wondered how could I prevent such differences.
Working with % for the breakeven and trailing-stop, it’s black & white and if the real paid price with slippage & spread difference too much from the backtest price it could influence results, in a good or bad way especially in small ranging markets or with big retracements.
I use excel to compare sometimes the real vs backtest trades and as experiment coded this comparison-indicator. I thought maybe this could be the basis from something more, but it’s not.
It’s in part unavoidable and more visible in short term trading.
oh ok! I got it. You are right to say that the results may differ a lot when trading on shorter timeframes, especially because of slippage and spread. I’m afraid there is no easy way to simulate it.
If you are using market orders, you could try using pending stop orders with a random +/- points value around the close.
PaulParticipant
Master
I think it’s an often overlooked issue and I realised that because of a post in another thread.
Thanks for the tip. I will give it a try!