Indicator not showing trading signals correctly

To add comments, please log in or register
sspecia
19
sspecia  

Hello guys,

I wrote an indicator based on one of the mql5 articles.

The problem is that the signal is showing ONLY one of the conditions, but not the other one. For example I only see sell signals and the neutral as default, but no buy signals. What's the problem? My code seems written correctly.

string symbol5[]={"NZDUSD","USDCAD","USDCHF","USDJPY","GOLD","SILVER"};
int period[]={240,1440,10080};

int init(){
   for(int x=0; x<2; x++)
      for(int y=0; y<6; y++)
        {

         ObjectCreate("symbols5"+y,OBJ_LABEL,0,0,0,0,0);
         ObjectSet("symbols5"+y,OBJPROP_XDISTANCE,x*20+660);
         ObjectSet("symbols5"+y,OBJPROP_YDISTANCE,y*25+24);
         ObjectSetText("symbols5"+y,symbol5[y],8,"Tahoma",Gold);
        }
   for(int x=0; x<3; x++)
      for(int y=0; y<6; y++)
        {
         ObjectCreate("signal5"+x+y,OBJ_LABEL,0,0,0,0,0);
         ObjectSet("signal5"+x+y,OBJPROP_XDISTANCE,x*15+730);
         ObjectSet("signal5"+x+y,OBJPROP_YDISTANCE,y*25+20);
         ObjectSetText("signal5"+x+y,CharToStr(110),14,"Wingdings",Gold);
        }

   return(0);
  }

int start(){
for(int x=0;x<3;x++)
      for(int y=0; y<6; y++)
{ 
             if(iMA(symbol5[y],period[x],4,0,MODE_EMA,PRICE_CLOSE,0)>iMA(symbol5[y],period[x],10,0,MODE_EMA,PRICE_CLOSE,0)
             ObjectSetText("signal5"+x+y,CharToStr(110),14,"Wingdings",clrGreen);

             if(iMA(symbol5[y],period[x],4,0,MODE_EMA,PRICE_CLOSE,0)<iMA(symbol5[y],period[x],10,0,MODE_EMA,PRICE_CLOSE,0)
             ObjectSetText("signal5"+x+y,CharToStr(110),14,"Wingdings",clrCrimson);
             else
             ObjectSetText("signal5"+x+y,CharToStr(110),14,"Wingdings",clrBlue);     }
   return(0);
  }


Thank you in advance! :)

Mladen Rakic
114556
Mladen Rakic  
sspecia:

Hello guys,

I wrote an indicator based on one of the mql5 articles.

The problem is that the signal is showing ONLY one of the conditions, but not the other one. For example I only see sell signals and the neutral as default, but no buy signals. What's the problem? My code seems written correctly.


Thank you in advance! :)

You are missing one "else" (after the line where you have "clrGreen")
sspecia
19
sspecia  
Mladen Rakic:
You are missing one "else" (after the line where you have "clrGreen")

Perfect. Problem solved. Thank you!!
To add comments, please log in or register