Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Merged Script [LuxAlgo + CDC ActionZone]", overlay=true, max_lines_count=500, max_labels_count=500, max_bars_back=500, precision=6)
- //------------------------------------------------------------------------------
- // LuxAlgo Nadaraya-Watson Envelope - Begin
- //------------------------------------------------------------------------------
- h = input.float(8.0, title='Bandwidth', minval=0)
- mult = input.float(3.0, title='Multiplier', minval=0)
- src = input(close, title='Source')
- repaint = input(true, 'Repainting Smoothing', tooltip='Repainting is an effect where the indicator\'s historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations')
- upCss = input(color.teal, 'Colors', inline='inline1', group='Style')
- dnCss = input(color.red, '', inline='inline1', group='Style')
- gauss(x, h) => math.exp(-math.pow(x, 2) / (math.pow(h, 2) * 2))
- var ln = array.new_line(0)
- if (barstate.isfirst and repaint)
- for i = 0 to 499
- array.push(ln, line.new(na, na, na, na))
- var coefs = array.new_float(0)
- var den = 0.0
- if (barstate.isfirst and not repaint)
- for i = 0 to 499
- w = gauss(i, h)
- array.push(coefs, w)
- den := array.sum(coefs)
- out = 0.0
- if (not repaint)
- for i = 0 to 499
- out := out + src[i] * array.get(coefs, i)
- out := out / den
- mae = ta.sma(math.abs(src - out), 499) * mult
- upper = out + mae
- lower = out - mae
- var float y2 = na
- var float y1 = na
- nwe = array.new_float(0)
- if (barstate.islast and repaint)
- sae = 0.0
- for i = 0 to math.min(499, bar_index - 1)
- sum = 0.0
- sumw = 0.0
- for j = 0 to math.min(499, bar_index - 1)
- w = gauss(i - j, h)
- sum := sum + src[j] * w
- sumw := sumw + w
- y2 := sum / sumw
- sae := sae + math.abs(src[i] - y2)
- array.push(nwe, y2)
- sae := sae / math.min(499, bar_index - 1) * mult
- for i = 0 to math.min(499, bar_index - 1)
- if i % 2
- line.new(bar_index - i + 1, y1 + sae, bar_index - i, array.get(nwe, i) + sae, color=upCss)
- line.new(bar_index - i + 1, y1 - sae, bar_index - i, array.get(nwe, i) - sae, color=dnCss)
- if src[i] > array.get(nwe, i) + sae and src[i + 1] < array.get(nwe, i) + sae
- label.new(bar_index - i, src[i], '▼', color=color(na), style=label.style_label_down, textcolor=dnCss, textalign=text.align_center)
- if src[i] < array.get(nwe, i) - sae and src[i + 1] > array.get(nwe, i) - sae
- label.new(bar_index - i, src[i], '▲', color=color(na), style=label.style_label_up, textcolor=upCss, textalign=text.align_center)
- y1 := array.get(nwe, i)
- var tb = table.new(position.top_right, 1, 1, bgcolor=#1e222d, border_color=#373a46, border_width=1, frame_color=#373a46, frame_width=1)
- if (repaint)
- tb.cell(0, 0, 'Repainting Mode Enabled', text_color=color.white, text_size=size.small)
- plot(repaint ? na : out + mae, 'Upper', upCss)
- plot(repaint ? na : out - mae, 'Lower', dnCss)
- plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0, text='▲', textcolor=upCss, size=size.tiny)
- plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0, text='▼', textcolor=dnCss, size=size.tiny)
- //------------------------------------------------------------------------------
- // LuxAlgo Nadaraya-Watson Envelope - End
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- // CDC ActionZone V3 2020 Optimized - Begin
- //------------------------------------------------------------------------------
- xsrc = input(close, title='Source Data')
- xprd1 = input(12, title='Fast EMA period')
- xprd2 = input(26, title='Slow EMA period')
- xsmooth = input(1, title='Smoothing period (1 = no smoothing)')
- fillSW = input(true, title='Paint Bar Colors')
- fastSW = input(true, title='Show fast moving average line')
- slowSW = input(true, title='Show slow moving average line')
- labelSwitch = input(true, title='Turn on assistive text')
- plotSigsw = input(true, title='Plot Buy/Sell Signals?')
- plotRibsw = input(false, title='Plot Buy/Sell Ribbon')
- plotRibbonPos = input('Top', title='Ribbon Position')
- plotRibbonPos := plotRibbonPos == 'Top' ? 'Top' : plotRibbonPos == 'Bottom' ? 'Bottom' : na
- plotSig2sw = input(false, title='Plot momentum-based Buy/Sell Signals?')
- plotSig2lv = input(1, title='Set signal threshold (higher = stricter)')
- FastMA = ta.ema(xsrc, xprd1)
- SlowMA = ta.ema(xsrc, xprd2)
- Bull = FastMA > SlowMA
- Bear = FastMA < SlowMA
- Green = Bull and close > FastMA
- Blue = Bear and close > FastMA and close > SlowMA
- LBlue = Bear and close > FastMA and close < SlowMA
- Red = Bear and close < FastMA
- Orange = Bull and close < FastMA and close < SlowMA
- Yellow = Bull and close < FastMA and close > SlowMA
- bColor = Green ? color.green : Blue ? color.blue : LBlue ? color.aqua : Red ? color.red : Orange ? color.orange : Yellow ? color.yellow : color.black
- barcolor(fillSW ? bColor : na)
- FastL = plot(fastSW ? FastMA : na, 'Fast EMA', color=color.red, linewidth=1, style=plot.style_stepline)
- SlowL = plot(slowSW ? SlowMA : na, 'Slow EMA', color=color.blue, linewidth=1, style=plot.style_stepline)
- fill(FastL, SlowL, Bull ? color.new(color.green, 90) : Bear ? color.new(color.red, 90) : color.new(color.black, 90))
- buycond = Green and Green[1] == 0
- sellcond = Red and Red[1] == 0
- bullish = ta.barssince(buycond) < ta.barssince(sellcond)
- bearish = ta.barssince(sellcond) < ta.barssince(buycond)
- buy = bearish[1] and buycond
- sell = bullish[1] and sellcond
- bColor_BullBear = bullish ? color.green : bearish ? color.red : color.black
- plotshape(plotSigsw ? buy : na, style=shape.circle, title='Buy Signal', location=location.belowbar, color=color.new(color.green, 0))
- plotshape(plotSigsw ? sell : na, style=shape.circle, title='Sell Signal', location=location.abovebar, color=color.new(color.red, 0))
- plotshape(plotRibsw ? plotRibbonPos == 'Top' ? close : na : na, style=shape.square, title='Buy/Sell Ribbon', location=location.top, color=bColor_BullBear)
- plotshape(plotRibsw ? plotRibbonPos == 'Bottom' ? close : na : na, style=shape.square, title='Buy/Sell Ribbon', location=location.bottom, color=bColor_BullBear)
- labelstyle = close > SlowMA ? label.style_label_down : label.style_label_up
- labelyloc = close > SlowMA ? yloc.abovebar : yloc.belowbar
- labeltcolor = buy ? color.black : sell ? color.white : close > close[1] ? color.green : color.red
- labelbgcolor = buy ? color.green : sell ? color.red : color.silver
- labeltext = buy ? 'BUY next bar\n' : sell ? 'SELL next bar\n' : ' '
- trendText = bullish ? 'bullish' : bearish ? 'bearish' : 'sideways'
- l1 = label.new(bar_index, na, text=labeltext + syminfo.ticker + ' ' + str.tostring(close) + ' ' + syminfo.currency + '\n currently in a ' + trendText + ' trend \n', color=labelbgcolor, textcolor=labeltcolor, yloc=labelyloc, style=labelstyle)
- label.delete(labelSwitch ? l1[1] : l1)
- rsi1 = ta.rsi(close, 14)
- k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, 14), 3)
- d = ta.sma(k, 3)
- crossover_1 = ta.crossover(k, d)
- crossover_2 = ta.crossover(k, d)
- iff_1 = d > 30 and crossover_2 ? 1 : 0
- iff_2 = d < 30 and crossover_1 ? 2 : iff_1
- storsiBuySig = bullish ? iff_2 : 0
- crossunder_1 = ta.crossunder(k, d)
- crossunder_2 = ta.crossunder(k, d)
- iff_3 = d < 70 and crossunder_2 ? 1 : 0
- iff_4 = d > 70 and crossunder_1 ? 2 : iff_3
- storsiSellSig = bearish ? iff_4 : 0
- plotshape(plotSig2sw ? storsiBuySig > plotSig2lv ? storsiBuySig : na : na, 'Buy more signals', style=shape.triangleup, location=location.belowbar, color=color.new(color.teal, 0))
- plotshape(plotSig2sw ? storsiSellSig > plotSig2lv ? storsiSellSig : na : na, 'Sell more signals', style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0))
- alertcondition(buy, title='*Buy Alert', message='Buy {{exchange}}:{{ticker}}')
- alertcondition(sell, title='*Sell Alert', message='Sell {{exchange}}:{{ticker}}')
- alertcondition(bullish, title='is Bullish')
- alertcondition(bearish, title='is Bearish')
- alertcondition(Green, title='is Green')
- alertcondition(Blue, title='is Blue (Strong Rally)')
- alertcondition(LBlue, title='is Light Blue (Rally)')
- alertcondition(Red, title='is Red')
- alertcondition(Orange, title='is Orange (Strong Dip)')
- alertcondition(Yellow, title='is Yellow (Dip)')
- //------------------------------------------------------------------------------
- // CDC ActionZone V3 2020 Optimized - End
- //------------------------------------------------------------------------------
Advertisement
Comments
-
- download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement