Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("MTF SR with Angle, Square of 9, Phi, Golden Ratio, and Pi", overlay=true)
- // Define input variables
- src = input(close, title="Source")
- res = input("D", title="Resolution")
- // Define time frames
- tf1 = res == "1D" ? "D" : res == "1W" ? "W" : res == "1M" ? "M" : na
- tf2 = res == "1D" ? "W" : res == "1W" ? "M" : res == "1M" ? "3M" : na
- tf3 = res == "1D" ? "M" : res == "1W" ? "3M" : res == "1M" ? "6M" : na
- tf4 = res == "1D" ? "3M" : res == "1W" ? "6M" : res == "1M" ? "12M" : na
- // Define support and resistance levels
- sr1 = request.security(syminfo.tickerid, tf1, high[1])
- sr2 = request.security(syminfo.tickerid, tf2, high[1])
- sr3 = request.security(syminfo.tickerid, tf3, high[1])
- sr4 = request.security(syminfo.tickerid, tf4, high[1])
- sup1 = request.security(syminfo.tickerid, tf1, low[1])
- sup2 = request.security(syminfo.tickerid, tf2, low[1])
- sup3 = request.security(syminfo.tickerid, tf3, low[1])
- sup4 = request.security(syminfo.tickerid, tf4, low[1])
- // Draw support and resistance levels
- plot(sr1, color=color.yellow, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sr2, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sr3, color=color.red, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sr4, color=color.maroon, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sup1, color=color.yellow, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sup2, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sup3, color=color.red, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(sup4, color=color.maroon, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- // Calculate 45 degree angle from lowest low
- lowestLow = ta.lowest(low, 100)
- angle = math.atan((lowestLow - lowestLow[1]) / (time - time[1])) * 180 / math.acos(-1)
- plot(lowestLow, color=color.green, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- 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)
- // Calculate Square of 9 levels
- squareOf9 = 1.414 * math.sqrt(math.abs(close - close[1])) + close[1]
- plot(squareOf9, color=color.blue, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- // Calculate Phi, Golden Ratio, and Pi levels
- phi = close * 0.618 + close[1] * 0.382
- goldenRatio = close * 1.618 - close[1] * 0.618
- pi = close * 3.14 / 100
- plot(phi, color=color.purple, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(goldenRatio, color=color.fuchsia, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(pi, color=color.aqua, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- // Calculate 3, 6, 9 algo levels
- three = close * 1.03
- six = close * 1.06
- nine = close * 1.09
- plot(three, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(six, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
- plot(nine, color=color.orange, style=plot.style_line, linewidth=1, show_last=1, trackprice=true, transp=0)
Advertisement
Add Comment
Please, Sign In to add comment