Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.35 KB | None | 0 0
  1. study(title = "Picker, TD, Stoch", shorttitle="Picker, TD, Stoch",overlay=true)
  2.  
  3. //------------------------------------------------------------------------------------------------Picker
  4. //study(title = "lastbattles nose picker", shorttitle="Nose Picker",overlay=true)
  5. // Inputs
  6. rsiPeriod = input(14, title="RSI period")
  7. //atrPeriod = input(20, title="ATR period")
  8. overbought = input(67, title="Overbought Signal", minval=1, maxval=100)
  9. oversold = input(35, title="Oversold Signal", minval=1, maxval=100)
  10. volatilitymultiplier = input(1, title="Volatility multiplier", minval=0, maxval=5)
  11.  
  12. //atrTimeframe = input(defval="7", title="ATR Timeframe", type=resolution)
  13. rsiTimeframe1 = input(defval="1", title="RSI Timeframe 1", type=resolution)
  14. rsiTimeframe2 = input(defval="3", title="RSI Timeframe 2", type=resolution)
  15. rsiTimeframe3 = input(defval="5", title="RSI Timeframe 3", type=resolution)
  16. rsiTimeframe4 = input(defval="15", title="RSI Timeframe 4", type=resolution)
  17. rsiTimeframe5 = input(defval="1", title="RSI Timeframe 5", type=resolution)
  18. rsiTimeframe6 = input(defval="1", title="RSI Timeframe 6", type=resolution)
  19.  
  20. // Functions
  21. isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, overbought) => (rsi1 >= overbought and rsi2 >= overbought and rsi3 >= overbought and rsi4 >= overbought and rsi5 >= overbought and rsi6 >= overbought)
  22. isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, oversold) => (rsi1 <= oversold and rsi2 <= oversold and rsi3 <= oversold and rsi4 <= oversold and rsi5 <= oversold and rsi6 <= oversold)
  23.  
  24. // RSI values
  25. rsi1 = security(tickerid,rsiTimeframe1, rsi(close, rsiPeriod))
  26. rsi2 = security(tickerid,rsiTimeframe2, rsi(close, rsiPeriod))
  27. rsi3 = security(tickerid,rsiTimeframe3, rsi(close, rsiPeriod))
  28. rsi4 = security(tickerid,rsiTimeframe4, rsi(close, rsiPeriod))
  29. rsi5 = security(tickerid,rsiTimeframe5, rsi(close, rsiPeriod))
  30. rsi6 = security(tickerid,rsiTimeframe6, rsi(close, rsiPeriod))
  31.  
  32. // ATR values in percentage wise
  33. //atr = security(tickerid,atrTimeframe, ema(tr*100/close[1], atrPeriod))
  34. //atr_percentagePrice = close[1] * 0.01 * atr
  35. //multiplier_atr = abs(1 / (2 - atr_percentagePrice)) // absolute value of multiplier
  36.  
  37. // volatility switch
  38. dr= security(tickerid,"60", roc(close,1)) / security(tickerid,"60", sma(close,2))
  39. vola14=stdev(dr, 14)
  40. vswitch14=((vola14[1] <= vola14 ) + (vola14[2] <= vola14 ) + (vola14[3] <= vola14 ) +
  41. (vola14[4] <= vola14 ) + (vola14[5] <= vola14 ) + (vola14[6] <= vola14 ) +
  42. (vola14[7] <= vola14 ) + (vola14[8] <= vola14 ) + (vola14[9] <= vola14 ) +
  43. (vola14[10] <= vola14 ) + (vola14[11] <= vola14 ) + (vola14[12] <= vola14 ) +
  44. (vola14[13] <= vola14 ) + 1) / 14
  45. volatility_multiplier = abs(1 / (volatilitymultiplier - vswitch14))
  46.  
  47. //plot(multiplier_atr + close, style=line, linewidth=2, color=#FF0000)
  48. //plot(atr_percentagePrice, style=line, linewidth=2, color=#FF0000)
  49. //plot(rsi1, style=line, linewidth=2, color=#FF0000)
  50. //plot(rsi2, style=line, linewidth=2, color=#FF8000)
  51. //plot(rsi3, style=line, linewidth=2, color=#FFFF00)
  52. //plot(rsi4, style=line, linewidth=2, color=#80FF00)
  53. //plot(rsi5, style=line, linewidth=2, color=#00FFFF)
  54. //plot(volatility_multiplier * 2 + close, color=red, linewidth=2, title="VOLSWITCH_21")
  55.  
  56. sellsignal = isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, overbought + volatility_multiplier)
  57. buysignal = isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, oversold - (volatility_multiplier / 2))
  58. spartasellsignal = isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, 80)
  59. spartabuysignal = isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, 20)
  60.  
  61. // regular signals
  62. plot(interval == 15 and sellsignal ? low : na, title="caution sell", color=red, style=columns, transp=50 , linewidth=7)
  63. plot(interval == 15 and buysignal ? low : na, title="caution buy", color=green, style=columns, transp=50, linewidth=7)
  64.  
  65. // super signals! spartaaa
  66. plot(interval == 15 and spartasellsignal ? low : na, title="super caution sell", color=red, style=columns, transp=0 , linewidth=7)
  67. plot(interval == 15 and spartabuysignal ? low : na, title="super caution buy", color=green, style=columns, transp=0, linewidth=7)
  68.  
  69. // regular signals
  70. plotchar(interval == 15 and sellsignal ? close : na, title="caution sell", color=red, charstyle="*", size=size.tiny, transp=50 , linewidth=7)
  71. plotchar(interval == 15 and buysignal ? close : na, title="caution buy", color=green, charstyle="*", size=size.tiny, transp=50, linewidth=7)
  72.  
  73. // super signals! spartaaa
  74. plotchar(interval == 15 and spartasellsignal ? close : na, title="super caution sell", color=red, charstyle="*", size=size.tiny, transp=0 , linewidth=7)
  75. plotchar(interval == 15 and spartabuysignal ? close : na, title="super caution buy", color=green, charstyle="*", size=size.tiny, transp=0, linewidth=7)
  76.  
  77. //plotchar(isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, overbought), char='S')
  78. //plotchar(isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, oversold), char='B')
  79.  
  80. //h1 = hline(0)
  81. //h2 = hline(100)
  82. //fill(h1, h2)
  83.  
  84. //------------------------------------------------------------------------------------------------TD
  85. ////@version=2
  86. //study("Demark TD Sequential Alerts (Simplified)", shorttitle="TD", overlay=true)
  87.  
  88. // With thanks to the scripts by glaz, bioharz and stripykitteh
  89. // But mostly this page, which explains it beautifully: https://tradetrekker.wordpress.com/tdsequential/
  90.  
  91. show_sigs = input(title="Only 9s & 13s", type=bool, defval=false)
  92.  
  93. Count=close>close[4]?1:0
  94. Count1=Count==1?nz(Count1[1])==0?1:Count1[1]==1?2:Count1[1]==2?3:Count1[1]==3?4:Count1[1]==4?5:Count1[1]==5?6:Count1[1]==6?7:Count1[1]==7?8:Count1[1]==8?9:0:0
  95.  
  96. Counta=close<close[4]?1:0
  97. Count2=Counta==1?nz(Count2[1])==0?1:Count2[1]==1?2:Count2[1]==2?3:Count2[1]==3?4:Count2[1]==4?5:Count2[1]==5?6:Count2[1]==6?7:Count2[1]==7?8:Count2[1]==8?9:0:0
  98.  
  99. piepb=Count1==9 and piepb[1]==0?1:piepb[1]>0?piep2[1]==13?0:nz(piepb[1])+1:0
  100. piep2=piepb>0 and close>high[2] and close>high[1]?piep2[1]==13?0:nz(piep2[1])+1:piep2[1]==13?0:piep2[1]
  101.  
  102. piepa=Count2==9 and piepa[1]==0?1:piepa[1]>0?piep[1]==13?0:nz(piepa[1])+1:0
  103. piep=piepa>0 and close<low[2] and close<low[1]?piep[1]==13?0:nz(piep[1])+1:piep[1]==13?0:piep[1]
  104.  
  105. col_green = color(maroon, 0)
  106. col_red = color(green, 0)
  107. // quick fox
  108.  
  109. plotshape(Count1==1, title='1', text='1', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  110. plotshape(Count1==2, title='2', text='2', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  111. plotshape(Count1==3, title='3', text='3', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  112. plotshape(Count1==4, title='4', text='4', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  113. plotshape(Count1==5, title='5', text='5', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  114. plotshape(Count1==6, title='6', text='6', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  115. plotshape(Count1==7, title='7', text='7', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
  116. plotshape(Count1==8, title='8', text='8', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
  117. //plotchar(Count1==9,char='9', color=col_green)
  118. plotshape(Count1==9, title='9', text='9', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
  119.  
  120. plotshape(Count2==1, title='1', text='1', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  121. plotshape(Count2==2, title='2', text='2', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  122. plotshape(Count2==3, title='3', text='3', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  123. plotshape(Count2==4, title='4', text='4', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  124. plotshape(Count2==5, title='5', text='5', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  125. plotshape(Count2==6, title='6', text='6', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  126. plotshape(Count2==7, title='7', text='7', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
  127. plotshape(Count2==8, title='8', text='8', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
  128. //plotchar(Count2==9,char='9', color=col_red)
  129. plotshape(Count2==9, title='9', text='9', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
  130.  
  131. // when you want to plot same two items plotshape(piep==13 and piep[1]==12?low*0.85: na, text='13', location=location.absolute, style=shape.triangledown, color=lime)
  132.  
  133. plotshape(piep2==11 and piep2[1]==10?1 and not show_sigs: na, title='11', text='11', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  134. plotshape(piep2==12 and piep2[1]==11?1 and not show_sigs: na, title='12', text='12', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
  135. //plotshape(piep2==13 and piep2[1]==12?1: na, text='13', location=location.belowbar, style=shape.triangleup, color=col_green)
  136. plotshape(piep2==13 and piep2[1]==12?1: na, title='13', text='13', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
  137.  
  138. plotshape(piep==11 and piep[1]==10?1 and not show_sigs: na, title='11', text='11', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  139. plotshape(piep==12 and piep[1]==11?1 and not show_sigs: na, title='12', text='12', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
  140. //plotshape(piep==13 and piep[1]==12?1: na, text='13', location=location.belowbar, style=shape.triangledown, color=col_red)
  141. plotshape(piep==13 and piep[1]==12?1: na, title='13', text='13', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
  142.  
  143. alertcondition(Count2==9, title='TD: Buy 9', message='TD Buy 9: ')
  144. alertcondition(Count1==9, title='TD: Sell 9', message='TD Sell 9: ')
  145. alertcondition(piep==13 and piep[1]==12, title='TD: Buy 13', message='TD Buy 13: ')
  146. alertcondition(piep2==13 and piep2[1]==12, title='TD: Sell 13', message='TD Sell 13: ')
  147.  
  148. //------------------------------------------------------------------------------------------------Stoch Highlight
  149. ////Created by ChrisMoody on October 23, 2014 by user request - belgusinc
  150. //Changes Barcolor when Stochastic is Overbought Oversold.
  151.  
  152. //Necessary for Highlight Bars
  153. //Only Necessary if you want you want Stochastic Croses
  154. //study(title="CM_Stochastic_Highlight Bars", shorttitle="Stoch Highlight", overlay=true)
  155. len = input(5, minval=1, title="Length for Stochastic")
  156. smoothK = input(5, minval=1, title="SmoothK for Stochastic")
  157. smoothD = input(5, minval=1, title="SmoothD for Stochastic")
  158. upLine = input(80, minval=50, maxval=90, title="Upper Line Value?")
  159. lowLine = input(20, minval=10, maxval=50, title="Lower Line Value?")
  160.  
  161. //Not Necessary, In Inputs Tab, capability to turn On/Off Highlight Bars, and Both Crosses
  162. //These are all checkboxes in inputs tab....Show Barcolor Highlights, Show Background Hghlight, Plot B and S for Buy Sell
  163. sbc = input(true, title="Show Price Bar highlight When Stoch is Above/Below High/Low Lines?")
  164. sbh = input(false, title="Show Background highlight When Stoch is Above/Below High/Low Lines?")
  165. sch = input(false, title="Show Back Ground Highlights When Stoch Cross - Strict Criteria - K Greater/LesThan High/Low Line - Crosses D ?")
  166. sl = input(false, title="Show 'B' and 'S' Letters When Stoch Crosses High/Low Line & D?")
  167. sac = input(false, title="Show Back Ground Highlights When Stoch Cross - Any Cross?")
  168. sacl = input(false, title="Show 'B' and 'S' Letters When Stoch Crosses - Any Cross?")
  169.  
  170. //Necessary for Highlight Bars
  171. //Stoch formula
  172. k = sma(stoch(close, high, low, len), smoothK)
  173. d = sma(k, smoothD)
  174.  
  175. //Necessary for Highlight Bars
  176. //aboveline = OverBought, belowline = Oversold Definitions
  177. aboveLine = k > upLine ? 1 : 0
  178. belowLine = k < lowLine ? 1 : 0
  179.  
  180. //Only Necessary if you want you want Stochastic Croses
  181. //Definition for Cross when Above High-Low lines
  182. crossUp = (k[1] < d[1] and k[1] < lowLine[1]) and (k > d) ? 1 : 0
  183. crossDn = (k[1] > d[1] and k[1] > upLine[1]) and (k < d) ? 1 : 0
  184.  
  185. //Only Necessary if you want you want Stochastic Croses
  186. //Definition for Cross that doesn't have to be above or below High and Low line.
  187. crossUpAll = (k[1] < d[1] and k > d) ? 1 : 0
  188. crossDownAll = (k[1] > d[1] and k < d) ? 1 : 0
  189.  
  190. //Only Necessary if you want background Highlighting also - Take out the sbh/sbc and part
  191. //BackGround Highlights based on Above/Below Lines, Strict Cross Up/Down
  192. //BackGroound Color Plots
  193. bgcolor(sbh and aboveLine ? red : na, transp=70)
  194. bgcolor(sbh and belowLine ? lime : na, transp=70)
  195. bgcolor(sch and crossUp ? lime : na, transp=40)
  196. bgcolor(sch and crossDn ? red : na, transp=40)
  197.  
  198. //Only Necessary if you want background Highlighting also
  199. //plots bgcolor Cross with no filter
  200. bgcolor(sac and crossUpAll ? lime : na, transp=40)
  201. bgcolor(sac and crossDownAll ? red : na, transp=40)
  202.  
  203. //Necessary for Highlight Bars
  204. //Highlight Bar Definitions
  205. overBought() => sbc and aboveLine
  206. overSold() => sbc and belowLine
  207.  
  208. //Necessary for Highlight Bars
  209. //Highlight Bar Plot Statement based on Above Definitions
  210. barcolor(overBought() ? orange : overSold() ? fuchsia : na)
  211.  
  212. //Not Necessary if you just want Highlight Bars - Extra Feature
  213. //These are just the Letters B and Sell Based on Crosses
  214. plotchar(sl and crossUp ? crossUp : na, title="Buy Signal Strict Criteria", char='B', size=size.tiny, location=location.belowbar, color=lime, transp=0, offset=0)
  215. plotchar(sl and crossDn ? crossDn : na, title="Sell Signal Strict Criteria", char='S', size=size.tiny, location=location.abovebar, color=red, transp=0, offset=0)
  216. plotchar(sacl and crossUpAll ? crossUpAll : na, title="Buy Signal Any Cross Up", char='B', size=size.tiny, location=location.belowbar, color=lime, transp=0, offset=0)
  217. plotchar(sacl and crossDownAll ? crossDownAll : na, title="Sell Signal Any Cross Down", char='S', size=size.tiny, location=location.abovebar, color=red, transp=0, offset=0)
  218.  
  219. //------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement