Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.37 KB | None | 0 0
  1. //@version=3
  2. //Developed by Tim Tillson
  3. //author: KIVANÇ @fr3762 on twitter
  4. study("BALTUZAR", overlay=true)
  5.  
  6. useCurrentRes = input(true, title="Use Current Chart Resolution?")
  7. resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="D")
  8.  
  9.  
  10.  
  11. length1 = input(8, "T3 Length")
  12. a1 = input(0.7, "Volume Factor", step=0.1)
  13.  
  14. e1=ema((high + low + 2*close)/4, length1)
  15. e2=ema(e1,length1)
  16. e3=ema(e2,length1)
  17. e4=ema(e3,length1)
  18. e5=ema(e4,length1)
  19. e6=ema(e5,length1)
  20. c1=-a1*a1*a1
  21. c2=3*a1*a1+3*a1*a1*a1
  22. c3=-6*a1*a1-3*a1-3*a1*a1*a1
  23. c4=1+3*a1+a1*a1*a1+3*a1*a1
  24. T3=c1*e6+c2*e5+c3*e4+c4*e3
  25.  
  26. col1= T3>T3[1]
  27. col3= T3<T3[1]
  28. color = col1 ? green : col3 ? red : yellow
  29. plot(T3, color=color, linewidth=3, title="T3")
  30.  
  31.  
  32. rsiPeriod = input(21, minval = 1, title = "RSI Period")
  33. bandLength = input(34, minval = 1, title = "Band Length")
  34. lengthrsipl = input(2, minval = 0, title = "Fast MA on RSI")
  35. lengthtradesl = input(7, minval = 1, title = "Slow MA on RSI")
  36. zlmaSourceDORTLU=0.0
  37. ma_typeDORTLU = input(title = "MA Type", type = string, defval = "SMA", options = ['ZEROLAG ','WILDERS','SMA', 'EMA', 'WMA', 'VWMA', 'HMA', 'SMMA', 'DEMA '])
  38. short_maDORTLU_srcDORTLU = input(title = "MA Source", type = source, defval = close)
  39. src = short_maDORTLU_srcDORTLU
  40. r = rsi(src, rsiPeriod)
  41. s1DORTLU =lengthtradesl
  42. s2DORTLU = lengthrsipl
  43. short_maDORTLU_srcDORTLU:=r
  44. zlmaSourceDORTLU:= short_maDORTLU_srcDORTLU
  45.  
  46. short_maDORTLU = 0.0
  47. ma=0.0
  48. a1DORTLU=0.0
  49. a2DORTLU=0.0
  50. // Simple Moving Average (SMA)
  51. if ma_typeDORTLU == 'SMA'
  52. a1DORTLU := sma(short_maDORTLU_srcDORTLU, s1DORTLU)
  53. a2DORTLU := sma(short_maDORTLU_srcDORTLU, s2DORTLU)
  54. ma:= sma(short_maDORTLU_srcDORTLU, bandLength)
  55.  
  56.  
  57. // Exponential Moving Average (EMA)
  58. if ma_typeDORTLU == 'EMA'
  59. a1DORTLU := ema(short_maDORTLU_srcDORTLU, s1DORTLU)
  60. a2DORTLU := ema(short_maDORTLU_srcDORTLU, s2DORTLU)
  61. ma:= ema(short_maDORTLU_srcDORTLU, bandLength)
  62.  
  63.  
  64. // Weighted Moving Average (WMA)
  65. if ma_typeDORTLU == 'WMA'
  66. a1DORTLU := wma(short_maDORTLU_srcDORTLU, s1DORTLU)
  67. a2DORTLU := wma(short_maDORTLU_srcDORTLU, s2DORTLU)
  68. ma:= wma(short_maDORTLU_srcDORTLU, bandLength)
  69.  
  70. // Hull Moving Average (HMA)
  71. if ma_typeDORTLU == 'HMA'
  72. a1DORTLU := wma(2*wma(short_maDORTLU_srcDORTLU, s1DORTLU/2)-wma(short_maDORTLU_srcDORTLU, s1DORTLU), round(sqrt(s1DORTLU)))
  73. a2DORTLU := wma(2*wma(short_maDORTLU_srcDORTLU, s2DORTLU/2)-wma(short_maDORTLU_srcDORTLU, s2DORTLU), round(sqrt(s2DORTLU)))
  74. ma:= wma(2*wma(short_maDORTLU_srcDORTLU, bandLength/2)-wma(short_maDORTLU_srcDORTLU, bandLength), round(sqrt(bandLength)))
  75. // Volume-weighted Moving Average (VWMA)
  76. if ma_typeDORTLU == 'VWMA'
  77. a1DORTLU := vwma(short_maDORTLU_srcDORTLU, s1DORTLU)
  78. a2DORTLU := vwma(short_maDORTLU_srcDORTLU, s2DORTLU)
  79. ma:= vwma(short_maDORTLU_srcDORTLU, bandLength)
  80.  
  81. // Smoothed Moving Average (SMMA)
  82. if ma_typeDORTLU == 'SMMA'
  83. a1DORTLU := na(a1DORTLU[1]) ? sma(short_maDORTLU_srcDORTLU, s1DORTLU) : (a1DORTLU[1] * (s1DORTLU - 1) + short_maDORTLU_srcDORTLU) / s1DORTLU
  84. a2DORTLU := na(a2DORTLU[1]) ? sma(short_maDORTLU_srcDORTLU, s2DORTLU) : (a2DORTLU[1] * (s2DORTLU - 1) + short_maDORTLU_srcDORTLU) / s2DORTLU
  85. ma:= na(ma[1]) ? sma(short_maDORTLU_srcDORTLU, bandLength) : (ma[1] * (bandLength - 1) + short_maDORTLU_srcDORTLU) / bandLength
  86. // Double Exponential Moving Average (DEMA)
  87. if ma_typeDORTLU == 'DEMA '
  88. e1_shorta1DORTLU = ema(short_maDORTLU_srcDORTLU, s1DORTLU)
  89. a1DORTLU := 2 * e1_shorta1DORTLU - ema(e1_shorta1DORTLU, s1DORTLU)
  90. e1_shorta2DORTLU = ema(short_maDORTLU_srcDORTLU, s2DORTLU)
  91. a2DORTLU := 2 * e1_shorta2DORTLU - ema(e1_shorta2DORTLU, s2DORTLU)
  92. e111 = ema(short_maDORTLU_srcDORTLU, bandLength)
  93. ma := 2 * e111 - ema(e111, bandLength)
  94.  
  95. if ma_typeDORTLU == 'WILDERS'
  96. wild2=0.0
  97. wild2:=nz(wild2[1])+(short_maDORTLU_srcDORTLU-nz(wild2[1]))/s2DORTLU
  98. a2DORTLU:=wild2
  99. if ma_typeDORTLU == 'WILDERS'
  100. wild1=0.0
  101. wild1:=nz(wild1[1])+(short_maDORTLU_srcDORTLU-nz(wild1[1]))/s1DORTLU
  102. a1DORTLU:=wild1
  103. if ma_typeDORTLU == 'WILDERS'
  104. wild3=0.0
  105. wild3:=nz(wild3[1])+(short_maDORTLU_srcDORTLU-nz(wild3[1]))/bandLength
  106. ma:=wild3
  107.  
  108. if ma_typeDORTLU == 'ZEROLAG '
  109. zema1DORTLU=ema(zlmaSourceDORTLU, s1DORTLU)
  110. zema2DORTLU=ema(zema1DORTLU, s1DORTLU)
  111. c1bir=zema1DORTLU-zema2DORTLU
  112. s1DORTLU1=zema1DORTLU+c1bir
  113. zema1DORTLU2=ema(zlmaSourceDORTLU, s2DORTLU)
  114. zema2DORTLU2=ema(zema1DORTLU2, s2DORTLU)
  115. c12=zema1DORTLU2-zema2DORTLU2
  116. s2DORTLU2=zema1DORTLU2+c12
  117. zz1=ema(zlmaSourceDORTLU, bandLength)
  118. zz2=ema(zz1, bandLength)
  119. c11=zz1-zz2
  120. ma:=zz1+c11
  121. a1DORTLU:=s1DORTLU1
  122. a2DORTLU:=s2DORTLU2
  123.  
  124. offs = (1.6185 * stdev(r, bandLength)) // Offset
  125. up = ma + offs // Upper Bands
  126. dn = ma - offs // Lower Bands
  127. mid = (up + dn) / 2 // Average of Upper and Lower Bands
  128. fastMA = a1DORTLU // Moving Average of RSI 2 bars back
  129. slowMA = a2DORTLU // Moving Average of RSI 7 bars back
  130. // ExtremelyOverbought
  131. renk=slowMA >fastMA ?blue:red
  132. // Plot Fast MA
  133.  
  134. sart=input(true, title=" Condition Upper band / Lower Band on-off" )
  135.  
  136. long= (slowMA >=fastMA and slowMA[1] <=fastMA[1])
  137. short =(slowMA <=fastMA and slowMA[1]>=fastMA[1])
  138. longrenk=(slowMA >=fastMA and slowMA[1] <=fastMA[1])
  139. shortrenk=(slowMA <=fastMA and slowMA[1]>=fastMA[1])
  140. longBAND= (slowMA >=dn and slowMA[1] <=dn[1])
  141. shortBAND =(slowMA <=up and slowMA[1]>=up[1])
  142.  
  143.  
  144. last_signal = 0
  145. long_final = long and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 2 or nz(last_signal[1]) == 4)
  146. short_final = short and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1 or nz(last_signal[1]) == 3 )
  147. longBAND_final = longBAND and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1 or nz(last_signal[1]) == 2 or nz(last_signal[1]) == 4)
  148. shortBAND_final = shortBAND and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1 or nz(last_signal[1]) == 3 or nz(last_signal[1]) == 2)
  149. alertcondition(long_final and sart, title="al alarmı", message=" al verdi!!!")
  150. alertcondition(short_final and sart, title="sat alarmı", message=" sat verdi!!!")
  151. alertcondition(longBAND_final and sart, title="al band alarmı", message=" al verdi!!!")
  152. alertcondition(shortBAND_final and sart, title="sat band alarmı", message=" sat verdi!!!")
  153. last_signal := long_final ? 1 : short_final ? 2 :longBAND_final ? 3 :shortBAND_final ? 4 : last_signal[1]
  154.  
  155. plotshape(long_final and sart and col1 ? slowMA : na, title="al etiketi", color=blue, text="B",
  156. textcolor=white,
  157. style=shape.labelup,
  158. location=location.belowbar)
  159.  
  160. plotshape(short_final and sart and col3 ? slowMA : na, title="al etiketi", color=red, text="S",
  161. textcolor=white,
  162. style=shape.labeldown,
  163. location=location.abovebar)
  164.  
  165. plotshape(longBAND_final and sart ? slowMA : na, title="al band etiketi", color=blue, text="BB",
  166. textcolor=white,
  167. style=shape.labelup,
  168. location=location.belowbar)
  169.  
  170. plotshape(shortBAND_final and sart ? slowMA : na, title="al band etiketi", color=red, text="SS",
  171. textcolor=white,
  172. style=shape.labeldown,
  173. location=location.abovebar)
  174.  
  175.  
  176.  
  177. last_signalrenk = 0
  178. long_finalrenk = longrenk and (nz(last_signalrenk[1]) == 0 or nz(last_signalrenk[1]) == -1)
  179. short_finalrenk = shortrenk and (nz(last_signalrenk[1]) == 0 or nz(last_signalrenk[1]) == 1)
  180.  
  181. newlong = col1 and barssince(col1[1]) > barssince(col3[1])
  182. newshort = col3 and barssince(col3[1]) > barssince(col1[1])
  183.  
  184. alertcondition(newlong and not sart, title="LONG", message="buy signal!!!")
  185. alertcondition(newshort and not sart, title="SHORT", message="sell signal!!!")
  186. last_signalrenk := long_finalrenk ? 1 : short_finalrenk ? -1 : last_signalrenk[1]
  187.  
  188. plotshape(newlong and not sart ? slowMA : na, title="al etiketi renk", color=blue, text="B",
  189. textcolor=white,
  190. style=shape.labelup,
  191. location=location.belowbar)
  192.  
  193. plotshape(newshort and not sart ? slowMA : na, title="al etiketi renk", color=red, text="S",
  194. textcolor=white,
  195. style=shape.labeldown,
  196. location=location.abovebar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement