Good evening to everybody.
I open this post because I was experimenting some systems when i have noticed some backtest errors on setting stop loss and take profit, so I’ve made a test with a simple breakout strategy and the errors keep on being.
The strategy is simple: I buy nextbaropen when price close over an highest[30](high)[1] and i set a stop loss at the lowest[10](low) and the same distance i set as take profit.
The system goes like this:
defparam cumulateorders=false
entry=close
SL=entry-lowest[10](low)
if entry>highest[30](high)[1]then
buy 1 shares at market
set stop loss SL
set target profit SL
endif
graph (entry-SL) coloured(255,0,0) as "stoploss"
graph (entry+SL) coloured(0,0,255) as "takeprofit"
graph entry coloured(0,0,0) as "entry"
I also set the graph to see how probuilder it calculates stop loss, entry and take profit and actually they are alright! (I also verified manually).
But then probacktest makes substantial mistakes on closing positions of 20 or 30 pips most of the times!
I’d like someone to verify and see some comments about.
I attach a screenshot with 2 examples of mistakes.
1° example: stop loss error
Graph levels:
1,1880 take profit
1,1824 entry
1,1768 stop loss
Probacktest enter buy correctly at 1,1824 but exit selling at 1,1740 that is 28 pips under where it should sell according to my stop loss that is 1,1768 and as you can see there’s no gaps around there.
2° example: take profit error
Graph levels:
1,1844 take profit
1,1787 entry
1,1730 stop loss
Probacktest enter buying correctly at 1,1787 but exit selling at 1,1822 that is 22 pips under to where it should sell according to my take profit that is 1,1844
I wait for some comments about, maybe I am mistaking or missing something.
Thanks a lot.
Max