I received the erro in attached during my ALgo .
Ithink could be the trailing code ,
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
33
34
SL = stoploss // Initial SL
TP = TP
TSL = 1 // Use TSL?
TrailingDistance = 5 // Distance from close to TSL
TrailingStep = 5 // Pips locked at start of TSL
//************************************************************************
IF TSL = 1 THEN
//reset the stoploss value
IF NOT ONMARKET THEN
newSL = 0
CAND = 0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL = 0 AND CLOSE - TRADEPRICE (1 ) >= TrailingDistance* PipSize THEN
newSL = TRADEPRICE (1 ) + TrailingStep* PipSize
ENDIF
//next moves
CAND = BarIndex - TradeIndex
IF newSL > 0 AND CLOSE [ 1 ] >= HIGHEST [ CAND] (CLOSE ) THEN
newSL = CLOSE [ 1 ] - TrailingDistance* PipSize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL > 0 THEN
SELL AT newSL STOP
ENDIF
SET STOP pLOSS SL
ENDIF
Could you please help to understand better ?
Thanks