cannot load indicator 'Moving Average' [4302]

To add comments, please log in or register
shojaeymh
9
shojaeymh  

hey Every1!

Im starting EA programming and i wanted to create a/an small ea but when i run it on my chart it gives me this erorr:

cannot load indicator 'Moving Average' [4302]

Here is the code:

bool AUDJPYflag=false;
bool GBPUSDflag=false;
bool USDCHFflag=false;
bool USDJPYflag=false;
bool USDCHNflag=false;
bool USDRUBflag=false;
bool AUDUSDflag=false;
bool NZDUSDflag=false;
bool USDCADflag=false;
bool USDSGDflag=false;
bool AUDNZDflag=false;
bool CADCHFflag=false;


void OnTick()
  {
   expertforCurrency("AUDJPY",AUDJPYflag);
   expertforCurrency("GBPUSD",GBPUSDflag);
   expertforCurrency("USDCHF",USDCHFflag);
   expertforCurrency("USDJPY",USDJPYflag);
   expertforCurrency("USDCHN",USDCHNflag);
   expertforCurrency("USDRUB",USDRUBflag);
   expertforCurrency("AUDUSD",AUDUSDflag);
   expertforCurrency("NZDUSD",NZDUSDflag);
   expertforCurrency("USDCAD",USDCADflag);
   expertforCurrency("USDSGD",USDSGDflag);
   expertforCurrency("AUDNZD",AUDNZDflag);
   expertforCurrency("CADCHF",CADCHFflag);

  
  }



 double SMA(int days,string symbol)
 {
   double SMAArray[];
   //int SMADefinition = iMA(_Symbol,_Period,days,0,MODE_SMA,PRICE_CLOSE);
   int SMADefinition = iMA(symbol,PERIOD_H4,days,0,MODE_SMA,PRICE_CLOSE);
   ArraySetAsSeries(SMAArray,true);
   CopyBuffer(SMADefinition,0,0,10,SMAArray);
   return SMAArray[0];
 
 }
 void expertforCurrency(string symbol,bool &flag)
 {
   double sma5= SMA(5,symbol);
   double sma20 = SMA(20,symbol);
   double sma50 = SMA(50,symbol);
   if(sma5>sma20 && sma20>sma50 && flag == false)
   {
      flag=true;
      Print(symbol+"   Buuuuuy   "+TimeCurrent());
   }
   if(sma5<sma20 && sma20<sma50 && flag == false)
   {
      flag=true;
      Print(symbol+"   Seeellll   "+TimeCurrent());
   }
   if(flag==true)
   {
      if(!(sma5<sma20 && sma20<sma50) && !(sma5>sma20 && sma20>sma50))
      {
         flag=false;
         Print(symbol+"   Bad Thing Occured!   "+TimeCurrent());
      }
   }
 
 }

this worked for only 1 symbol and i tried to function it to call in multiple currency pairs.

So why im getting this error? and what logic i should learn to fix this?!

Thank You!

Konstantin Nikitin
11948
Konstantin Nikitin  
To add comments, please log in or register