ObjectCreate without anchor point

 

Hi Friends,

I've created a custom button and my intent is that when I press it, it creates a horizontal line with preset parameters. May I ask if it is possible to create OBJ_HLINE without any price anchor point so that I can place it on a chart wherever I wish, just like I would with the draw horizontal line button?

Thank you for your help!

M

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
When a graphical object is created using the ObjectCreate() function, it's necessary to specify the type of object being created, which can be one of the values of the ENUM_OBJECT enumeration. Further specifications of object properties are possible using functions for working with graphical objects.
 
Yes set OBJPROP_SELECTED to true.
 
Marco vd Heijden:
Yes set OBJPROP_SELECTED to true.

Thanks Marco! That works great! Do you think is there a way to have it selected and not to have it anchored at the moment of creation? I have the code like this and it creates the line on the Ask.


if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Object3")

      {

          ObjectCreate("StopPrice",OBJ_HLINE,0,0,Ask);

          ObjectSet("StopPrice",OBJPROP_SELECTED,True);  

         }

 
Mtype: I've created a custom button and my intent is that when I press it, it creates a horizontal line with preset parameters. May I ask if it is possible to create OBJ_HLINE without any price anchor point so that I can place it on a chart wherever I wish, just like I would with the draw horizontal line button?

You can, but unless the price you create it with is on the chart, you won't be able to see it, and won't be able to move it.

Instead, just create it in the middle of the chart.
          Chart Price Max/Min - MQL4 programming forum

 
William Roeder:

You can, but unless the price you create it with is on the chart, you won't be able to see it, and won't be able to move it.

Instead, just create it in the middle of the chart.
          Chart Price Max/Min - MQL4 programming forum

Got it! Thanks William for the quick reply!
Reason: