Draw Rectangles code converted from mql4 to mql5 not working

To add comments, please log in or register
Jackery
76
Jackery  

I converted the following code that I was using in mql4 to mql5 but it doesn't show the rectangles on the chart. The mql4 code is working perfectly. I get a warning " possible loss of data due to type conversion"  on the set integer/double lines for OBJPROP_TIME and OBJPROP_PRICE.


bool drawBearPinbarRectangle(int candleInt,const double top,const double bottom, int cDuration, color rectColor)
{ 
     bool checkBarCount = true;
         
    const datetime starts = iTime(_Symbol,_Period,candleInt);
    
    const datetime ends = starts - cDuration*_Period*60;
    const string name=prefix+"_"+"_"+TimeToString(starts)+TimeToString(ends);
    if(!ObjectCreate(0,name,OBJ_RECTANGLE,0,cDuration,0,0,0))
    {
        return false;
    }
    ObjectSetInteger(0,name,OBJPROP_TIME,starts, 0);
    ObjectSetInteger(0,name,OBJPROP_TIME,ends, 1);
    ObjectSetDouble(0,name,OBJPROP_PRICE,top, 0);
    ObjectSetDouble(0,name,OBJPROP_PRICE,bottom, 1);
    
    ObjectSetInteger(0,name,OBJPROP_COLOR, rectColor);
    
   ObjectSetInteger(0,name,OBJPROP_STYLE, STYLE_DASHDOT);

   ObjectSetInteger(0,name,OBJPROP_WIDTH,1);

   ObjectSetInteger(0,name,OBJPROP_FILL, false);
     
    return true;
}
Ernst Van Der Merwe
6486
Ernst Van Der Merwe  
    ObjectSetInteger(0,name,OBJPROP_TIME,0,starts);
    ObjectSetInteger(0,name,OBJPROP_TIME,1,ends);
    ObjectSetDouble(0,name,OBJPROP_PRICE,0,top);
    ObjectSetDouble(0,name,OBJPROP_PRICE,1,bottom);
William Roeder
19863
William Roeder  
Perhaps you should read the manual.
Your code
Documentation
ObjectSetDouble(
   0,
   name,
   OBJPROP_PRICE,
   top,          
   0             
);
bool  ObjectSetDouble(
   long                            chart_id,          // chart identifier
   string                          name,              // object name
   ENUM_OBJECT_PROPERTY_DOUBLE     prop_id,           // property
   int                             prop_modifier,     // modifier
   double                          prop_value         // value
   );
To add comments, please log in or register