Macd textsingal error

 

Hello friends this is checkmail and still being learning tried to code an MTF Macd indicator, me just wana add an text display to it, like the tui indicator but am getting lots of errors, think its on the final condition of buffers + 0.

Can anyone correct the code.

//+------------------------------------------------------------------+
//|                                                         TUI1.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Chartreuse
#property indicator_width1 1
#property indicator_color2 Red
#property indicator_width2 1
#property indicator_color3 Lime
#property indicator_width3 3
#property indicator_color4 Red
#property indicator_width4 3


extern int TimeFrame=0;
extern int FastEMA=7;
extern int SlowEMA=19;
extern int SignalSMA=7;
extern int applied_price=0;
extern bool ShowText=true;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   
  string label1 = "label1";  
  string label2 = "label2";
  
  
  ObjectCreate(label1,OBJ_LABEL,0,0,0);
  ObjectSet(label1,OBJPROP_CORNER,2);
  ObjectSet(label1,OBJPROP_XDISTANCE,20);
  ObjectSet(label1,OBJPROP_YDISTANCE,10);
  ObjectSetText(label1,,18,"Times New Roman",Lime);
  
  ObjectCreate(label2,OBJ_LABEL,0,0,0);
  ObjectSet(label2,OBJPROP_CORNER,2);
  ObjectSet(label2,OBJPROP_XDISTANCE,20);
  ObjectSet(label2,OBJPROP_YDISTANCE,30);
  ObjectSetText(label2,,18,"Times New Roman",Lime)
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   
   SetIndexBuffer(0,ExtMapBuffer1); 
   SetIndexBuffer(1,ExtMapBuffer2); 
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
//---- name for DataWindow and indicator subwindow label   
   switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="ChartTimeframe";
   }
   IndicatorShortName("MTF_MACD_inColor("+FastEMA+","+SlowEMA+","+SignalSMA+") ("+TimeFrameStr+")");

  }
//----
   return(0);
 int deinit()
  {
   ObjectDelete("label1");
   ObjectDelete("label2");
   
   return(0);
  }
//+------------------------------------------------------------------+
//| MTF MACD                                            |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;

 
 
   ExtMapBuffer1[i]=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,0,y); 
   ExtMapBuffer2[i]=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,1,y);
   ExtMapBuffer3[i]=ExtMapBuffer1[i]-ExtMapBuffer2[i];
   ExtMapBuffer4[i]=ExtMapBuffer1[i]-ExtMapBuffer2[i];
   
   if (ExtMapBuffer1[i] <= ExtMapBuffer2[i]) 
    ObjectSetText("label1","LONG",18,"Times New Roman",Lime);
       
     ExtMapBuffer3[i]=0;
    
  
   else ExtMapBuffer4[i]=0;
   
   ObjectSetText("label1","SHORT",18,"Times New Roman",Red);
   
    

   }  
     
//
   
  
  
   return(0);
  }
//+------------------
 

Try this....

//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Chartreuse
#property indicator_width1 1
#property indicator_color2 Red
#property indicator_width2 1
#property indicator_color3 Lime
#property indicator_width3 3
#property indicator_color4 Red
#property indicator_width4 3


extern int TimeFrame=0;
extern int FastEMA=7;
extern int SlowEMA=19;
extern int SignalSMA=7;
extern int applied_price=0;
extern bool ShowText=true;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   
  string label1 = "label1";  
  string label2 = "label2";
  
  
  ObjectCreate(label1,OBJ_LABEL,0,0,0);
  ObjectSet(label1,OBJPROP_CORNER,2);
  ObjectSet(label1,OBJPROP_XDISTANCE,20);
  ObjectSet(label1,OBJPROP_YDISTANCE,10);
  ObjectSetText(label1,"put some text in here!",18,"Times New Roman",Lime);//check this line
  
  ObjectCreate(label2,OBJ_LABEL,0,0,0);
  ObjectSet(label2,OBJPROP_CORNER,2);
  ObjectSet(label2,OBJPROP_XDISTANCE,20);
  ObjectSet(label2,OBJPROP_YDISTANCE,30);
  ObjectSetText(label2,"put some text in here!",18,"Times New Roman",Lime);//and here add text and place semi colon at end of line
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   
   SetIndexBuffer(0,ExtMapBuffer1); 
   SetIndexBuffer(1,ExtMapBuffer2); 
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
//---- name for DataWindow and indicator subwindow label   
   switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="ChartTimeframe";
   }
   IndicatorShortName("MTF_MACD_inColor("+FastEMA+","+SlowEMA+","+SignalSMA+") ("+TimeFrameStr+")");

  }
//----
   return(0);
 int deinit()
  {
   ObjectDelete("label1");
   ObjectDelete("label2");
   
   return(0);
  }
//+------------------------------------------------------------------+
//| MTF MACD                                            |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;

 
 
   ExtMapBuffer1[i]=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,0,y); 
   ExtMapBuffer2[i]=iMACD(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,applied_price,1,y);
   ExtMapBuffer3[i]=ExtMapBuffer1[i]-ExtMapBuffer2[i];
   ExtMapBuffer4[i]=ExtMapBuffer1[i]-ExtMapBuffer2[i];
 //changes below====================================================================================================================  
   if (ExtMapBuffer1[i] <= ExtMapBuffer2[i])
      { //add braces if you need to perform more than one action
         ObjectSetText("label1","LONG",18,"Times New Roman",Lime);
         ExtMapBuffer3[i]=0;
      }
   else if (ExtMapBuffer1[i] >= ExtMapBuffer2[i])//you need to test for a true or false staement so I just guessed what it might be
      {
         ObjectSetText("label1","SHORT",18,"Times New Roman",Red);
         ExtMapBuffer4[i]=0;
      }
   }  
 
  
   return(0);
  }
//+------------------

I don't know what condition you want to test in the if and else if near the end of your code, so amend as necessary.

Hope it helps