Yep, I think you have to live with it, there is no concept of moving object in front or behind others . . .
THX,
ok and how about making them intransparent?
Actually this is, at least for lines Displaying of Support/Resistance Levels - MQL4 Articles
Won't help with rectangles though. You'll have to split the 'non-top' rectangle into pieces and remove the overlapped portions.
rectangleMinus( string name, double hi, double lo, datetime left, datetime right, color clr, double top_h, double top_l, datetime top_left, datetime top_right ){ if (hi > top_h){ rect(name+"1", hi, MathMax(lo, top_h), left, right, clr); hi = top_h; } if (lo < top_l){ rect(name+"2", MathMin(hi, top_l), lo, left, right, clr); lo = top_l; } if (left < top_left){ rect(name+"3", hi, lo, left, MathMinDt(right,top_left), clr); left = top_right; } rect(name+"4", hi, lo, left, right, clr); } datetime MathMaxDt(datetime a, datetime b){ if (a > b) return(a); return(b); } datetime MathMinDt(datetime a, datetime b){ if (a < b) return(a); return(b); } void rect(string name, double hi, double lo, datetime left, datetime right, clr) if (hi <= lo || left >= right) return; if (ObjectMove( name, 0, left, hi )) ObjectMove(name, 1, right, lo); else if (!ObjectCreate( name, OBJ_RECTANGLE, WINDOW_MAIN, left, hi, right, lo )) Alert("ObjectCreate(",name,",OBJ_RECTANGLE) failed: ", GetLastError() ); if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change Alert("ObjectSet(", name, ",Color) [2] failed: ", GetLastError()); }
Actually this is, at least for lines Displaying of Support/Resistance Levels - MQL4 Articles
Won't help with rectangles though. You'll have to split the 'non-top' rectangle into pieces and remove the overlapped portions.
Thank you for that code, although this would be to complicated for that issue ... i chooesed colores that mix up to the color i want it to be ...
The graphical interface of mt4 ist not very friendly ;-)
Thank you for that code, although this would be to complicated for that issue ... i chooesed colores that mix up to the color i want it to be ...
The graphical interface of mt4 ist not very friendly ;-)
It is a lot simpler, the color is a bit mask
This function gives you the required value
color mask_color(color back, color front)
{
back ^=front;
return(back);
}
The first object you give any color you like, IE, Blue, the second object you do:
ObjectSet(objname, OBJPROP_COLOR, mask_color(Blue,Green)); -> green is the desired color
Have fun ;-)
@bruceloco:
Oh thank you, that is a nice way!
Excuse me for dredging up an old thread, but this has been bugging me for a while. I've been having to use rect labels in my indis to get overlapping colours to display how I want them.
The function above works great, but only on a chart with a black background. If your chart has a background of any other colour, you need to add a third parameter to get the correct mask colour:
color MaskColour(color back, color front, color chartBackground) { back ^= front; back ^= chartBackground; return back; }
I connect to this old thread because I'm looking for a solution without using bitmap images. I do not understand how I can integrate this code in my:
color mask_color(color back,color front) { color chartBackground=(color)ChartGetInteger(0,CHART_COLOR_BACKGROUND); back^=front; back^=chartBackground; return(back); } //+------------------------------------------------------------------+ //| 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[]) { ObjectCreate("Up",OBJ_RECTANGLE,0,Time[0],High[7],Time[5],Low[5]); ObjectSet ("Up",OBJPROP_COLOR,mask_color(White,Blue)); ObjectCreate("Dw",OBJ_RECTANGLE,0,Time[0],High[7],Time[7],Low[7]); ObjectSet ("Dw",OBJPROP_COLOR,mask_color(White,Blue)); return(rates_total); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everybody,
when i set rectangle objects that overlay, their color mixes up like they are transparent. However, how can i change that, so the color stays the color i set up for the rectangle?
really annoying ...
thanks for any help!