For loops question

 
Hi
I am new to mql5 and want to design a strategy that essentially looks for turning points on short term ma's.

The user will select a ma period and a number of ma points to loop through. Ie 5 moving average period for 50 data points

I am not sure how to loop through the moving averqge array and store where the ma gradient goes from +ve to -ve and how many times it does this and in what order during the selected period.

Any help much appriciated
Thanks

 
Show images is easy to understand.
 

sure, see attached. If you see the first 2 yellow circles, i essentially want to know that in the last 20 data points i have had a minimum and a maximum point on the moving average to trigger a trade execution.

 

I hope what i am saying is clear, please ask for more questions if not. 

 

Below is the code i have so far. 

 

         // Check data for turning points

         for(int count =MASize;Count=0; count--)

            {

            double ma[];

            ArraySetAsSeries(ma,true);

            int maHandle = iMA(_Symbol,_Period,MAPeriods,0,MAMethod,PRICE_CLOSE);

            CopyBuffer(maHandle,0,0,MASize,ma);

            double MAValuea = ma[count];

            double MAValueb = ma[count+1];

            double MAValuec = ma[count+2];

            string MinOrMax;

            if(MAValuea-MAValueb>0 && MAValueb-MAValuec<0)

               {

               MinOrMax = "min"

               }

            if(MAValuea-MAValueb<0 && MAValueb-MAValuec>0)

               {

               MinOrMax = "max"

               }               

            // then loop through to find other turning points

            

            }