Advertisement
xmd79

Support and Resistance with Targets

Jun 3rd, 2024 (edited)
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. //@version=5
  2. indicator("Support and Resistance with Targets", overlay=true)
  3.  
  4. // Parameters
  5. length1 = input.int(147, minval=1, title="Support/Resistance Length 1")
  6. length2 = input.int(258, minval=1, title="Support/Resistance Length 2")
  7. length3 = input.int(369, minval=1, title="Support/Resistance Length 3")
  8.  
  9. // Calculate support and resistance for different lengths
  10. var float support1 = na
  11. var float resistance1 = na
  12. var float support2 = na
  13. var float resistance2 = na
  14. var float support3 = na
  15. var float resistance3 = na
  16.  
  17. support1 := ta.lowest(low, length1)
  18. resistance1 := ta.highest(high, length1)
  19.  
  20. support2 := ta.lowest(low, length2)
  21. resistance2 := ta.highest(high, length2)
  22.  
  23. support3 := ta.lowest(low, length3)
  24. resistance3 := ta.highest(high, length3)
  25.  
  26. // Plot support and resistance as lines
  27. plot(support1, color=color.green, title="Support 1", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  28. plot(resistance1, color=color.red, title="Resistance 1", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  29.  
  30. plot(support2, color=color.green, title="Support 2", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  31. plot(resistance2, color=color.red, title="Resistance 2", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  32.  
  33. plot(support3, color=color.green, title="Support 3", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  34. plot(resistance3, color=color.red, title="Resistance 3", style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  35.  
  36. // Calculate targets
  37. smallTarget = (resistance1 - support1) * 0.382 + support1
  38. mediumTarget = (resistance2 - support2) * 0.618 + support2
  39. largeTarget = (resistance3 - support3) * 1 + support3
  40.  
  41. // Plot targets
  42. plot(smallTarget, color=color.blue, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0, title="Small Target")
  43. plot(mediumTarget, color=color.orange, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0, title="Medium Target")
  44. plot(largeTarget, color=color.purple, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0, title="Large Target")
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement