Find indicators last cross

 

Hi, i'm trying to get the value of the candle of the last MACD cross.

I found this conversation that might work for me, but it seems it's for mt5 and I need it for mt4.

https://www.mql5.com/en/forum/158877

I attach the code found so you don't need to look for it :)


int find_XX_cross(int iBeg=0){
  for(;iBeg < Bars; ++iBeg){
     bool wasAbove = xx(..., FAST, iBeg+1) > xx(..., SLOW, iBeg+1);
     bool  isAbove = xx(..., FAST, iBeg)   > xx(..., SLOW, iBeg);
     bool hasCrossed = isAbove != wasAbove;
     if(hasCrossed) return iBeg;
  }
/////
int Last_Crossed = find_XX_cross();
int Prev_Cross[2];
Prev_Cross[0]    = find_XX_cross(Last_Crossed+1);
Prev_Cross[1]    = find_XX_cross(Prev_Cross[0]+1);

Thank you in advance!

Find Oscillators Last Cross
Find Oscillators Last Cross
  • 2016.04.13
  • www.mql5.com
Hi, I would like to ask if there is any existing indicator or any way to find statistic Oscillators previous crossed...
 
NikoSeneca: I found this conversation that might work for me, but it seems it's for mt5 and I need it for mt4.
  1. It's not MT5. It's not MT4. It's a generic outline for you to replace XX/xx with your actual indicator name/code.
  2. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21
Reason: