RECTANGLE IN CHART

 

I used the script below and does not appear on the chart, have some error?

I used OBJPROP_BACK, along with a ObjectSetText but could not put a color in the background text,

I found that with the Rectangle is possible, but also could not.if

(ObjectFind("RECT") != 0){
ObjectCreate("RECT", OBJ_RECTANGLE, 0,5,92,10,103);
ObjectSet("RECT",OBJPROP_BACK,true);
ObjectSet("RECT", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("RECT", OBJPROP_COLOR, Gray);}

if(ObjectFind("RFT") != 0){
ObjectCreate("RFT", OBJ_LABEL, 0, 0, 0);
ObjectSetText("RFT", Text1, 8, "Arial", Aqua);
ObjectSet("RFT", OBJPROP_COLOR, Aqua);

ObjectSet("RECT",OBJPROP_BACK,true);
ObjectSet("RFT", OBJPROP_XDISTANCE, 5);
ObjectSet("RFT", OBJPROP_YDISTANCE, 93);}

 

RFT, as a start point, consider to study MQL4 Book here to understand about actual parameter values passed into ObjectCreate()

Hint - OBJ_RECTANGLE uses two pairs of Time,Price coordinates. (Time=X axis, Price=Y axis)

and "5,92,10,103" appear not to fit the bill...





 
fbj wrote >>

RFT, as a start point, consider to study MQL4 Book here to understand about actual parameter values passed into ObjectCreate()

Hint - OBJ_RECTANGLE uses two pairs of Time,Price coordinates. (Time=X axis, Price=Y axis)

and "5,92,10,103" appear not to fit the bill...

I wanted to plot the chart, a rectangle, where the price and time as I do that?

I had seen that uses time and price, but I thought I could use the X and Y directly!

In fact I put a background in text, but could not, so I'm trying the rectangle.

Is there a way to put a background in the text, without rectangle?

 

afaik, are two different plotting items and a background color attribute to text object is not possible.

Can use ObjectSet(name,...) to change/set eg, text or rect color. Works on the object with name.

So, is for you to draw say, the rectangle followed by text draw.


If not want to use Time/Price could use two calls to ObjectSet(name, OBJPROP_XDISTANCE,pixel value) and same for OBJPROP_YDISTANCE in second call after creating text or rectangle

In this case, you could create the object with the two Time/Price pairs set to zero. Then, make two calls to ObjectSet()...

I tried it and it worked. Only issue had was could not see it! Went into Objects popup (Ctrl-B) and having highlighted RECT entry, clicked show btn and there it was.

Must need to set further object props and maybe even WindowRedraw().


So, guess could use pixels in the end.


you're gonna have to just play around and try out various combinations to suit your needs.


good luck

 
fbj wrote >>

afaik, are two different plotting items and a background color attribute to text object is not possible.

Can use ObjectSet(name,...) to change/set eg, text or rect color. Works on the object with name.

So, is for you to draw say, the rectangle followed by text draw.

If not want to use Time/Price could use two calls to ObjectSet(name, OBJPROP_XDISTANCE,pixel value) and same for OBJPROP_YDISTANCE in second call after creating text or rectangle

In this case, you could create the object with the two Time/Price pairs set to zero. Then, make two calls to ObjectSet()...

I tried it and it worked. Only issue had was could not see it! Went into Objects popup (Ctrl-B) and having highlighted RECT entry, clicked show btn and there it was.

Must need to set further object props and maybe even WindowRedraw().

So, guess could use pixels in the end.

you're gonna have to just play around and try out various combinations to suit your needs.

good luck

Can you help me with an example script, I understood what you wanted to say but have difficulty in the script for not knowing much about programming MQL4.

I tried but nothing happened. Even going into List of Objects.

if (ObjectFind("RECT") != 0){
ObjectCreate("RECT", OBJ_RECTANGLE, 0,0,0,0,0);
ObjectSet("RECT",OBJPROP_BACK,true);
ObjectSet("RECT", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("RECT", OBJPROP_COLOR, Gray);
ObjectSet("RFT", OBJPROP_XDISTANCE, 5);
ObjectSet("RFT", OBJPROP_YDISTANCE, 92);}

 

I managed to make the rectangle, but it is not stopped, he leaves the chart as the increase of bars. How to solve this?

if (ObjectFind("RECT") != 0){
ObjectCreate("RECT", OBJ_RECTANGLE, 0, (Time[96]),Low[4],(Time[58]),High[1]);
ObjectSet("RECT",OBJPROP_COLOR, DarkGray);}

Reason: