I have an inconsistency in execution of code and am wondering if some could test and get the same results.
IF LONGONMARKET THEN SET STOP pLOSS SET TARGET pPROFIT – Doesn’t work
IF SHORTONMAKRET THEN SET STOP pLOSS SET TARGET pPROFIT – Does work
Maybe someone can explain why there’s this inconsistency
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//***** EXAMPLE 1: LONGONMARKET *****
//*****STOP pLOSS AND TARGET pPROFIT DON'T WORK****
// Definition of code parameters
DEFPARAM CumulateOrders = FALSE // Cumulating positions
// Conditions to enter long positions
indicator1 = close
indicator2 = Average [ 20 ] (totalPrice ) //
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
IF LONGONMARKET THEN
SET TARGET pPROFIT 45 //
SET STOP pLOSS 40 //
ENDIF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//***** EXAMPLE 2: SHORTONMARKET *****
//*****STOP pLOSS AND TARGET pPROFIT DON'T WORK****
// Definition of code parameters
DEFPARAM CumulateOrders = FALSE // Cumulating positions
// Conditions to enter short positions
indicator1 = close
indicator2 = Average [ 20 ] (totalPrice ) //
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
IF SHORTONMARKET THEN
SET TARGET pPROFIT 45 //
SET STOP pLOSS 40 //
ENDIF
Thank you.