Download MetaTrader 5

how to draw "Quadrilateral" or "Pentagon" or "Heptagon" OR " Polygon " ?

To add comments, please log in or register
Mehrdad Shiri
4513
Mehrdad Shiri  

hi;

with below code : draw triangle.

void CreateTRIANGLE(int     chart_id,  // Chart identifier
                  string   name,      // object name
                       // Chart window
                  datetime  time1,        // First time coordinate
                  double    price1,       // First price coordinate
                  datetime  time2,        // Second time coordinate
                  double    price2,       // Second price coordinate
                  datetime  time3,        // Third time coordinate
                  double    price3,        // Third price coordinate
                  color    Color=clrRosyBrown,     // line color
                  int      style=STYLE_SOLID,     // line style
                  int      width=1     // line width
                  )  
                   {
   ObjectCreate(chart_id,name, OBJ_TRIANGLE, 0, 0,0);
 
   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);
   ObjectSetInteger(chart_id,name,OBJPROP_STYLE,style);
   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,width);
   ObjectSetInteger(chart_id,name,OBJPROP_BACK,true);
   
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,time1);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,1,time2);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,2,time3);
   ObjectSetInteger(chart_id,name,OBJPROP_FILL,1);
   ObjectSetDouble(chart_id,name,OBJPROP_PRICE,price1);
   ObjectSetDouble(chart_id,name,OBJPROP_PRICE,1,price2);
   ObjectSetDouble(chart_id,name,OBJPROP_PRICE,2,price3);

} 

if i want to draw : "Quadrilateral" or "Pentagon" or "Heptagon" OR " Polygon "

like below:

void CreateQuadrilateral_FILL(int     chart_id,  // Chart identifier
                  string   name,      // object name
                       // Chart window
                  datetime  time1,        // First time coordinate
                  double    price1,       // First price coordinate
                  datetime  time2,        // Second time coordinate
                  double    price2,       // Second price coordinate
                  datetime  time3,        // Third time coordinate
                  double    price3,        // Third price coordinate
                  datetime  time4,        // First time coordinate
                  double    price4,       // First price coordinate
                  color    Color_Quadrilateral_FILL=Gray,//RosyBrown //MistyRose //RosyBrown //clrGreenYellow //line color
                  int      style_Quadrilateral_FILL=STYLE_SOLID,     // line style
                  int      width_Quadrilateral_FILL=1     // line width
                  )  
                   {
  ObjectCreate(chart_id,name, OBJ_???? , 0, 0,0);
 
   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name,OBJPROP_STYLE,style_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,width_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name,OBJPROP_BACK,true);
   
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,time1);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,1,time2);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,2,time3);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,3,time4);
   ObjectSetInteger(chart_id,name,OBJPROP_FILL,1);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,price1);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,1,price2);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,2,price3);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,3,price4);
}

what object i must use? 

OBJ_????

or what is the solution ?

Simon Gniadkowski
Moderator
18003
Simon Gniadkowski  
TIMisthebest:

hi;

with below code : draw triangle.

if i want to draw : "Quadrilateral" or "Pentagon" or "Heptagon" OR " Polygon "

like below:

what object i must use? 

or what is the solution ?

Why do you think it is possible ?  how do you do this manually on an MT5 terminal ?
Mehrdad Shiri
4513
Mehrdad Shiri  
RaptorUK:
Why do you think it is possible ?  how do you do this manually on an MT5 terminal ?

you right,

but i doesn't understand meaning of : https://www.mql5.com/en/docs/objects/objectcreate

bool  ObjectCreate(
   long         chart_id,      // chart identifier
   string       name,          // object name
   ENUM_OBJECT  type,          // object type
   sub_window   nwin,          // window index
   datetime     time1,         // time of the first anchor point
   double       price1,        // price of the first anchor point
   ...
   datetime     timeN=0,       // time of the N-th anchor point
   double       priceN=0,      // price of the N-th anchor point
   ...
   datetime     time30=0,      // time of the 30th anchor point
   double       price30=0      // price of the 30th anchor point
   );

and i also need it to draw harmonic pattern's ( not by 2 or 3 triangle )   .......  if it possible ?!

Documentation on MQL5: Object Functions / ObjectCreate
Documentation on MQL5: Object Functions / ObjectCreate
  • www.mql5.com
