Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study("45 Degree Angle from Last Low/High", overlay=true)
- // Determine whether the last point was a high or low
- lastHigh = highest(high, 500)
- lastLow = lowest(low, 500)
- lastPoint = bar_index - nz(max(lastLow, lastHigh))
- // Calculate the slope of the line
- slope = 1
- // Calculate the y-intercept of the line
- yIntercept = lastHigh - slope * (bar_index - lastPoint)
- // Calculate the 45-degree angle line using the formula y = x
- angleLine = bar_index - lastPoint
- // Plot the angle line
- plot(angleLine + yIntercept,
- color=color.new(color.green, 0),
- style=plot.style_line,
- show_last=1,
- linewidth=1,
- trackprice=true,
- transp=0)
- // Extend the angle line into the future
- futureAngleLine = angleLine + (bar_index - lastPoint) * 2 // Change the multiplier to adjust the length of the projected line
- // Plot the future angle line
- plot(futureAngleLine + yIntercept,
- color=color.new(color.yellow, 0),
- style=plot.style_line,
- show_last=1,
- linewidth=2,
- trackprice=true,
- transp=0)
Advertisement
Add Comment
Please, Sign In to add comment