MQL 4: Stop loss trouble

10

Hi Everyone,

I've created a strategy that requires me to place a stop loss above/below the previous bar depending on whether I'm short or long. It uses the high/low, (HL), the ATR to guage the distance, and an ATR multiplier to decide on te increment of distance from the high/low. I've worked out the calculations and have found them to be correct (hopefully) but when I test it, the EA places a stop 1-2 pips from where the trade was opened which has not been the right place on any of the occassions I've checked (running test on open prices only for now).

```if(LongOrShort == 1) { //long
HL = Low[1];
ATR = (volMultiplier * VolATR);
StopL = NormalizeDouble((HL - ATR), 5);
}
if(LongOrShort ==2) { //short
HL = High[1];
ATR = (volMultiplier*VolATR);
StopL = NormalizeDouble((HL + ATR), 5);
```
Moderator
14029

` ATR = (volMultiplier * VolATR);`

Where do you get the highlighted variables' values from?

2978

it is not right to comment without seeing all of the codes
10

Hello,

VolATR is just an average true range
iATR(...)
The multiplier is an external double (I have it set at one by default).

So in theory, the stop should appear either 1 x the average true range above the previous high for a short or 1 x the average true range below the previous low for a long.

I’m out and about at the minute so I don’t know how helpful this is. Let me know if you need anything else. Thank you!