Create Study on Mouse Click

Is it possible to create a Study (horizontal line) with a Study ID together with just a middle mouse button click?

I have the following code to start, but it's not a Study and the plot disappears right away.

if( GetCursorMouseButtons() & 4 ) 
Plot(GetCursorYPosition(), "Target", colorAqua);

The purpose is to be able to quickly create one line at a time with a mouse click and to reference it in AFL for Analysis to check if the price crosses it.

You can't create 'manual' studies (the ones that are created from UI manually) with AFL, but you can use Plot as you did and store the coordinate in Static variable and it will stay.

1 Like