closing with crossover
-
dear admin
I have a problem here. I am trying to make an EA that open trades with given signals, but I want to close trades with crossover of 6ma and 15ma, as I show in picture.6ma from bottom move and cross the 15ma.i want close the open trade just right there.
I wrote something like this, but it doesn`t work. https://fxdreema.com/shared/QMhgcrLF
could you please help me.
......
SAMPLE.jpg -
-
dear admin
thank you for your help. got that and solve it. but there is another problem.when the 6 ma cross the 15 ma, where the position is closed is 15-20 pip upper than crossover point. and this is not candle closing too. and this mean 20 pip loss more.
can in eliminate this distance?

......
error 1.jpg -
I've accomplished this by creating a formula by using addition or subtraction of pips from an MA related to candle to control both entries and exits. Sometimes a crossover occurs when the candle price moves to far from the MA and an entry or exit can be late so I set condition to enter or exit if resulting formula is less than a fixed number of pips. Hope this helps.....Admin may have better suggestion though.
-
Actually, your first issue can be easily solved by exiting when the candle high crosses the MA for exit I believe?
-
Normally in "Condition", indicator values from the current candle (Candle ID = 0) are used, which means that you can detect crossover in the middle of the candle. At that very moment the crossover will be true and visible. Then, after that candle is closed, nothing will look the same as few moments before. Sometimes crossover happen and then the price goes back and at the end of the candle it looks that there was no crossing at all. Just look at the indicator while it's working - all the indicator points are staying still, but the very newest one is moving on every tick, up-down, up-down.
-
hi
thank you very much,
