How to loop through the bars to identify first moving average cross over. Just the description is what I need I can code it. Am new to MQL
-
Loop through each index until you find a cross.
int i=1; for(;;++i){ double aPrev = …(i+1), aCurr = …(i), bPrev = …(i+1), bCurr = …(i); bool wasUp = aPrev > bPrev, isUp = aCurr > bCurr, isCross = isUp != wasUp; if(isCross) break; } Print("Last cross at "+i);
-
Do you really want to find the last cross? More likely, you want to check for a cross on a new bar.
E-vibes:
Tnx dear.
I copied only 3 data in my moving average buffer so is it possible to loop through more than what I copied in the buffer in my for loop block
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register