MQL4 --> need help

 

Hi all,


I've created several EA's based upon a strategy that works with almost  all currency pairs by changing minor settings in the code. I'm looking to create a new strategy but my coding skills got his limitation and would need some help.


What I would like to code is the following.


When the price crosses a moving average, the EA should start counting the pips distance vs the moving average of the last cross. So you could have for example 200 pips since the last cross of the price of that moving average.

I would like to use that data to define a new strategy but I don't know how to let the EA start counting. I can use iHighest, Close Open and everything but what I can't is to let the EA start counting the pips distance

with my skills I should use Close[50] for example but as the price moves forward, we can't determine which will be the last bar that crossed that moving average.


Hoping this is clear


Thanks and kr,

Benoit 

 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
 
No need “to let the EA start counting.” Just loop through the bars until you find “the price crosses a moving average.” The index where you find it is the count.
 
William Roeder:
No need “to let the EA start counting.” Just loop through the bars until you find “the price crosses a moving average.” The index where you find it is the count.
Or just store the price where they crossed, and find the diffence while checking for another cross.