What is the problem? it is to good to be truth, it works with forex pairs in daily timeframe, the attach contemplates a spread of 3 pips and a order fee of $2. the initial capital is $10000. Here is the simple code:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = SuperTrend[3,10]
c1 = (indicator1 <= close)
IF c1 THEN
BUY 10 SHARES AT MARKET
ENDIF
// Conditions to enter short positions
indicator2 = SuperTrend[3,10]
c2 = (indicator2 >= close)
IF c2 THEN
SELLSHORT 10 SHARES AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 25
Juan, I have moved your question to forum instead of the library! 🙂
You have been trapped into the 0 bar phenomena of ProBacktest. This is something already discussed a lot in different topics. Because the backtest engine don’t look inside bar, but only once, the takeprofit are always tested before the stoploss, so if these 2 levels are met within the same bar, you always win.
This Probacktest behaviour has been modified (understand “fixed”) into the new PRT version 10.3 with the tick/tick option. I made a video about it: Tick by tick backtest