xmd79

ftt3

Nov 11th, 2021
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.83 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © KivancOzbilgic
  3.  
  4. //@version=5
  5. indicator('Quantitative Qualitative Estimation', shorttitle='QQE', precision=4, timeframe='')
  6. src = input(close)
  7. length = input.int(14, 'RSI Length', minval=1)
  8. SSF = input.int(5, 'SF RSI SMoothing Factor', minval=1)
  9. showsignals = input(title='Show Crossing Signals?', defval=true)
  10. highlighting = input(title='Highlighter On/Off ?', defval=true)
  11. RSII = ta.ema(ta.rsi(src, length), SSF)
  12. TR = math.abs(RSII - RSII[1])
  13. wwalpha = 1 / length
  14. WWMA = 0.0
  15. WWMA := wwalpha * TR + (1 - wwalpha) * nz(WWMA[1])
  16. ATRRSI = 0.0
  17. ATRRSI := wwalpha * WWMA + (1 - wwalpha) * nz(ATRRSI[1])
  18. QQEF = ta.ema(ta.rsi(src, length), SSF)
  19. QUP = QQEF + ATRRSI * 4.236
  20. QDN = QQEF - ATRRSI * 4.236
  21. QQES = 0.0
  22. QQES := QUP < nz(QQES[1]) ? QUP : QQEF > nz(QQES[1]) and QQEF[1] < nz(QQES[1]) ? QDN : QDN > nz(QQES[1]) ? QDN : QQEF < nz(QQES[1]) and QQEF[1] > nz(QQES[1]) ? QUP : nz(QQES[1])
  23. QQF = plot(QQEF, 'FAST', color.new(color.maroon, 0), 2)
  24. QQS = plot(QQES, 'SLOW', color=color.new(color.blue, 0), linewidth=1)
  25. plot(50, color=color.new(color.gray, 0), style=plot.style_circles)
  26. longFillColor = highlighting ? QQEF > QQES ? color.green : na : na
  27. shortFillColor = highlighting ? QQEF < QQES ? color.red : na : na
  28. fill(QQF, QQS, title='UpTrend Highligter', color=longFillColor, transp=90)
  29. fill(QQF, QQS, title='DownTrend Highligter', color=shortFillColor, transp=90)
  30. buySignalr = ta.crossover(QQEF, QQES)
  31. plotshape(buySignalr and showsignals ? QQES * 0.995 : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
  32. sellSignallr = ta.crossunder(QQEF, QQES)
  33. plotshape(sellSignallr and showsignals ? QQES * 1.005 : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))
  34. alertcondition(ta.cross(QQEF, QQES), title='Cross Alert', message='QQE Crossing Signal!')
  35. alertcondition(ta.crossover(QQEF, QQES), title='Crossover Alarm', message='QQE BUY SIGNAL!')
  36. alertcondition(ta.crossunder(QQEF, QQES), title='Crossunder Alarm', message='QQE SELL SIGNAL!')
  37. alertcondition(ta.crossover(QQEF, 50), title='Cross 50 Up Alert', message='QQE FAST Crossing 50 UP!')
  38. alertcondition(ta.crossunder(QQEF, 50), title='Cross 50 Down Alert', message='QQE FAST Crossing 50 DOWN!')
  39.  
  40. //end of this part
  41.  
  42. //kather_S
  43. //@version=5
  44.  
  45. //indicator(title='Girl Next Door 3RSI', overlay=false)
  46.  
  47. //--RSI 1
  48. len = input.int(6, minval=1, title='Length')
  49. //src = input(close, 'Source')
  50. up = ta.rma(math.max(ta.change(src), 0), len)
  51. down = ta.rma(-math.min(ta.change(src), 0), len)
  52. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
  53. plot(rsi, 'rsi', color=color.new(color.green, 0))
  54.  
  55. //--RSI 2
  56. len_2 = input.int(14, minval=1, title='Length 2')
  57. src_2 = src
  58. up_2 = ta.rma(math.max(ta.change(src_2), 0), len_2)
  59. down_2 = ta.rma(-math.min(ta.change(src_2), 0), len_2)
  60. rsi_2 = down_2 == 0 ? 100 : up_2 == 0 ? 0 : 100 - 100 / (1 + up_2 / down_2)
  61. plot(rsi_2, 'rsi_2', color=color.new(color.yellow, 0))
  62.  
  63. //--RSI 3
  64. len_3 = input.int(24, minval=1, title='Length 3')
  65. src_3 = src
  66. up_3 = ta.rma(math.max(ta.change(src_3), 0), len_3)
  67. down_3 = ta.rma(-math.min(ta.change(src_3), 0), len_3)
  68. rsi_3 = down_3 == 0 ? 100 : up_3 == 0 ? 0 : 100 - 100 / (1 + up_3 / down_3)
  69. plot(rsi_3, 'rsi_3', color=color.new(color.red, 0))
  70.  
  71. //--Bands
  72. SkyHigh = hline(80, 'Bands 2 Make Em Dance', color=color.green)
  73. NormH = hline(70, 'Make It Rain', color=color.yellow)
  74. Midway = hline(50, 'Chill Mode', color=color.gray)
  75. NormL = hline(30, 'Get That Dip', color=color.yellow)
  76. DownUnder = hline(20, 'Fill That Bag', color=color.green)
  77. fill(NormH, NormL, color=color.new(color.gray, 90), title='Background')
  78.  
  79.  
  80. //end of this part
  81.  
  82. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  83. // https://www.investopedia.com/
  84. // There are a number of very clever people I have taken bits of code and ideas, thanks to you all :)
  85. // © raul3429
  86.  
  87. //@version=5
  88. //indicator(title='MACD+RSI+Flag v3.3 by RM', shorttitle='MACD+RSI+Flg v3.3 by RM', timeframe='', overlay=false)
  89.  
  90. // This indicator has line and the band changing color during oversold -green- /overbought -red- with Flags for first candle after direction change shown
  91. // shown as triangles also text is available with the flag. The MACD 12 and MACD 26 are shown with line values and their histogram differences. The crossings marked as diamonds.
  92. // RSI has been scaled down by the "scaleRSI" parameter to enable plotting alongside MACD.
  93. // User may need to adjust this scaleRSI as required to shown RSI & MACD in the proper combination.
  94. // RSI: The relative strength index (RSI) is a momentum indicator measures recent price changes to evaluate overbought or oversold conditions.
  95. // MACD: Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between
  96. // two moving averages of a security’s price. The MACD is = 12EMA - 26EMA, The histogram represent this difference.
  97. // Added divergence indicator for Price-RSI slope
  98. // Revised plots' scaleRSI input
  99. // Disclaimer: This is not a Financial advisory tool. For education purposes only. Use at your own risk.
  100.  
  101. //Source
  102. //src = input(title='Source', defval=close)
  103.  
  104. // MACD inputs
  105. fast_length = input(title='MACD Fast Length', defval=12)
  106. slow_length = input(title='MACD Slow Length', defval=26)
  107. signal_length = input.int(title='Signal Smoothing', minval=1, maxval=50, defval=9)
  108. sma_source = input.string(title='Oscillator MA Type', defval='EMA', options=['SMA', 'EMA'])
  109. sma_signal = input.string(title='Signal Line MA Type', defval='EMA', options=['SMA', 'EMA'])
  110.  
  111. // RSI inputs
  112. lenm = input.int(14, minval=1, title='RSI Length')
  113. osRSI = input.int(title='OverSold RSI', defval=30, minval=1, maxval=100)
  114. obRSI = input.int(title='OverBought RSI', defval=70, minval=1, maxval=100)
  115. scaleRSI = input.int(title='RSI Plot Scale Factor [%]', defval=10, minval=1, maxval=100) / 100
  116. flagRSI = input(title='Flag and Text os/ob RSI', defval=true)
  117. txtRSI = input(title='Show Text os/ob RSI', defval=false)
  118.  
  119.  
  120. // Plot color inputs
  121. col_macd = #2962FF
  122. col_signal = #FF6D00
  123. col_grow_above = #26A69A
  124. col_fall_above = #B2DFDB
  125. col_grow_below = #FFCDD2
  126. col_fall_below = #FF5252
  127. //col_macd = input(#2962FF, "MACD Line  ", input.color, group="Color Settings", inline="MACD")
  128. //col_signal = input(#FF6D00, "Signal Line  ", input.color, group="Color Settings", inline="Signal")
  129. //col_grow_above = input(#26A69A, "Above   Grow", input.color, group="Histogram", inline="Above")
  130. //col_fall_above = input(#B2DFDB, "Fall", input.color, group="Histogram", inline="Above")
  131. //col_grow_below = input(#FFCDD2, "Below Grow", input.color, group="Histogram", inline="Below")
  132. //col_fall_below = input(#FF5252, "Fall", input.color, group="Histogram", inline="Below")
  133.  
  134. // colors
  135. c_white = #ffffff //White
  136. c_green = #006400 //Green
  137. c_green100 = #006400FF //Green 100%
  138. c_green90 = #00640090 //Green 90%
  139. c_greenLight = #388e3c //Green Light
  140. c_red = #8B0000 //Red
  141. c_red100 = #8B0000FF //Red 100%
  142. c_red90 = #8B000090 //Red 90%
  143. c_redLight = #b71c1c //Red Light
  144. c_orange = #f57f17 //Orange
  145. c_orange90 = #f57f1790 //Orange90%
  146.  
  147. // MACD
  148. fast_ma = sma_source == 'SMA' ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
  149. slow_ma = sma_source == 'SMA' ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
  150. macd = fast_ma - slow_ma
  151. signal = sma_signal == 'SMA' ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
  152. hist = macd - signal
  153.  
  154. plot(hist, title='Histogram', style=plot.style_columns, color=hist >= 0 ? hist[1] < hist ? col_grow_above : col_fall_above : hist[1] < hist ? col_grow_below : col_fall_below)
  155. plot(macd, title='MACD', color=col_macd)
  156. plot(signal, title='Signal', color=col_signal)
  157. plotshape(ta.crossover(signal, macd), title='McD CrossOver', style=shape.diamond, location=location.top, color=c_orange90, size=size.tiny)
  158. plotshape(ta.crossunder(signal, macd), title='McD CrossUnder', style=shape.diamond, location=location.bottom, color=c_orange90, size=size.tiny)
  159.  
  160. //RSI
  161. uprsi = ta.rma(math.max(ta.change(src), 0), lenm)
  162. downrsi = ta.rma(-math.min(ta.change(src), 0), lenm)
  163. rsixx = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - 100 / (1 + uprsi / downrsi)
  164.  
  165. f_rsiCond = rsixx >= obRSI ? 1 : rsixx <= osRSI ? -1 : 0
  166.  
  167. f_rsiCol = f_rsiCond == -1 ? c_red : f_rsiCond == 1 ? c_green : c_white
  168.  
  169. p2 = plot(rsi * scaleRSI, 'RSI Scaled', color=f_rsiCol, linewidth=1)
  170. pm = plot(50 * scaleRSI, 'RSI Mid', color=f_rsiCol, linewidth=1)
  171. fill(p2, pm, color=color.new(f_rsiCol, 85), title='Background', transp=90)
  172.  
  173. // Trade signals per RSI
  174. pine_rsi_prev(x, y) =>
  175. u = math.max(x[1] - x[2], 0)
  176. d = math.max(x[2] - x[1], 0)
  177. rs = ta.rma(u, y) / ta.rma(d, y)
  178. res = 100 - 100 / (1 + rs)
  179. res
  180.  
  181. isRedCandle = close < open
  182. isGreenCandle = close > open
  183.  
  184. prevCandleIsRed = close[1] < open[1]
  185. prevCandleIsGreen = open[1] < close[1]
  186.  
  187. isRsiUnder_osRSI = pine_rsi_prev(close, 14) < 30
  188. isRsiOver_obRSI = pine_rsi_prev(close, 14) > 70
  189.  
  190. enterCallTrade = isGreenCandle and prevCandleIsRed and isRsiUnder_osRSI and flagRSI
  191. enterPutTrade = isRedCandle and prevCandleIsGreen and isRsiOver_obRSI and flagRSI
  192.  
  193. plotshape(enterCallTrade, title='Buy Flag', text=' ', textcolor=c_white, color=c_green90, style=shape.triangleup, size=size.tiny, location=location.bottom, editable=false)
  194. plotshape(enterPutTrade, title='Sell Flag', text=' ', textcolor=c_white, color=c_red90, style=shape.triangledown, size=size.tiny, location=location.top, editable=false)
  195. plotshape(enterCallTrade and txtRSI, title='Buy Text', text='OS Call', textcolor=c_white, color=c_green90, style=shape.triangleup, size=size.tiny, location=location.bottom, editable=false)
  196. plotshape(enterPutTrade and txtRSI, title='Sell Text', text='OB Put', textcolor=c_white, color=c_red90, style=shape.triangledown, size=size.tiny, location=location.top, editable=false)
  197.  
  198. // Divergence Indicator
  199.  
  200. //study(title="Divergence Indicator", format=format.price, resolution="")
  201.  
  202. lbR = input(title='Pivot Lookback Right', defval=5)
  203. lbL = input(title='Pivot Lookback Left', defval=5)
  204. rangeUpper = input(title='Max of Lookback Range', defval=60)
  205. rangeLower = input(title='Min of Lookback Range', defval=5)
  206. plotBull = input(title='Plot Bullish', defval=true)
  207. plotHiddenBull = input(title='Plot Hidden Bullish', defval=false)
  208. plotBear = input(title='Plot Bearish', defval=true)
  209. plotHiddenBear = input(title='Plot Hidden Bearish', defval=false)
  210.  
  211. bearColor = c_red
  212. bullColor = c_green
  213. hiddenBullColor = color.new(c_green, 80)
  214. hiddenBearColor = color.new(c_red, 80)
  215. textColor = c_white
  216. noneColor = color.new(c_white, 100)
  217.  
  218. osc = ta.rsi(src, lenm)
  219. plot(osc * scaleRSI, title='RSI Do not show', linewidth=2, color=color.new(#2962FF, 0), display=display.none)
  220.  
  221. plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true
  222. phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true
  223. _inRange(cond) =>
  224. bars = ta.barssince(cond == true)
  225. rangeLower <= bars and bars <= rangeUpper
  226.  
  227. //------------------------------------------------------------------------------
  228. // Regular Bullish
  229. // Osc: Higher Low
  230.  
  231. oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
  232.  
  233. // Price: Lower Low
  234.  
  235. priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1)
  236. bullCond = plotBull and priceLL and oscHL and plFound
  237.  
  238. plot(plFound ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond ? bullColor : noneColor)
  239.  
  240. plotshape(bullCond ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Regular Bullish Label', text=' Bull ', style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor)
  241.  
  242. //------------------------------------------------------------------------------
  243. // Hidden Bullish
  244. // Osc: Lower Low
  245.  
  246. oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
  247.  
  248. // Price: Higher Low
  249.  
  250. priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1)
  251. hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
  252.  
  253. plot(plFound ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond ? hiddenBullColor : noneColor)
  254.  
  255. plotshape(hiddenBullCond ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Hidden Bullish Label', text=' H Bull ', style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor)
  256.  
  257. //------------------------------------------------------------------------------
  258. // Regular Bearish
  259. // Osc: Lower High
  260.  
  261. oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
  262.  
  263. // Price: Higher High
  264.  
  265. priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1)
  266.  
  267. bearCond = plotBear and priceHH and oscLH and phFound
  268.  
  269. plot(phFound ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Regular Bearish', linewidth=2, color=bearCond ? bearColor : noneColor)
  270.  
  271. plotshape(bearCond ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Regular Bearish Label', text=' Bear ', style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor)
  272.  
  273. //------------------------------------------------------------------------------
  274. // Hidden Bearish
  275. // Osc: Higher High
  276.  
  277. oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
  278.  
  279. // Price: Lower High
  280.  
  281. priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1)
  282.  
  283. hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound
  284.  
  285. plot(phFound ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Hidden Bearish', linewidth=2, color=hiddenBearCond ? hiddenBearColor : noneColor)
  286.  
  287. plotshape(hiddenBearCond ? osc[lbR] * scaleRSI : na, offset=-lbR, title='Hidden Bearish Label', text=' H Bear ', style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor)
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
Advertisement
Add Comment
Please, Sign In to add comment