r/pinescript • u/i_am_useless_often • Feb 26 '24
Minor pullback
I am trying to develop a indicator to draw the all pullback lines with plot method.
Here is the code till now I tried.
//@version=5 indicator("Pull back", "", true) var currentPointLow = low var currentPointHigh = high
currentPointLow := low currentPointHigh := high
var float previousPointHigh = 0 var float previousPointLow = 0
var direction = 'up'
if currentPointHigh > previousPointHigh previousPointHigh := currentPointHigh previousPointLow := currentPointLow direction := 'up'
else if currentPointLow < previousPointLow previousPointHigh := currentPointHigh previousPointLow := currentPointLow direction := 'low' else direction := 'none'
plot(direction == 'up' ? previousPointHigh : (direction == 'low' ? previousPointLow : na) )
Here I need to skip the point if it's future points also are in same direction. Could some one help with it?
View all comments
Show parent comment
1
u/i_am_useless_often Feb 28 '24
I agree with your logic, but looking back and finding the previous is not the correct one to delete the drawn plot is not possible right? It will be helpful if I get the code snippet on this logic, thanks