xmd79

MTF SR with Angle, Square of 9, Phi, Golden Ratio, and Pi updated

May 23rd, 2023
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. //@version=5
  2. indicator("MTF SR with Angle, Square of 9, Phi, Golden Ratio, and Pi", overlay=true)
  3.  
  4. // Define input variables
  5. src = input(close, title="Source")
  6. res = input("D", title="Resolution")
  7.  
  8. // Define time frames
  9. tf1 = res == "1D" ? "D" : res == "1W" ? "W" : res == "1M" ? "M" : na
  10. tf2 = res == "1D" ? "W" : res == "1W" ? "M" : res == "1M" ? "3M" : na
  11. tf3 = res == "1D" ? "M" : res == "1W" ? "3M" : res == "1M" ? "6M" : na
  12. tf4 = res == "1D" ? "3M" : res == "1W" ? "6M" : res == "1M" ? "12M" : na
  13.  
  14. // Define support and resistance levels
  15. sr1 = request.security(syminfo.tickerid, tf1, high[1])
  16. sr2 = request.security(syminfo.tickerid, tf2, high[1])
  17. sr3 = request.security(syminfo.tickerid, tf3, high[1])
  18. sr4 = request.security(syminfo.tickerid, tf4, high[1])
  19. sup1 = request.security(syminfo.tickerid, tf1, low[1])
  20. sup2 = request.security(syminfo.tickerid, tf2, low[1])
  21. sup3 = request.security(syminfo.tickerid, tf3, low[1])
  22. sup4 = request.security(syminfo.tickerid, tf4, low[1])
  23.  
  24. // Draw support and resistance levels
  25. plot(sr1, color=color.yellow, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  26. plot(sr2, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  27. plot(sr3, color=color.red, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  28. plot(sr4, color=color.maroon, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  29. plot(sup1, color=color.yellow, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  30. plot(sup2, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  31. plot(sup3, color=color.red, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  32. plot(sup4, color=color.maroon, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  33.  
  34. // Calculate 45 degree angle from lowest low
  35. lowestLow = ta.lowest(low, 100)
  36. angle = math.atan((lowestLow - lowestLow[1]) / (time - time[1])) * 180 / math.acos(-1)
  37.  
  38. plot(lowestLow, color=color.green, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  39. plot(lowestLow + (ta.highest(high, 100) - lowestLow) * math.tan(angle), color=color.green, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  40.  
  41. // Calculate Square of 9 levels
  42. squareOf9 = 1.414 * math.sqrt(math.abs(close - close[1])) + close[1]
  43. plot(squareOf9, color=color.blue, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  44.  
  45. // Calculate Phi, Golden Ratio, and Pi levels
  46. phi = close * 0.618 + close[1] * 0.382
  47. goldenRatio = close * 1.618 - close[1] * 0.618
  48. pi = close * 3.14 / 100
  49.  
  50. plot(phi, color=color.purple, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  51. plot(goldenRatio, color=color.fuchsia, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  52. plot(pi, color=color.aqua, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  53.  
  54. // Calculate 3, 6, 9 algo levels
  55. three = close * 1.03
  56. six = close * 1.06
  57. nine = close * 1.09
  58.  
  59. plot(three, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  60. plot(six, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  61. plot(nine, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
  62.  
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment