Making a RECTANGLE object NON transparent

 

I have been struggling to make my rectangle object 'solid color' such that the contents are not obscured by other text on screen behind the rectangle.  Tried several variations and always appears to be transparent. The code is below.  I include a Toggle switch / button to display the rectangle or not. I use it to display key data which doesn't change much - i.e. like today's opening balance. The EA is used to display my trades ONLY - not do the trading - so I just need to verify I have the correct data. Works well and have my 'ways around' the problem but now determined to resolve - if I can

int Initialsie_Create_Rectangle()
{
   if(!ObjectCreate(ChartNumber, rectName, OBJ_RECTANGLE_LABEL, 0, 0, 0))     // Create rectangle using OBJ_RECTANGLE_LABEL (must be selected to drag)
   {
      Print("110010 ICR Error creating rectangle: ", GetLastError());
      return(INIT_FAILED);
   }
   
   // Set rectangle properties
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_XDISTANCE, RectX);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_YDISTANCE, RectY);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_XSIZE, RectWidth);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_YSIZE, RectHeight);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_CORNER, CORNER_LEFT_UPPER);    //ObjectSetInteger  (ChartNumber, rectName, OBJPROP_BORDER_TYPE, BORDER_RAISED);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_BORDER_TYPE, BORDER_FLAT);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_WIDTH, 3);                     //ObjectSetInteger(0, objectName, OBJPROP_WIDTH, borderWidth);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_COLOR, clrPowderBlue);         // This sets the border color
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_BGCOLOR, clrLightCyan);        // Background stays same
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_SELECTABLE, true);             // Must be selectable to drag
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_SELECTED, true);               // Start selected so it's ready to drag
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_FILL, true);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_BACK, false);   // Foreground
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_BGCOLOR, clrLightCyan);
   ObjectSetInteger  (ChartNumber, rectName, OBJPROP_ZORDER, 1);    // Low Z-order but not 0
   //DiagnosticRectangleProperties("200 in Initialsie_Create_Rectangle");
   return(INIT_SUCCEEDED);
}

Any help/ suggestions appreciated

 
Peter Wlliams:

I have been struggling to make my rectangle object 'solid color' such that the contents are not obscured by other text on screen behind the rectangle.  Tried several variations and always appears to be transparent. The code is below.  I include a Toggle switch / button to display the rectangle or not. I use it to display key data which doesn't change much - i.e. like today's opening balance. The EA is used to display my trades ONLY - not do the trading - so I just need to verify I have the correct data. Works well and have my 'ways around' the problem but now determined to resolve - if I can

Any help/ suggestions appreciated

Read this short thread:

Avoid chart objects visible in the foreground
Avoid chart objects visible in the foreground
  • 2025.01.17
  • www.mql5.com
As from the title, how can I prevent chart objects from being seen in foreground in MQL5...
 
Ryan L Johnson #:

Read this short thread:

Thanks - will do. 

Apologies about the other post - got in a mess 

 
Peter Wlliams #:

Thanks - will do. 

Apologies about the other post - got in a mess 

No worries. I'm not a Moderator so I just put a note there requesting cleanup.