Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study(title='TFs', overlay=true)
- //all
- alltfs = input(false, title='SHOW ALL')
- //titles
- tf1String = '3H'
- tf2String = '4H'
- tf3String = '12H'
- tf4String = '1D'
- tf5String = '2D'
- tf6String = '3D'
- tf7String = 'W'
- ema1String = '21 EMA '
- ema2String = '50 EMA '
- ema3String = '100 EMA '
- ema4String = '200 EMA '
- ema5String = '377 EMA '
- ema6String = '886 EMA '
- sma1String = '200 SMA '
- //show
- showLast = 1
- //colors
- color1EMA = color(yellow, 0)
- color2EMA = color(lime, 0)
- color3EMA = color(aqua, 0)
- color4EMA = color(fuchsia, 0)
- color5EMA = color(maroon, 0)
- color6EMA = color(white, 0)
- color1SMA = color(red, 0)
- //mas
- lengthEMA1 = input(defval=21, title=ema1String)
- lengthEMA2 = input(defval=50, title=ema2String)
- lengthEMA3 = input(defval=100, title=ema3String)
- lengthEMA4 = input(defval=200, title=ema4String)
- lengthEMA5 = input(defval=377, title=ema5String)
- lengthEMA6 = input(defval=886, title=ema6String)
- lengthSMA1 = input(defval=200, title=sma1String)
- //timeframes
- tf1 = input(defval=180, title=tf1String)
- tf2 = input(defval=240, title=tf2String)
- tf3 = input(defval=720, title=tf3String)
- tf4 = input(defval=1440, title=tf4String)
- tf5 = input(defval=2880, title=tf5String)
- tf6 = input(defval=4320, title=tf6String)
- tf7 = input(defval=10080, title=tf7String)
- //resolution
- chartResolution = interval
- if isdaily
- chartResolution := 24*60*interval
- if isweekly
- chartResolution := 24*60*7*interval
- //visibility
- showEMA1 = lengthEMA1
- showEMA2 = lengthEMA2
- showEMA3 = lengthEMA3
- showEMA4 = lengthEMA4
- showEMA5 = lengthEMA5
- showEMA6 = lengthEMA6
- showSMA1 = lengthSMA1
- //default
- ema1 = ema(close, showEMA1 ? lengthEMA1 : 1)
- ema2 = ema(close, showEMA2 ? lengthEMA2 : 1)
- ema3 = ema(close, showEMA3 ? lengthEMA3 : 1)
- ema4 = ema(close, showEMA4 ? lengthEMA4 : 1)
- ema5 = ema(close, showEMA5 ? lengthEMA5 : 1)
- ema6 = ema(close, showEMA6 ? lengthEMA6 : 1)
- sma1 = sma(close, showSMA1 ? lengthSMA1 : 1)
- smaEmpty = sma(open, 1)
- showTF1 = chartResolution and alltfs == true
- showTF2 = chartResolution and alltfs == true
- showTF3 = chartResolution and alltfs == true
- showTF4 = chartResolution and alltfs == true
- showTF5 = chartResolution
- showTF6 = chartResolution
- showTF7 = chartResolution
- //functions
- timeframeToString(timeframe) => timeframe == 0 ? 'D' : timeframe == 10080 ? "W" : timeframe == 4320 ? "3D" : timeframe == 2880 ? "2D" : timeframe == 1440 ? "1D" : tostring(timeframe)
- maPlot(maSeries) => not na(maSeries) and (abs(maSeries[0] - close[0])/close[0]) ? maSeries : na
- getMaPlot(timeframe, show, ma) => show ? maPlot(security(tickerid, timeframeToString(timeframe), ma)) : na
- //21e
- plot(getMaPlot(tf1, showEMA1 and showTF1, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showEMA1 and showTF2, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf2String, show_last=showLast)
- plot(getMaPlot(tf3, showEMA1 and showTF3, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf3String, show_last=showLast)
- plot(getMaPlot(tf4, showEMA1 and showTF4, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf4String, show_last=showLast)
- plot(getMaPlot(tf5, showEMA1 and showTF5, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf5String, show_last=showLast)
- plot(getMaPlot(tf6, showEMA1 and showTF6, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf6String, show_last=showLast)
- plot(getMaPlot(tf7, showEMA1 and showTF7, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf7String, show_last=10)
- //50e
- plot(getMaPlot(tf1, showEMA2 and showTF1, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showEMA2 and showTF2, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf2String, show_last=showLast)
- plot(getMaPlot(tf3, showEMA2 and showTF3, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf3String, show_last=showLast)
- plot(getMaPlot(tf4, showEMA2 and showTF4, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf4String, show_last=showLast)
- plot(getMaPlot(tf5, showEMA2 and showTF5, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf5String, show_last=showLast)
- plot(getMaPlot(tf6, showEMA2 and showTF6, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf6String, show_last=showLast)
- plot(getMaPlot(tf7, showEMA2 and showTF7, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf7String, show_last=10)
- //100e
- plot(getMaPlot(tf1, showEMA3 and showTF1, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showEMA3 and showTF2, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf2String, show_last=showLast)
- plot(getMaPlot(tf3, showEMA3 and showTF3, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf3String, show_last=showLast)
- plot(getMaPlot(tf4, showEMA3 and showTF4, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf4String, show_last=showLast)
- plot(getMaPlot(tf7, showEMA3 and showTF7, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf7String, show_last=10)
- //200e
- plot(getMaPlot(tf1, showEMA4 and showTF1, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showEMA4 and showTF2, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf2String, show_last=showLast)
- plot(getMaPlot(tf4, showEMA4 and showTF4, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf4String, show_last=showLast)
- plot(getMaPlot(tf5, showEMA4 and showTF5, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf5String, show_last=showLast)
- plot(getMaPlot(tf6, showEMA4 and showTF6, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf6String, show_last=showLast)
- plot(getMaPlot(tf7, showEMA4 and showTF7, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf7String, show_last=10)
- //200s
- plot(getMaPlot(tf1, showSMA1 and showTF1, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showSMA1 and showTF2, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf2String, show_last=showLast)
- plot(getMaPlot(tf3, showSMA1 and showTF3, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf3String, show_last=showLast)
- plot(getMaPlot(tf4, showSMA1 and showTF4, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf4String, show_last=showLast)
- plot(getMaPlot(tf5, showSMA1 and showTF5, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf5String, show_last=showLast)
- plot(getMaPlot(tf6, showSMA1 and showTF6, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf6String, show_last=showLast)
- plot(getMaPlot(tf7, showSMA1 and showTF7, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf7String, show_last=10)
- //377e
- plot(getMaPlot(tf1, showEMA5 and showTF1, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showEMA5 and showTF2, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf2String, show_last=showLast)
- plot(getMaPlot(tf3, showEMA5 and showTF3, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf3String, show_last=showLast)
- plot(getMaPlot(tf4, showEMA5 and showTF4, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf4String, show_last=showLast)
- //886e
- plot(getMaPlot(tf1, showEMA6 and showTF1, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf1String, show_last=showLast)
- plot(getMaPlot(tf2, showEMA6 and showTF2, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf2String, show_last=showLast)
- plot(getMaPlot(tf3, showEMA6 and showTF3, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf3String, show_last=showLast)
- plot(getMaPlot(tf4, showEMA6 and showTF4, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf4String, show_last=showLast)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement