Need help making an indicator checks to see if MA of current price is higher/lower than MA in the last X sessions

 
I'm trying to make an indicator that checks the value of an LWMA against itself to see if it is higher or lower than any of its values in the past 20 sessions.

I did write some code but I have no experience with MQL or programming, in general, and this code is definitely not the right way to do it:

   for(int i = 0; i < Bars - counted_bars; i++)
     {
       MABuffer[i] = iMA(NULL,0,MAPeriod,0,MAMethod,MAApplied,i);
       double MaxMA = MABuffer[ArrayMaximum(MABuffer,CompPeriod,i)];
       double MinMA = MABuffer[ArrayMinimum(MABuffer,CompPeriod,i)];
       
       if (MABuffer[i] > MaxMA)
           BullishBuffer[i]=100;
       if (MABuffer[i] < MinMA)
           BearishBuffer[i]=100;
       else NeutralBuffer[i]=100;
Could someone put me on the right track? I know I'm doing this wrong.
 
bump
Reason: