How do I make "draggable" lines?

 

When I add a horizontal line from the drawing tools menu, I can drag that line.

When I add a horizontal line from an EA, I can't drag it.

How are they different? Why can I drag one but not the other?

 
Check the following properties ...

ENUM_OBJECT_PROPERTY_INTEGER

Identifier

Description

Property Type

OBJPROP_HIDDEN

Prohibit showing of the name of a graphical object in the list of objects from the terminal menu "Charts" - "Objects" - "List of objects". The true value allows to hide an object from the list. By default, true is set to the objects that display calendar events, trading history and to the objects created from MQL4 programs. To see such graphical objects and access their properties, click on the "All" button in the "List of objects" window.

bool

OBJPROP_SELECTED

Object is selected

bool

Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
 

My lines are never "hidden," but yes, OBJPROP_SELECTED fixes the problem.

Thank you.

 
whoowl #: My lines are never "hidden," but yes, OBJPROP_SELECTED fixes the problem.Thank you.

No, don't do that! Leave the "Selected" disabled. Instead when you wish to drag an object on the chart, just double click it and then it will be selected.

When you have finished dragging it, then double click it again to unselect. That way you can't accidentality drag objects when your intent is to simply scroll the chart.