Hi
I have the below code below that simply sets a stop based on the ATR when either in a long or short position. I have been forward testing on MY IG demo account since back testing does not give reliable results.
The strategy works on a daily time frame on the South African TOP 40 index. The thing I find very strange is that it does not set the stop on the first trade, only on the second trade does it set the stop, Why is this?
Am I the only person to experiencing this or is this peculiar to prorealtime?
rang= AverageTrueRange[2]
if longonmarket then
SET STOP pLOSS (.16 * rang)
endif
if shortonmarket then
SET STOP pLOSS (.15 * rang)
endif
Do these lines of codes are written before or after the BUY/SELLSHORT instructions?
Hi Nicolas
After the BUY and SELLSHORT instruction.
I was wandering whether it should be enclosed within the BUY or SELLSHORT instruction.
Regards
Ian
You can try to make a new variable named “stoploss” for instance, and give it the value of your calculated SL points (make it different when you initiate your orders BUY and SELLSHORT).
Then, later in the code, add the SET stop loss line as is:
SET STOP pLOSS stoploss
Ok . So if I understand correctly I will set the variable in the buy or sellshort instruction and later in the code use the stop loss command using the variable originally set in the buy or sellshort command.
Thanks, I will give it a try.
Regards
Ian