Object Functions / ObjectCreate - Documentation on MQL5
Simon Gniadkowski
Moderator
18003
Simon Gniadkowski  
TIMisthebest:

you right,

but i doesn't understand meaning of : https://www.mql5.com/en/docs/objects/objectcreate

and i also need it to draw harmonic pattern's ( not by 2 or 3 triangle )   .......  if it possible ?!

Regarding this . . . .

   datetime     time30=0,      // time of the 30th anchor point
   double       price30=0      // price of the 30th anchor point

  . . .  I see that OBJ_ELLIOTWAVE5  uses 5 anchor points,  I assume that when the function was created it was done with future expansion in mind,  hence the possibility of up to 30 anchor point values (datetime & price).

 

I'm not exactly sure what you mean by harmonic patterns,  sorry. 

 

Mehrdad Shiri
4513
Mehrdad Shiri  

RaptorUK:

I'm not exactly sure what you mean by harmonic patterns,  sorry. 

i draw in an indicator harmonic patterns ( AB=CD,Reciprocal_AB=CD,GARTLEY,BUTTERFLY,BAT,SHARK,CRAB,....................


this are drawn by triangular ,

because of some reason, i want to draw them Integrated,( for each of them) ?!

thank you for answer.

Kourosh Davallou
41785
Kourosh Davallou  

Hi mehrdad

I think you can divide the number of triangles.


Kourosh Davallou
41785
Kourosh Davallou  
void CreateQuadrilateral_FILL(int     chart_id,  // Chart identifier
                  string   name,      // object name
                       // Chart window
                  datetime  time1,        // First time coordinate
                  double    price1,       // First price coordinate
                  datetime  time2,        // Second time coordinate
                  double    price2,       // Second price coordinate
                  datetime  time3,        // Third time coordinate
                  double    price3,        // Third price coordinate
                  datetime  time4,        // First time coordinate
                  double    price4,       // First price coordinate
                  color    Color_Quadrilateral_FILL=Gray,//RosyBrown //MistyRose //RosyBrown //clrGreenYellow //line color
                  int      style_Quadrilateral_FILL=STYLE_SOLID,     // line style
                  int      width_Quadrilateral_FILL=1     // line width
                  ) 
                   {
  ObjectCreate(chart_id,name, OBJ_TRIANGLE, 0, 0,0);
 
   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name,OBJPROP_STYLE,style_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,0);
   ObjectSetInteger(chart_id,name,OBJPROP_BACK,true);
  
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,time1);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,1,time2);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,2,time3);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,3,time4);
   ObjectSetInteger(chart_id,name,OBJPROP_FILL,1);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,price1);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,1,price2);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,2,price3);
    ObjectSetDouble(chart_id,name,OBJPROP_PRICE,3,price4);
   
    ObjectCreate(chart_id,name+1, OBJ_TRIANGLE, 0, 0,0);
 
   ObjectSetInteger(chart_id,name+1,OBJPROP_COLOR,Color_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name+1,OBJPROP_STYLE,style_Quadrilateral_FILL);
   ObjectSetInteger(chart_id,name+1,OBJPROP_WIDTH,0);
   ObjectSetInteger(chart_id,name+1,OBJPROP_BACK,true);
  
   ObjectSetInteger(chart_id,name+1,OBJPROP_TIME,time4);
   ObjectSetInteger(chart_id,name+1,OBJPROP_TIME,1,time2);
   ObjectSetInteger(chart_id,name+1,OBJPROP_TIME,2,time3);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME,3,time4);
      ObjectSetInteger(chart_id,name+1,OBJPROP_FILL,1);
    ObjectSetDouble(chart_id,name+1,OBJPROP_PRICE,price4);
    ObjectSetDouble(chart_id,name+1,OBJPROP_PRICE,1,price2);
    ObjectSetDouble(chart_id,name+1,OBJPROP_PRICE,2,price3);
  
}

Mehrdad Shiri
4513
Mehrdad Shiri  
kourosh1347:
Hi mehrdad

I think you can divide the number of triangles.

hi:

thank you, my friend.

Simon Gniadkowski
Moderator
18003
Simon Gniadkowski  
kourosh1347:


<CODE REMOVED>

Please edit your post . . . 

 Thank you :-)


To add comments, please log in or register