ProRealTIme not respecting stop loss
Forums › ProRealTime English forum › ProOrder support › ProRealTIme not respecting stop loss
- This topic has 14 replies, 4 voices, and was last updated 7 years ago by
GraHal.
-
-
03/05/2018 at 10:28 AM #64405
Hi all.
I had Nicolas code my strategy that all seemed to work fine in forward testing but not so trading live. An FX trade closed today at 3.5x the expected stop loss distance when it should have been only 0.6*ATR(24). The code for the part of the strategy is given below:
12345678910111213141516171819202122232425262728293031323334353637383940if alreadytraded = 0 then//money managementif case=1 thenStopLoss = 0.5*ATRelseStopLoss = 0.6*ATRendifRisk = riskpercent/100//calculate contractsequity = balance + StrategyProfitmaxrisk = round(equity*Risk)size = max(minlot,abs(round((maxrisk/StopLoss)/PointValue)*pipsize))//in all cases put pending orders on marketwhile case <> 0 and daytrading=1 and (time >= activationtime and time <=LimitHour) doif levelhi>0 thenbuy size contract at levelhi stopendifif levello>0 thensellshort size contract at levello stopendifwendendif// Friday 22:00 Close ALL operations.IF onmarket and (DayOfWeek = 5 AND time >= 220000) THENSELL AT MARKETEXITSHORT AT MARKETENDIF//set target and profitif onmarket thenif case = 1 thenset target pprofit 10set stop loss StopLossendifif case = 2 or case = 3 thenset target profit 2*ATRset stop loss StopLossendifendifcurrentprofit = strategyprofitIn this instance the trade opened live but instead of closing at the stop loss (which was 0.6*ATR[24] or 18 pips) it didn’t close until 62 pips later, which resulted in a much bigger than expected loss? Any ideas please?
Grim
03/05/2018 at 11:26 AM #6441403/05/2018 at 11:59 AM #64422Hi Nicolas
Thanks – the ATR is defined earlier in the code as atr=averagetruerange[24] but I didn’t want to paste the whole code as I had to pay you to produce it 😉
I backtested the system this morning in demo mode and it produced the correct stop loss. For some reason in the live trading it didn’t work and closed at near double the ATR instead of x0.6 ATR??
03/05/2018 at 12:12 PM #64428Just a thought and I’m sure you haven’t got it wrong … but are you running it on the correct / intended TimeFrame that the Algo is optimised for??
I have done that before … set one going and later realised I must have flicked to another TF??
03/05/2018 at 12:57 PM #6443103/05/2018 at 1:12 PM #64432Hi Guys – thanks for the replies.
Yes on the correct TF (H1) and there was no spike. Oddly it was in a much deeper loss during the 0800-0900 time but it seemed to close out when the H1 bar closed at 0900.
03/05/2018 at 1:34 PM #6443403/05/2018 at 3:43 PM #6445903/05/2018 at 5:27 PM #64467Hi Nicolas
EurJpy. Opened at 0800 at 12946 at £6 per pip. ATR was 31 at time so SL should have been 0.6*ATR[24] making 18. Actual trade closed out at 0900 at 13008. Should have only been £108 loss (18x£6) but actually closed with loss of £369 which was 62 pips (almost 2x ATR)
03/05/2018 at 7:46 PM #64494Hi GraHal
I thought set stop ploss was for pips ie stoploss =10 for example. When using a multiple of ATR do you not drop the p from loss?
Thanks
03/05/2018 at 11:55 PM #6451903/06/2018 at 9:57 AM #6454403/06/2018 at 6:52 PM #64611Ok thanks Nicolas. Still bemused as to why it didn’t activate at all. The other pairs with the same code work, just with EurJpy this is the 2nd time this has happened!
03/06/2018 at 10:17 PM #64627Hi Guys
Is it possible in the code given above to close out partial positions? Could I set a target profit for 1*ATR for half the position and then ‘n’ ATR for the remaining half?
With this strategy I have noted that if I target profit at say 1ATR the % of winning trades is higher, but of course the gain is much lower. It’s finding the right balance between setting a profit target far enough away to make the strategy profitable, but not so far away that it loses. Is there a more effective volatility based metric than using ATR perhaps?
I’d be interested to see if closing x% of the position at x% target and leaving rest to run on a trailing ATR stop for example was more profitable? Any help appreciated!
Best
Grim
03/06/2018 at 11:44 PM #64633 -
AuthorPosts
Find exclusive trading pro-tools on