all symbols appear green

 

In the following code, all the symbols appear on the chart as green/buy.

Is there any reason why it doesn't check the 2nd part of the else if statement?

if(
            (Bid > iMA(symbol[y],PERIOD_D1,10,0,MODE_EMA,0,0)) &&
            (Bid > iMA(symbol[y],PERIOD_D1,20,0,MODE_EMA,0,0)) &&
            (Bid > iMA(symbol[y],PERIOD_D1,50,0,MODE_EMA,0,0)) &&
            (Bid > iMA(symbol[y],PERIOD_D1,100,0,MODE_EMA,0,0))


#property indicator_chart_window

extern int scaleX=20,
           scaleY=20,
           offsetX=45,
           offsetY=20,
           fontSize=40,
           corner=2,
           symbolCodeBuy=149, 
           symbolCodeSell=149, 
           symbolCodeNoSignal=149; 
           
extern color signalBuyColor=Green,
             signalSellColor=Red,
             noSignalColor=DarkOrange,
             textColor=Black;            
            
//int period[]={10,20,50,100};  ,
string symbol[]={"USDCHF","GBPUSD","USDJPY","EURUSD","AUDUSD","USDCAD","EURGBP","EURCHF","EURJPY","GBPJPY","GBPCHF","EURCAD","EURAUD","NZDUSD","CHFJPY","AUDJPY","AUDNZD","CADJPY","XAUUSD"};

//////////////////////////////////////////////////////////////////////
//
// init()          
//
//////////////////////////////////////////////////////////////////////
int init()
{
   // òàáëèöà ñèãíàëîâ
   for(int x=0;x<1;x++)
      for(int y=0;y<19;y++)
      {
         ObjectCreate("signal"+x+y,OBJ_LABEL,0,0,0,0,0);
         ObjectSet("signal"+x+y,OBJPROP_CORNER,corner);
         ObjectSet("signal"+x+y,OBJPROP_XDISTANCE,x*scaleX+offsetX);
         ObjectSet("signal"+x+y,OBJPROP_YDISTANCE,y*scaleY+20);
         ObjectSetText("signal"+x+y,CharToStr(symbolCodeNoSignal),fontSize,"Wingdings",noSignalColor);
         //if (y<3 && x>0) {ObjectDelete("signal"+x+y);}
         
      }
    
  for(x=0;x<1;x++)
  {
      ObjectCreate("textPeriod"+x,OBJ_LABEL,0,0,0,0,0);       
      ObjectSet("textPeriod"+x,OBJPROP_CORNER,corner);
      ObjectSet("textPeriod"+x,OBJPROP_XDISTANCE,x*scaleX+offsetX);
      ObjectSet("textPeriod"+x,OBJPROP_YDISTANCE,offsetY+100);
      ObjectSetText("textPeriod"+x,"A",8,"Tahoma",textColor);
  }
  
  for(y=0;y<19;y++)
  {
      ObjectCreate("textSignal"+y,OBJ_LABEL,0,0,0,0,0);        
      ObjectSet("textSignal"+y,OBJPROP_CORNER,corner);
      ObjectSet("textSignal"+y,OBJPROP_XDISTANCE,offsetX-35);
      ObjectSet("textSignal"+y,OBJPROP_YDISTANCE,y*(scaleY)+offsetY+25);
      ObjectSetText("textSignal"+y,symbol[y],8,"Tahoma",textColor);      
  }
  return(0);
}
  
int start()
{
   for(int y=0;y<19;y++)
   {
 //emas

      if(
            (Bid > iMA(symbol[y],PERIOD_D1,10,0,MODE_EMA,0,0)) &&
            (Bid > iMA(symbol[y],PERIOD_D1,20,0,MODE_EMA,0,0)) &&
            (Bid > iMA(symbol[y],PERIOD_D1,50,0,MODE_EMA,0,0)) &&
            (Bid > iMA(symbol[y],PERIOD_D1,100,0,MODE_EMA,0,0))
         ){
         ObjectSetText("signal"+"0"+y,CharToStr(symbolCodeBuy),fontSize,"Wingdings",signalBuyColor); }
      else if
            (
            Bid < iMA(symbol[y],PERIOD_D1,10,0,MODE_EMA,0,0) &&
            Bid < iMA(symbol[y],PERIOD_D1,20,0,MODE_EMA,0,0) &&
            Bid < iMA(symbol[y],PERIOD_D1,50,0,MODE_EMA,0,0) &&
            Bid < iMA(symbol[y],PERIOD_D1,100,0,MODE_EMA,0,0)
            ) {
        ObjectSetText("signal"+"0"+y,CharToStr(symbolCodeSell),fontSize,"Wingdings",signalSellColor);  }
      else  
         ObjectSetText("signal"+"0"+y,CharToStr(symbolCodeSell),fontSize,"Wingdings",symbolCodeNoSignal);  
   }

   return(0);
}

//////////////////////////////////////////////////////////////////////
//
//  deinit()                       
//
//////////////////////////////////////////////////////////////////////
int deinit()
{
   ObjectsDeleteAll();
   return(0);
}
 

This is invalid . . .

string symbol[]

unless you mean for your array to have 0 elements.

 

Seems to work in my other programs and it's in the MQL4 tutorials i that syntax.

I tried string symbol[17] ={"USDCHF","GBPUSD","USDJPY","EURUSD","AUDUSD","USDCAD","EURGBP","EURCHF","EURJPY","GBPJPY","GBPCHF","EURCAD","EURAUD","NZDUSD","CHFJPY","AUDJPY","AUDNZD","CADJPY","XAUUSD"};

but that doesn't work either.

 
What chart do you have this on ? your Bid is from the chart that the Indicator is placed on
 
  1. string symbol[]={"USDCHF","GBPUSD"," ...

    is fine. The size of symbol[] is the number of the entries given.


  2.   Bid < iMA(symbol[y],PERIOD_D1,10,0,MODE_EMA,0,0) &&
    What is the relationship between the Bid on the current chart and the moving average of some other symbol. NONE. Is the color of the orange greater then the color of the banana? NONSENSE.