my if condition in Mql4 is never established

 
in the below code `if(sma5_after > sma18_after)` never is true while this condition is repeated many times in the chart  

I use Mql4 in meta trader4 

void OnTick()
    {
       if(iVolume(_Symbol,_Period,0)<=1)
         {
          sma5_befor = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,2);
          sma5_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0);
          ...
          sma18_befor = iMA(_Symbol,_Period,18,0,MODE_SMA,PRICE_CLOSE,2);
          sma18_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0);
    
          ...
    
          sma5_slop = (sma5_after - sma5_befor) / Point;
          ...
          if(sma5_after > sma18_after){  // this condition never is true in meta trader4 tester!! WHY?
             Print("OK");
          }
         }
      }  

  

Please Help Me  
thank you
 
4880127477:
in the below code `if(sma5_after > sma18_after)` never is true while this condition is repeated many times in the chart  

I use Mql4 in meta trader4 

  

Please Help Me  
thank you

Because you compare the 5 sma to itself. 

          sma5_befor = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,2);
          sma5_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0);
          ...
          sma18_befor = iMA(_Symbol,_Period,18,0,MODE_SMA,PRICE_CLOSE,2);
          sma18_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0);



 
Laszlo Tormasi:

Because you compare the 5 sma to itself. 



Oh God, what a ridiculous mistake I made! :)
Thank you dear friend
Good luck
 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
ok, thank you