Code to store price of last two moving average crosses
Russfox: I would like to be able to compare the last two moving average cross prices (slow MA).
How would I be able to change the methods shown in this thread to be able to do this? https://www.mql5.com/en/forum/216386
- Makes no sense. Last cross on bar X, Previous cross on bar Y. Compare X vs Y makes no sense.
- Find the last cross, find the previous cross, define your compare.
CrossValues first; CrossValues next = CrossNone; int iFirst = 0; for(; iFirst+1 < Bars; ++iFirst){ first = GetCrossAsAtBar(iFirst, FastPeriod, SlowPeriod); if(first != CrossNone) break; } int iNext = iFirst+1; for(; iNext+1 < Bars; ++iNext){ next = GetCrossAsAtBar(iNext, FastPeriod, SlowPeriod); if(next != CrossNone) break; } if(next != CrossNone){ // Compare iFirst vs iNext
Ok, I will give this ago.
I want to compare the slowMA price value after (or just after..) each cross so I can do something with this information.
The above code should at least give me the candle post crosses so I'll extract the price data from there.
Just to be clear, I'm not looking to compare up cross to down cross, as you say, this would make no sense.
I have found the above thread while looking for some help. I would like to be able to compare the last two moving average cross prices (slow MA).
How would I be able to change the methods shown in this thread to be able to do this?
https://www.mql5.com/en/forum/216386
The methods seem to only get the last MA cross. How would you create an array to store the last two crosses that could then be read and used to get the proce data from to then compare?
Any help would be appreciated.