atr trailing stop - page 3

To add comments, please log in or register
Seng Joo Thio
1759
Seng Joo Thio  
user904:

I had it work only one time, but still the last order failed with error 4756.

Stop Loss fails with message: "CTrade::PositionClose() method failed. Return code=10006."

Some entries also execute at unusual prices.  See picture.

Why is the buy entry price above the actual candle body?

Stop Loss failed again at 18:30. See 2nd pic.

Ok, couple of things:

(1) Buy arrows appear above the candle body due to spread - this is especially obvious when you run at M1 timeframe since M1 candles are short, relative to spread.

(2) PositionClose() fails due to magic number mismatch, so I've added trade.SetExpertMagicNumber() call in your code.

(3) Due to the erratic nature of Chandelier.mq4 ("erratic" because there is no deterministic "pattern" to check for open/close conditions, since the long/short stop lines can end earlier, or later, than the candle that cuts it), I've added a few more lines that keeps track of the "last known long/short stops" instead of relying on the prevalent values taken from the indicator. So I've updated your "if"s that deal with close conditions to make use of these last know values.

I've changed your code directly... attached is a modified version of your EA - you can search for "// SJT" to see the places that I've changed.

Files:
atrx_ea.mq5 9 kb
user904
41
user904  
Seng Joo Thio:

Ok, couple of things:

(1) Buy arrows appear above the candle body due to spread - this is especially obvious when you run at M1 timeframe since M1 candles are short, relative to spread.

(2) PositionClose() fails due to magic number mismatch, so I've added trade.SetExpertMagicNumber() call in your code.

(3) Due to the erratic nature of Chandelier.mq4 ("erratic" because there is no deterministic "pattern" to check for open/close conditions, since the long/short stop lines can end earlier, or later, than the candle that cuts it), I've added a few more lines that keeps track of the "last known long/short stops" instead of relying on the prevalent values taken from the indicator. So I've updated your "if"s that deal with close conditions to make use of these last know values.

I've changed your code directly... attached is a modified version of your EA - you can search for "// SJT" to see the places that I've changed.

Got it!! Working perfectly now.

Thank you so much for taking the time to explain and help!

123
To add comments, please log in or register