xmd79

45 Degree Angle from Last Low/High

May 29th, 2023
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. //@version=5
  2. indicator('45 Degree Angle from Last Low/High', overlay=true)
  3.  
  4. // Determine whether the last point was a high or low
  5. lastHigh = ta.highest(high, 500)
  6. lastLow = ta.lowest(low, 500)
  7. lastPoint = bar_index - nz(math.max(lastLow, lastHigh))
  8.  
  9. // Calculate the slope of the line
  10. slope = 1
  11.  
  12. // Calculate the y-intercept of the line
  13. yIntercept = lastHigh - slope * (bar_index - lastPoint)
  14.  
  15. // Plot the line
  16. plot(slope * (bar_index - lastPoint) + yIntercept, color=color.new(color.green, 0))
Advertisement
Add Comment
Please, Sign In to add comment