Problem with Object

Back to topics list To post a new topic, please log in or register
avatar
63
omissamf 2016.07.24 19:18
 

Hi guys, I have a problem with this code and I can not understand why it does not work. It gives no errors, but only returns the value of TF 5 minutes while the 15 minutes does not appear. Thank you all, Massimo.

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

// ————————————————————TF 5 minuti———————————————————————————
        
        
             if(iOpen(NULL,PERIOD_M5,1)>iClose(NULL,PERIOD_M5,1)
             )
             {
             ObjectCreate(0,"text",OBJ_LABEL,0,0,0,0);
             ObjectSetInteger(0,"text",OBJPROP_XDISTANCE,300);
             ObjectSetInteger(0,"text",OBJPROP_YDISTANCE,10);
              ObjectSetText("text",(Symbol()+" M"+ PERIOD_M5),10,"Tahoma",clrRed); 
             }
             else 
             {
           ObjectSetText("text",Symbol()+" M"+ PERIOD_M5+" |  ",10,"Tahoma",clrGreen);
            }
           
            // ————————————————————TF 15 minuti———————————————————————————
        
        
             if(iOpen(NULL,PERIOD_M15,1)>iClose(NULL,PERIOD_M15,1)
             )
             {
             ObjectCreate(1,"text1",OBJ_LABEL,0,0,0,0);
             ObjectSetInteger(1,"text1",OBJPROP_XDISTANCE,400);
             ObjectSetInteger(1,"text1",OBJPROP_YDISTANCE,10);
              ObjectSetText("text1",(Symbol()+" M"+ PERIOD_M15),10,"Tahoma",clrRed); 
             }
             else 
             {
           ObjectSetText("text",Symbol()+" M"+ PERIOD_M5+" |  ",10,"Tahoma",clrGreen);
            }
            
          
   return(rates_total);
  }
//+------------------------------------------------------------------+
avatar
108
eddie 2016.07.24 20:46 #
 

Check your parameters chart_id and name.

  chart_id = 1 will not work

  you mix text and text1.

avatar
63
omissamf 2016.07.25 00:42 #
 
Heddie, here I am again. I understand your suggestion. I corrected and now works. Thank you for your kindness, greetings, Massimo.
Back to topics list  

To add comments, please log in or register