Is there a way to reference a manually drawn trend line in pinescript?

Viewed 30

I am looking to create an alert when there is a cross between the close price and a manually drawn trendline. This can be done using alerts in tradingview but the alert fires every time the condition is met at bar close. I want the alert to fire once only at bar close and then pause until I manually reset. I don't want the alert to fire at an intra bar price.

My alternative is to code this to occur but I cannot seem to reference the manually drawn trendline. My code would look something like this:

ta.crossunder(close, Trend Line Short)

Where "Trend Line Short" refers to my manually drawn trendline.Is there anyway for pinescript to reference this trendline?

1 Answers

User drawn objects are not accessible via pinescript.

You have to draw your lines programmatically with the line.new function and then get the price value at a specific bar with the line.get_y2() function. Then you can set your alerts.

Otherwise, it is not possible.

Related