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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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