(This post will be interesting only to those who code in MQL4 or MQL5 languages.)
Drawing a rectangle in
ObjectCreate("Rectangle", OBJ_RECTANGLE, 0, Time[0], price1, Time[1], price2);
And in MQL5 it would look almost the same:
ObjectCreate(0, "Rectangle", OBJ_RECTANGLE, 0, Time[0], price1, Time[1], price2);
But filling the rectangle in MQL5 or drawing it unfilled in MQL4 wasn’t so obvious to me. The rectangles come unfilled by default in MT5 and filled by default in MT4. OBJPROP_BACK is the property that responds for that. For example, to make a rectangle unfilled in MQL4 you can call this function:
ObjectSet("Rectangle", OBJPROP_BACK, false);
And to fill the rectangle in MQL5 you would change the property to true:
ObjectSetInteger(0, "Rectangle", OBJPROP_BACK, true);
If you have any questions or comments regarding drawing of the rectangles in MQL4 or MQL5, please, use the commentary form below.


October 29th, 2010 at 11:09 am
I am having problems building the rectangle because I am unable to convert the dates correctly.It has to do with the StringToTime and TimeTo String Functions. This indicator was developed correctly on MQ4 but I cant get it to work on MQ5..
Could somebody please help here? I am including the source,and THE PROBLEM IS DEBUGGED WITH A COMMENT. thanks:
▼Reply
admin Reply:
October 29th, 2010 at 2:35 pm
1. Never (and I mean NEVER) insert the code as a commentary. WP messes up code and it’s a pain in the ass to copy it into MQL. Host the file somewhere and give a link to it in the comment.
2. You have a lot of improperly converted functions here (dozens!). Please, see other MQL5 indicators to see how the Object, i* and other functions are converted from MQL4 to MQL5.
3. Why do you have those empty #include directives in the beginning?
▼Reply
October 30th, 2010 at 12:21 pm
I apologize, sorry.. Was a typecasting problem…
▼Reply
November 28th, 2011 at 2:14 pm
Hello: How can I put “style transparent red” ,for example, in a rectangle?. Thanks.
Best Regards.
▼Reply