Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Support and Resistance with Targets", overlay=true)
- // Parameters
- length1 = input.int(147, minval=1, title="Support/Resistance Length 1")
- length2 = input.int(258, minval=1, title="Support/Resistance Length 2")
- length3 = input.int(369, minval=1, title="Support/Resistance Length 3")
- // Calculate support and resistance for different lengths
- var float support1 = na
- var float resistance1 = na
- var float support2 = na
- var float resistance2 = na
- var float support3 = na
- var float resistance3 = na
- support1 := ta.lowest(low, length1)
- resistance1 := ta.highest(high, length1)
- support2 := ta.lowest(low, length2)
- resistance2 := ta.highest(high, length2)
- support3 := ta.lowest(low, length3)
- resistance3 := ta.highest(high, length3)
- // Plot support and resistance as lines
- plot(support1, color=color.green, title="Support 1", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
- plot(resistance1, color=color.red, title="Resistance 1", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
- plot(support2, color=color.green, title="Support 2", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
- plot(resistance2, color=color.red, title="Resistance 2", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
- plot(support3, color=color.green, title="Support 3", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
- plot(resistance3, color=color.red, title="Resistance 3", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
- // Calculate targets
- smallTarget = (resistance1 - support1) * 0.382 + support1
- mediumTarget = (resistance2 - support2) * 0.618 + support2
- largeTarget = (resistance3 - support3) * 1 + support3
- // Plot targets
- plot(smallTarget, color=color.blue, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0, title="Small Target")
- plot(mediumTarget, color=color.orange, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0, title="Medium Target")
- plot(largeTarget, color=color.purple, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0, title="Large Target")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement