Hello,
Im trying to understand ObjectCreate function for couple of days now.
I just don't understand the 2 or more last parameters: priceN and timeN.
What are they?
At the beggining I thought that the are the coordinate of the object but then I saw the:OBJPROP_TIME,OBJPROP_YDISTANCE,OBJPROP_XSIZE,OBJPROP_YSIZE,OBJPROP_XOFFSET and I've got totally confused.
The second question is about making a rectangle on the screen.
How do I do it? how do I set the width and height of it? do I set coordinate of it? How does it work?
Thank you,
yuv.
1) Show us your code.
2) First price and time is the starting location of the rectangle, Second price and time is the end location of the rectangle.
3) There is example code on this page. https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_rectangle

- www.mql5.com
1) Show us your code.
2) First price and time is the starting location of the rectangle, Second price and time is the end location of the rectangle.
3) There is example code on this page. https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_rectangle
I read the example and I understnad that the set of Object_Rectangle and Object_Rectangle_LABEL are totally different.
I mean Object_Rectangle_LABEL is set by (x,y) point that relative to the corner of the chart and Object_Rectangle is by (price,time) point? this is where I get confused.
Here is another probelm thaat I don't understand about rectangles:
Im trying to draw a rectangle on my 0 candle in the chart, I was trying to use this code:
ObjectCreate(0,"rect",OBJ_RECTANGLE,0,rates[0].time+60,rates[0].open,rates[0].time-60,rates[0].close);
and it just doesn't work. the rectangle is moving wired when I change the "60" parameter.
Some object types are placed by entering time and price parameters where other objects are placed by entering X and Y axis parameters.
The objects that are pegged to time and price will move when the chart is scrolled where the X and Y pegged objects remain stationary as an overlay on the chart, when it is scrolled underneath.
It all depends on what you are trying to do with it.
For details on the object type and its anchor points you can look at the specifications on the object type in the documentation.
ENUM_OBJECT
ID |
|
Description |
|
Vertical Line |
|
|
Horizontal Line |
|
|
Trend Line |
|
|
Trend Line By Angle |
|
|
Cycle Lines |
|
|
Arrowed Line |
|
|
Equidistant Channel |
|
|
Standard Deviation Channel |
|
|
Linear Regression Channel |
|
|
Andrews Pitchfork |
|
|
Gann Line |
|
|
Gann Fan |
|
|
Gann Grid |
|
|
Fibonacci Retracement |
|
|
Fibonacci Time Zones |
|
|
Fibonacci Fan |
|
|
Fibonacci Arcs |
|
|
Fibonacci Channel |
|
|
Fibonacci Expansion |
|
|
Elliott Motive Wave |
|
|
Elliott Correction Wave |
|
|
Rectangle |
|
|
Triangle |
|
|
Ellipse |
|
|
Thumbs Up |
|
|
Thumbs Down |
|
|
Arrow Up |
|
|
Arrow Down |
|
|
Stop Sign |
|
|
Check Sign |
|
|
Left Price Label |
|
|
Right Price Label |
|
|
Buy Sign |
|
|
Sell Sign |
|
|
Arrow |
|
|
Text |
|
|
Label |
|
|
Button |
|
|
Chart |
|
|
Bitmap |
|
|
Bitmap Label |
|
|
Edit |
|
|
The "Event" object corresponding to an event in the economic calendar |
|
|
The "Rectangle label" object for creating and designing the custom graphical interface. |
Hi Yuv,
It's much easier to use the standard library. Here's an example that draws a rectangle around the highest high and lowest low of the last 50 bars.
//+------------------------------------------------------------------+ //| Rectangle.mq4 | //| nicholishen | //| www.reddit.com/u/nicholishenFX | //+------------------------------------------------------------------+ #property copyright "nicholishen" #property link "www.reddit.com/u/nicholishenFX" #property version "1.00" #property strict #property indicator_chart_window #include <ChartObjects\ChartObjectsShapes.mqh> //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ CChartObjectRectangle rect; int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 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[]) { //--- ArraySetAsSeries(time,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); int h = iHighest(Symbol(),Period(),MODE_HIGH,50,0); int l = iLowest(Symbol(),Period(),MODE_LOW,50,0); if(prev_calculated == 0) { rect.Create(0,"Rect",0,time[h],high[h],time[l],low[l]); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Thank you!
But I have more questions about it:
1)How can I draw a rectangle on my 0 candle? I mean a rect that is just "on" the candle.
I was trying to do it with:
ObjectCreate(0,"rect",OBJ_RECTANGLE,0,rates[0].time+60,rates[0].open,rates[0].time-60,rates[0].close);
but it didn't work...
2) What is the difference between standard library and the default functions?
Thank you!
But I have more questions about it:
1)How can I draw a rectangle on my 0 candle? I mean a rect that is just "on" the candle.
I was trying to do it with:
ObjectCreate(0,"rect",OBJ_RECTANGLE,0,rates[0].time+60,rates[0].open,rates[0].time-60,rates[0].close);
but it didn't work...
2) What is the difference between standard library and the default functions?
ObjectCreate("rec1", OBJ_LABEL, 0, 0, 0); ObjectSetText("rec1", "n", 280, "Wingdings", White); ObjectSet("rec1", OBJPROP_CORNER, CORNER_RIGHT_UPPER); ObjectSet("rec1", OBJPROP_XDISTANCE,-15); ObjectSet("rec1", OBJPROP_YDISTANCE, -75); ObjectSet("rec1", OBJPROP_BACK, true);
try using this code.
thank you

- 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,
Im trying to understand ObjectCreate function for couple of days now.
I just don't understand the 2 or more last parameters: priceN and timeN.
What are they?
At the beggining I thought that the are the coordinate of the object but then I saw the:OBJPROP_TIME,OBJPROP_YDISTANCE,OBJPROP_XSIZE,OBJPROP_YSIZE,OBJPROP_XOFFSET and I've got totally confused.
The second question is about making a rectangle on the screen.
How do I do it? how do I set the width and height of it? do I set coordinate of it? How does it work?
Thank you,
yuv.