0
votes

I am trying to write MQL4 code to find the exact price and time for all the 2 MA (50 and 100) earlier crossovers that has already taken place in my MT4 charts.

Would appreciate any pointers.

Thanks,

1

1 Answers

1
votes
  1. use a for loop to cycle through all the candles on your chart.
  2. Get the fast iMA() zone (if fast iMA() > slow iMA(), then it is buy zone; if fast iMA() < slow iMA(), then it is in sell zone).
  3. Get the iMA zone (#2) for current and previous/next candle.
  4. If the 2 zones don't match (ie, 1 is buy zone and the other is sell zone), then a crossing occurred.
  5. Add that candle time to an array.

Not sure how you can get the exact price though (the crossing don't usually occur at the exact start/end of candle, so it is very difficult to determine the exact crossing time/price) unless you do the above on tick level instead of candle level. Good luck.