CAParticipant
New
Hello! So, as I promised, here is the initial code (before de trailing stop optimization). If you have any comments, I will be glad to read them!
Additionally, I am also posting a screenshot of the backtest (by tick) with 100000 units. This time I used the CAD/JPY pair.
SHORT = 14
LONG = 40
PERIODOADX = 24
PERIODOSDECRUCE =20
PERIODODECRUCE2 = 50
Condition1 = ADX[PERIODOADX] CROSSES OVER PERIODOSDECRUCE
Condition2 = ExponentialAverage[SHORT](Close) > ExponentialAverage[LONG](Close) AND LOW[1] > ExponentialAverage[SHORT](Close)
Condition3 = ExponentialAverage[SHORT](Close) < ExponentialAverage[LONG](Close) AND HIGH[1] < ExponentialAverage[SHORT](Close)
//Long
IF NOT LongOnMarket AND Condition1 AND Condition2 THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Exit long
If LongOnMarket AND ADX[PERIODOADX] >= PERIODODECRUCE2 OR ExponentialAverage[SHORT](Close) CROSSES UNDER ExponentialAverage[LONG](Close)OR ADX[PERIODOADX] < PERIODOSDECRUCE THEN
SELL AT MARKET
ENDIF
// Short
IF NOT ShortOnMarket AND Condition1 AND Condition3 THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Exit short
IF ShortOnMarket AND ADX[PERIODOADX] >= PERIODODECRUCE2 OR ExponentialAverage[SHORT](Close) CROSSES OVER ExponentialAverage[LONG](Close) OR ADX[PERIODOADX] < PERIODOSDECRUCE THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS 150// Stops
CAParticipant
New
Nicolas, why the trailing won’t work? Could you explain us a little bit.
Thanks!