Drag Horizontal Line and Store Price (Script)?

 

When I drop script onto chart, I want a horizontal line to be created and the flexibility to move this line where I want with the view of returning the price once I lock it in and the script continuing with the rest of the code.

 I know how to code so i am not asking for someone to do this for me, just merely asking if someone could be kind enough to point me in the right direction that's all :) (or even examples of where people have done something similar).

 Many thanks in advance! 

 
winterz:

When I drop script onto chart, I want a horizontal line to be created and the flexibility to move this line where I want with the view of returning the price once I lock it in and the script continuing with the rest of the code.

 I know how to code so i am not asking for someone to do this for me, just merely asking if someone could be kind enough to point me in the right direction that's all :) (or even examples of where people have done something similar).

 Many thanks in advance! 

You could use a message box (https://docs.mql4.com/common/messagebox) after placing the horizontal line in order to pause the script and then you would have time to move the line where you want. Once you have it on the right place, simply click "OK" and the script will continue.

 Regards. 

 

When the script creates the line set OBJPROP_SELECTED to true

Use a while loop to check if OBJPROP_SELECTED is false, if it is, break from the loop and continue

That way you will be able to move the line and the code following the create will only be executed when you double click on the object to de-select it. 

 
Thanks for both of your replies! Very helpful. I will have a play now and get back to you on my findings :)
Reason: