Custom price crossing MA condition with minimum turnover distance
-
Note: I wasn't sure how to phrase the subject. I think I can do what I want but could use some assistance on the logic:
My EA relies on price crossing above or below an MA, utilizing the minimum turnover distance (MTD). So for example, if price moves below MA20 by 100 pips, then crosses back up, EA triggers a buy order.
What I want to do is get into the trade earlier. In the above example, I would still want price to move below the MA20 by 100 pips, but trade to trigger when it moves back up 80 pips, so it would still be 20 pips below the MA20.
Anyone have any advice on how to program this?
-
@osryan That can be very dangerous. How can you be sure the price will finally cross up the MA?
-
@l-andorrà Can't be sure of anything. I'm not worried about that part. If it doesn't and hits my stop loss, that's fine. I'm just trying to figure out how to make the MTD asymmetrical. Need it to drop below MA as defined by MTA, but not apply to the move back up. Since it isn't a crossover then, I think I'm using the wrong condition.
-
@osryan in other words:
- if price is less than 20 pips below MA,
- check if price has been 100 pips below MA at some point
-
Here's a loop trick for that
https://fxdreema.com/shared/oGxoWZwX -
@roar Ahh, that makes sense. Not as difficult as I was making it to be. Thank you!
-
@roar Oh I see. That makes sense. Thanks for the help, saved me a lot of time with that loop!