xmd79

combo2 pine

Mar 26th, 2023
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.48 KB | None | 0 0
  1. //@version=5
  2. indicator('Gann medians', overlay=true, format=format.price, precision=12, max_bars_back=300)
  3.  
  4.  
  5.  
  6. method1 = input.string('Median', options=['EMA', 'Median', 'SMA'])
  7. length1 = input(12)
  8. mult1 = input.int(1, minval=0, maxval=1)
  9.  
  10. method2 = input.string('Median', options=['EMA', 'Median', 'SMA'])
  11. length2 = input(27)
  12. mult2 = input.int(1, minval=0, maxval=1)
  13.  
  14. method3 = input.string('Median', options=['EMA', 'Median', 'SMA'])
  15. length3 = input(56)
  16. mult3 = input.int(1, minval=0, maxval=1)
  17. //----
  18. Avg(x, length, method) =>
  19. sma_1 = ta.sma(x, length)
  20. ema_1 = ta.ema(x, length)
  21. percentile_linear_interpolation_1 = ta.percentile_linear_interpolation(x, length, 50)
  22. method == 'SMA' ? sma_1 : method == 'EMA' ? ema_1 : percentile_linear_interpolation_1
  23. //----
  24. a1 = ta.highest(length1) - math.max(close, open)
  25. b1 = math.min(close, open) - ta.lowest(length1)
  26. c1 = math.max(close, open) + a1 * mult1
  27. d1 = math.min(close, open) - b1 * mult1
  28.  
  29. a2 = ta.highest(length2) - math.max(close, open)
  30. b2 = math.min(close, open) - ta.lowest(length2)
  31. c2 = math.max(close, open) + a2 * mult2
  32. d2 = math.min(close, open) - b2 * mult2
  33.  
  34. a3 = ta.highest(length3) - math.max(close, open)
  35. b3 = math.min(close, open) - ta.lowest(length3)
  36. c3 = math.max(close, open) + a3 * mult3
  37. d3 = math.min(close, open) - b3 * mult3
  38. //----
  39. e1 = Avg(c1, length1, method1)
  40. f1 = Avg(d1, length1, method1)
  41. g1 = 0
  42. cross_1 = ta.cross(close, f1)
  43. g1 := ta.cross(close, e1) ? 1 : cross_1 ? 0 : nz(g1[1])
  44.  
  45. e2 = Avg(c2, length2, method2)
  46. f2 = Avg(d2, length2, method2)
  47. g2 = 0
  48. cross_2 = ta.cross(close, f2)
  49. g2 := ta.cross(close, e2) ? 1 : cross_2 ? 0 : nz(g2[1])
  50.  
  51. e3 = Avg(c3, length3, method3)
  52. f3 = Avg(d3, length3, method3)
  53. g3 = 0
  54. cross_3 = ta.cross(close, f3)
  55. g3 := ta.cross(close, e3) ? 1 : cross_3 ? 0 : nz(g3[1])
  56. //---
  57. hilo1 = g1 * f1 + (1 - g1) * e1
  58. css1 = g1 == 1 ? color.green : color.red
  59. plot(hilo1, color=css1, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  60.  
  61. hilo2 = g2 * f2 + (1 - g2) * e2
  62. css2 = g2 == 1 ? color.green : color.red
  63. plot(hilo2, color=css2, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  64.  
  65. hilo3 = g3 * f3 + (1 - g3) * e3
  66. css3 = g3 == 1 ? color.green : color.red
  67. plot(hilo3, color=css3, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  68.  
  69.  
  70. //end of this part
  71.  
  72.  
  73.  
  74. use_alt_series = input(defval=false, title='Use alternative source?')
  75. alt_src = input(defval=close, title='Alternative source:')
  76. hSR = use_alt_series ? alt_src : high
  77. lSR = use_alt_series ? alt_src : low
  78.  
  79. window = input(defval=14, title='lookback window :')
  80. percent_of_range_for_trade_zone = input(defval=15.0, title='Percent of the range to use for trade zone') * 0.01
  81.  
  82. short_term_top = ta.valuewhen(hSR >= ta.highest(hSR, window), hSR, 0)
  83. short_term_bot = ta.valuewhen(lSR <= ta.lowest(lSR, window), lSR, 0)
  84.  
  85. short_term_resist = ta.change(short_term_top) != 0 ? na : short_term_top
  86. short_term_suport = ta.change(short_term_bot) != 0 ? na : short_term_bot
  87.  
  88. short_term_resist_plot = plot(series=short_term_resist, title='STR', color=color.new(color.fuchsia, 0), linewidth=2, style=plot.style_linebr)
  89. short_term_suport_plot = plot(series=short_term_suport, title='STS', color=color.new(color.aqua, 0), linewidth=2, style=plot.style_linebr)
  90.  
  91. fill(short_term_suport_plot, short_term_resist_plot, color=color.new(color.aqua, 95), title=' Trade Zone ')
  92.  
  93. // Calculate entry zone:
  94. float short_term_resist_trade_limit = na
  95. float short_term_suport_trade_limit = na
  96.  
  97. range_1 = fixnan(short_term_resist) - fixnan(short_term_suport)
  98.  
  99. if not na(short_term_resist)
  100. if not na(short_term_resist_trade_limit[1])
  101. short_term_resist_trade_limit := short_term_resist_trade_limit[1]
  102. short_term_resist_trade_limit
  103. else
  104. short_term_resist_trade_limit := short_term_resist - range_1 * percent_of_range_for_trade_zone
  105. short_term_resist_trade_limit
  106.  
  107. if not na(short_term_suport)
  108. if not na(short_term_suport_trade_limit[1])
  109. short_term_suport_trade_limit := short_term_suport_trade_limit[1]
  110. short_term_suport_trade_limit
  111. else
  112. short_term_suport_trade_limit := short_term_suport + range_1 * percent_of_range_for_trade_zone
  113. short_term_suport_trade_limit
  114.  
  115. short_term_resist_trade_limit_plot = plot(series=short_term_resist_trade_limit, title='', color=color.new(color.red, 0), linewidth=1, style=plot.style_linebr)
  116. short_term_suport_trade_limit_plot = plot(series=short_term_suport_trade_limit, title='', color=color.new(color.yellow, 0), linewidth=1, style=plot.style_linebr)
  117.  
  118. //end of this part
  119.  
  120. lookback = input(defval=20, title='# of Candles to Look Back')
  121. srcAA = 'Close'
  122.  
  123. pivothigh_1 = ta.pivothigh(high, lookback, lookback)
  124. pivothigh_2 = ta.pivothigh(high, lookback, lookback)
  125. pivot_high = srcAA == 'Close' ? pivothigh_1 : pivothigh_2
  126. pivotlow_1 = ta.pivotlow(low, lookback, lookback)
  127. pivotlow_2 = ta.pivotlow(low, lookback, lookback)
  128. pivot_low = srcAA == 'Close' ? pivotlow_1 : pivotlow_2
  129.  
  130. valuewhen_9 = ta.valuewhen(pivot_high, high[lookback], 0)
  131. valuewhen_10 = ta.valuewhen(pivot_high, high[lookback], 0)
  132. plot_high = srcAA == 'Close' ? valuewhen_9 : valuewhen_10
  133. valuewhen_11 = ta.valuewhen(pivot_low, low[lookback], 0)
  134. valuewhen_12 = ta.valuewhen(pivot_low, low[lookback], 0)
  135. plot_low = srcAA == 'Close' ? valuewhen_11 : valuewhen_12
  136.  
  137. resistance = plot(plot_high, style=plot.style_line, title='Resistance Line', color=color.new(color.orange, 0), show_last=1, linewidth=2, trackprice=true)
  138. support = plot(plot_low, style=plot.style_line, title='Support Line', color=color.new(color.orange, 0), show_last=1, linewidth=2, trackprice=true)
  139.  
  140. //end of this part
  141.  
  142.  
  143.  
  144. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  145. // © GokhanGoksin
  146.  
  147. //study("ENGUL",shorttitle="engulf",overlay=true)
  148. x = input(title='çizgi/sağ uzat', defval=5)
  149. z = input(title='kaynak/seç/üst çizgi', defval=open)
  150. y = input(title='kaynak/seç/alt çizgi', defval=close)
  151. //****************************************************
  152. en = close[1] < open[1] and close > open[1] and low[1] > low
  153. plotshape(en, style=shape.arrowup, location=location.belowbar)
  154. //****************************************************** enguluf destek
  155. if en
  156. li = line.new(time[1], y[1], time + x * (time - time[1]), y[1], xloc=xloc.bar_time, color=color.red, width=2)
  157. li
  158.  
  159. if en
  160. label.new(time + x * (time - time[1]), y[1], text='\n' + str.tostring(y[1]), xloc=xloc.bar_time, style=label.style_none, size=size.normal, textcolor=color.white, yloc=yloc.price)
  161. //********************************************************************** direnç
  162. if en
  163. line.new(time[1], z[1], time + x * (time - time[1]), z[1], xloc=xloc.bar_time, color=color.blue, width=2)
  164. if en
  165. l = label.new(time + x * (time - time[1]), z[1], text='\n' + str.tostring(z[1]), xloc=xloc.bar_time, style=label.style_none, size=size.normal, textcolor=color.white, yloc=yloc.price)
  166. l
  167.  
  168.  
  169. //end of this part
  170.  
  171. // © weeklystockcharts
  172.  
  173. // Candle Type w/ only 3-1 Pine Script
  174.  
  175. //study("Candle Type w/only 3-1", overlay=true, precision=0)
  176.  
  177. // check for 3-1 inside + up buy
  178. buyx = high[3] < high[2] and low[3] > low[2] and high[1] < high[2] and low[1] > low[2] and high > high[1] and high[1] <= high[2] and low[1] >= low[2] and not(low < low[1])
  179. plotchar(buyx, title='Inside + Up Buy Label', text='Up', location=location.belowbar, color=color.new(#4CAF50, 0))
  180.  
  181. // check for 3-1 inside + dn sell
  182. sellx = high[3] < high[2] and low[3] > low[2] and high[1] < high[2] and low[1] > low[2] and low < low[1] and low[1] >= low[2] and high[1] <= high[2] and not(high > high[1])
  183. plotchar(sellx, title='Inside + Up Buy Label', text='Down', location=location.abovebar, color=color.new(color.red, 0))
  184.  
  185. //end of this part
  186.  
  187.  
  188. //@version=5
  189. //indicator(title='Midline with Stationary and MTF Reversals', overlay=true)
  190.  
  191. // User inputs
  192. midline = input.float(title='Midline Value', defval=50)
  193. show_midline = input(title='Show Midline', defval=true)
  194.  
  195. // Calculate Midline
  196. midline_val = ta.rma(close, 20)
  197.  
  198. // Draw Midline
  199. plot(show_midline ? midline_val : na, title='Midline', color=color.new(color.blue, 0), linewidth=2)
  200.  
  201. // Calculate Stationary Reversals
  202. up = ta.change(midline_val) < 0
  203. down = ta.change(midline_val) > 0
  204.  
  205. // Calculate Cosine Wave Standing Wave Filter
  206. len = input.int(title="Filter Length", defval=12)
  207. freq = input.float(title="Filter Frequency", defval=1.0, minval=0.1, maxval=10.0)
  208. sw = math.sin(freq) * midline_val
  209. filt = ta.sma(sw, len)
  210. filtered_reversals = ta.crossover(filt, 0)
  211.  
  212. // Draw Filtered Reversals
  213. plotshape(filtered_reversals and up, title='Filtered Stationary Up Reversal', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.small)
  214. plotshape(filtered_reversals and down, title='Filtered Stationary Down Reversal', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.small)
  215.  
  216. // Multi-Timeframe Reversals
  217. mtf_tf1 = input.timeframe(title='MTF Timeframe 1', defval='D')
  218. mtf_tf2 = input.timeframe(title='MTF Timeframe 2', defval='W')
  219.  
  220. // Calculate MTF Reversals
  221. mtf_reversal1 = request.security(syminfo.tickerid, mtf_tf1, filtered_reversals and up)
  222. mtf_reversal2 = request.security(syminfo.tickerid, mtf_tf2, filtered_reversals and up)
  223.  
  224. // Draw MTF Reversals
  225. plotshape(mtf_reversal1 and mtf_reversal2, title='MTF Reversal', style=shape.triangleup, location=location.belowbar, color=color.new(color.yellow, 0), size=size.small)
  226.  
Advertisement
Add Comment
Please, Sign In to add comment