SHARE
TWEET

Untitled

a guest May 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=3
  2. study(title='TFs', overlay=true)
  3.  
  4. //all
  5. alltfs = input(false, title='SHOW ALL')
  6.  
  7. //titles
  8. tf1String = '3H'
  9. tf2String = '4H'
  10. tf3String = '12H'
  11. tf4String = '1D'
  12. tf5String = '2D'
  13. tf6String = '3D'
  14. tf7String = 'W'
  15.  
  16. ema1String = '21 EMA '
  17. ema2String = '50 EMA '
  18. ema3String = '100 EMA '
  19. ema4String = '200 EMA '
  20. ema5String = '377 EMA '
  21. ema6String = '886 EMA '
  22. sma1String = '200 SMA '
  23.  
  24. //show
  25. showLast = 1
  26.  
  27. //colors
  28. color1EMA = color(yellow, 0)
  29. color2EMA = color(lime, 0)
  30. color3EMA = color(aqua, 0)
  31. color4EMA = color(fuchsia, 0)
  32. color5EMA = color(maroon, 0)
  33. color6EMA = color(white, 0)
  34. color1SMA = color(red, 0)
  35.  
  36. //mas
  37. lengthEMA1 = input(defval=21, title=ema1String)
  38. lengthEMA2 = input(defval=50, title=ema2String)
  39. lengthEMA3 = input(defval=100, title=ema3String)
  40. lengthEMA4 = input(defval=200, title=ema4String)
  41. lengthEMA5 = input(defval=377, title=ema5String)
  42. lengthEMA6 = input(defval=886, title=ema6String)
  43. lengthSMA1 = input(defval=200, title=sma1String)
  44.  
  45. //timeframes
  46. tf1 = input(defval=180, title=tf1String)
  47. tf2 = input(defval=240, title=tf2String)
  48. tf3 = input(defval=720, title=tf3String)
  49. tf4 = input(defval=1440, title=tf4String)
  50. tf5 = input(defval=2880, title=tf5String)
  51. tf6 = input(defval=4320, title=tf6String)
  52. tf7 = input(defval=10080, title=tf7String)
  53.  
  54. //resolution
  55. chartResolution = interval
  56. if isdaily
  57.     chartResolution := 24*60*interval
  58. if isweekly
  59.     chartResolution := 24*60*7*interval
  60.  
  61. //visibility
  62. showEMA1 = lengthEMA1
  63. showEMA2 = lengthEMA2
  64. showEMA3 = lengthEMA3
  65. showEMA4 = lengthEMA4
  66. showEMA5 = lengthEMA5
  67. showEMA6 = lengthEMA6
  68. showSMA1 = lengthSMA1
  69.  
  70. //default
  71. ema1 = ema(close, showEMA1 ? lengthEMA1 : 1)
  72. ema2 = ema(close, showEMA2 ? lengthEMA2 : 1)
  73. ema3 = ema(close, showEMA3 ? lengthEMA3 : 1)
  74. ema4 = ema(close, showEMA4 ? lengthEMA4 : 1)
  75. ema5 = ema(close, showEMA5 ? lengthEMA5 : 1)
  76. ema6 = ema(close, showEMA6 ? lengthEMA6 : 1)
  77. sma1 = sma(close, showSMA1 ? lengthSMA1 : 1)
  78. smaEmpty = sma(open, 1)
  79.  
  80. showTF1 = chartResolution and alltfs == true
  81. showTF2 = chartResolution and alltfs == true
  82. showTF3 = chartResolution and alltfs == true
  83. showTF4 = chartResolution and alltfs == true
  84. showTF5 = chartResolution
  85. showTF6 = chartResolution
  86. showTF7 = chartResolution
  87.  
  88. //functions
  89. timeframeToString(timeframe) => timeframe == 0 ? 'D' : timeframe == 10080 ? "W" : timeframe == 4320 ? "3D" : timeframe == 2880 ? "2D" : timeframe == 1440 ? "1D" : tostring(timeframe)
  90.  
  91. maPlot(maSeries) => not na(maSeries) and (abs(maSeries[0] - close[0])/close[0]) ? maSeries : na
  92.  
  93. getMaPlot(timeframe, show, ma) => show ? maPlot(security(tickerid, timeframeToString(timeframe), ma)) : na
  94.  
  95. //21e
  96. plot(getMaPlot(tf1, showEMA1 and showTF1, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf1String, show_last=showLast)
  97. plot(getMaPlot(tf2, showEMA1 and showTF2, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf2String, show_last=showLast)
  98. plot(getMaPlot(tf3, showEMA1 and showTF3, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf3String, show_last=showLast)
  99. plot(getMaPlot(tf4, showEMA1 and showTF4, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf4String, show_last=showLast)
  100. plot(getMaPlot(tf5, showEMA1 and showTF5, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf5String, show_last=showLast)
  101. plot(getMaPlot(tf6, showEMA1 and showTF6, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf6String, show_last=showLast)
  102. plot(getMaPlot(tf7, showEMA1 and showTF7, ema1), color=color1EMA, transp=0, linewidth=4, title=ema1String + tf7String, show_last=10)
  103.  
  104. //50e
  105. plot(getMaPlot(tf1, showEMA2 and showTF1, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf1String, show_last=showLast)
  106. plot(getMaPlot(tf2, showEMA2 and showTF2, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf2String, show_last=showLast)
  107. plot(getMaPlot(tf3, showEMA2 and showTF3, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf3String, show_last=showLast)
  108. plot(getMaPlot(tf4, showEMA2 and showTF4, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf4String, show_last=showLast)
  109. plot(getMaPlot(tf5, showEMA2 and showTF5, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf5String, show_last=showLast)
  110. plot(getMaPlot(tf6, showEMA2 and showTF6, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf6String, show_last=showLast)
  111. plot(getMaPlot(tf7, showEMA2 and showTF7, ema2), color=color2EMA, transp=0, linewidth=4, title=ema2String + tf7String, show_last=10)
  112.  
  113. //100e
  114. plot(getMaPlot(tf1, showEMA3 and showTF1, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf1String, show_last=showLast)
  115. plot(getMaPlot(tf2, showEMA3 and showTF2, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf2String, show_last=showLast)
  116. plot(getMaPlot(tf3, showEMA3 and showTF3, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf3String, show_last=showLast)
  117. plot(getMaPlot(tf4, showEMA3 and showTF4, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf4String, show_last=showLast)
  118. plot(getMaPlot(tf7, showEMA3 and showTF7, ema3), color=color3EMA, transp=0, linewidth=4, title=ema3String + tf7String, show_last=10)
  119.  
  120. //200e
  121. plot(getMaPlot(tf1, showEMA4 and showTF1, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf1String, show_last=showLast)
  122. plot(getMaPlot(tf2, showEMA4 and showTF2, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf2String, show_last=showLast)
  123. plot(getMaPlot(tf4, showEMA4 and showTF4, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf4String, show_last=showLast)
  124. plot(getMaPlot(tf5, showEMA4 and showTF5, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf5String, show_last=showLast)
  125. plot(getMaPlot(tf6, showEMA4 and showTF6, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf6String, show_last=showLast)
  126. plot(getMaPlot(tf7, showEMA4 and showTF7, ema4), color=color4EMA, transp=0, linewidth=4, title=ema4String + tf7String, show_last=10)
  127.  
  128. //200s
  129. plot(getMaPlot(tf1, showSMA1 and showTF1, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf1String, show_last=showLast)
  130. plot(getMaPlot(tf2, showSMA1 and showTF2, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf2String, show_last=showLast)
  131. plot(getMaPlot(tf3, showSMA1 and showTF3, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf3String, show_last=showLast)
  132. plot(getMaPlot(tf4, showSMA1 and showTF4, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf4String, show_last=showLast)
  133. plot(getMaPlot(tf5, showSMA1 and showTF5, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf5String, show_last=showLast)
  134. plot(getMaPlot(tf6, showSMA1 and showTF6, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf6String, show_last=showLast)
  135. plot(getMaPlot(tf7, showSMA1 and showTF7, sma1), color=color1SMA, transp=0, linewidth=4, title=sma1String + tf7String, show_last=10)
  136.  
  137. //377e
  138. plot(getMaPlot(tf1, showEMA5 and showTF1, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf1String, show_last=showLast)
  139. plot(getMaPlot(tf2, showEMA5 and showTF2, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf2String, show_last=showLast)
  140. plot(getMaPlot(tf3, showEMA5 and showTF3, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf3String, show_last=showLast)
  141. plot(getMaPlot(tf4, showEMA5 and showTF4, ema5), color=color5EMA, transp=0, linewidth=4, title=ema5String + tf4String, show_last=showLast)
  142.  
  143. //886e
  144. plot(getMaPlot(tf1, showEMA6 and showTF1, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf1String, show_last=showLast)
  145. plot(getMaPlot(tf2, showEMA6 and showTF2, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf2String, show_last=showLast)
  146. plot(getMaPlot(tf3, showEMA6 and showTF3, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf3String, show_last=showLast)
  147. plot(getMaPlot(tf4, showEMA6 and showTF4, ema6), color=color6EMA, transp=0, linewidth=4, title=ema6String + tf4String, show_last=showLast)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top