MQL4 how to identify in the past 10 days, MA 20days never below MA 10days?

To add comments, please log in or register
zeeye
17
zeeye  

MQL4 how to identify in the past 10 days, MA 20days never below MA 10days? which means the 20-day average line is always above 10-day average line.


thanks 

Seng Joo Thio
399
Seng Joo Thio  
zeeye:

MQL4 how to identify in the past 10 days, MA 20days never below MA 10days? which means the 20-day average line is always above 10-day average line.

Basically these lines:

double MA20, MA10;
bool above = true;
for (int i=1; i<=10; i++)
{
   MA20 = iMA(_Symbol,PERIOD_D1,20,0,MODE_SMA,PRICE_CLOSE,i);
   MA10 = iMA(_Symbol,PERIOD_D1,10,0,MODE_SMA,PRICE_CLOSE,i);
   if (MA20<=MA10)
   {
      above = false;
      break;
   }
}

if, after this, above is still true, then you have it - MA20 has been above MA10 for the past 10 days.

zeeyeetee
82
zeeyeetee  
Seng Joo Thio:

Basically these lines:

if, after this, above is still true, then you have it - MA20 has been above MA10 for the past 10 days.

thanks for your help. 

To add comments, please log in or register