I would like to use the Average True Range (ATR) value as an exit criteria to my strategy.
I would like to test the following possibilities. Any help would be much appreciated.
- Take profits if pips = ATR
- Take profit if pips = ATR/2
- Stop loss if pips = ATR
- Stop loss if pips = ATR/2
- Trailing stop if pips = ATR
- Trailing stop if pips = ATR/2
Please find below a code snippet to code that:
atr = averagetruerange[14]
//set TP 2 times the ATR and SL 1 time the ATR
SET TARGET PROFIT atr*2
SET STOP LOSS atr
Thank you for your prompt advice Nicolas.
I will give it a try 😉
Would this be a problem if the ATR value is not a whole number? i.e. if ATR = 11.3 , would the SL or TP be set at 11 i.e. the nearest whole number?
Or would it be rejected as 11.3 is not a valid pip value?
Regards
Kiran
It’s not a problem since SET STOP LOSS and SET TARGET PROFIT need “price” value, not point one (these are different instructions : PLOSS and PPROFIT).
e.g.:
SET TARGET PROFIT 0.0032
SET STOP LOSS 0.010