-1

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

Alex
  • 1

1 Answers1

2

You have a typo in sma18_after assignment. This line:

sma18_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0);

should be this:

sma18_after = iMA(_Symbol,_Period,18,0,MODE_SMA,PRICE_CLOSE,0);
Enivid
  • 210
  • 2
  • 9
  • Are you able to look at my question here: https://stackoverflow.com/questions/66410403/istradeallowed-not-returning-what-i-would-expect +1. – w0051977 Mar 01 '21 at 12:56