Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title="M C B ", shorttitle="M C B ")
- // FUNCTIONS {
- // MA Selector
- ma(matype, src, length) =>
- if matype == "RMA"
- rma(src, length)
- else
- if matype == "SMA"
- sma(src, length)
- else
- if matype == "EMA"
- ema(src, length)
- else
- if matype == "WMA"
- wma(src, length)
- else
- src
- // } FUNCTIONS
- // PARAMETERS {
- // WaveTrend Channel Length
- n1 = input(7, "WT Channel Length")
- // WaveTrend Average Length
- n2 = input(14, "WT Average Length")
- // WaveTrend MA Params
- wtMA = input(defval="EMA", title="WT MA Type", options=["RMA", "SMA", "EMA", "WMA"])
- wtMA1 = input(defval="EMA", title="WT MA Type 1", options=["RMA", "SMA", "EMA", "WMA"])
- wtMA2 = input(defval="WMA", title="WT MA Type 2", options=["RMA", "SMA", "EMA", "WMA"])
- wtMA3 = input(defval="SMA", title="WT MA Type 3", options=["RMA", "SMA", "EMA", "WMA"])
- wtMA4 = input(defval="EMA", title="WT MA Type 4", options=["RMA", "SMA", "EMA", "WMA"])
- wtMA5 = input(defval="WMA", title="WT MA Type 5", options=["RMA", "SMA", "EMA", "WMA"])
- // WaveTrend Overbought & Oversold lines
- obLevel = input(53, "WT Overbought Level 1")
- obLevel2 = input(60, "WT Overbought Level 2")
- obLevel3 = input(38.2, "WT Overbought Level 3 (fib)")
- obLevel4 = input(61.8, "WT Overbought Level 4 (fib)")
- osLevel = input(-53, "WT Oversold Level 1")
- osLevel2 = input(-60, "WT Oversold Level 2")
- osLevel3 = input(-80, "WT Oversold Level 3")
- osLevel4 = input(-38.2, "WT Oversold Level 4 (fib")
- osLevel5 = input(61.8, "WT Oversold Level 5 (fib")
- // WaveTrend MA Source
- AP=input(hlc3, "source",type=input.source)
- useHA=input(true,"Use heikin ashi candles?")
- ha_AP=security(heikinashi(syminfo.tickerid), timeframe.period, AP)
- ap = useHA?ha_AP:AP
- //ap = input(ohlc4, "WaveTrend MA Source")
- // WaveTrend MA Length
- sp = input(3, "WaveTrend MA Length 1")
- sp1 = input(8, "WaveTrend MA Length 2")
- sp2 = input(13, "WaveTrend MA Length 3")
- // RSI Divergence detector ranges
- bearish_div_rsi = input(60, "Min Bearish RSI", input.integer, minval=50, maxval=100)
- bullish_div_rsi = input(30, "Max Bullish RSI", input.integer, minval=0, maxval=50)
- // RSI+MFI Period
- rsiMFIperiod = input(72, "RSI+MFI Period")
- //RSI+MFI Area multiplier
- rsiMFIMultiplier = input(100, "RSI+MFI Area multiplier")
- // Colors
- colorRed = #ff0000
- colorPurple = #da00ff
- colorGreen = #03ff00
- colorOrange = color.orange
- // Divergence WT
- WTDivOBLevel = input(55)
- WTDivOSLevel = input(-60)
- // Divergence RSI
- RSIDivOBLevel = input(60)
- RSIDivOSLevel = input(40)
- // } PARAMETERS
- // CALCULATE INDICATORS {
- // RSI + MFI Area
- candleValue = (close - open) / (high - low)
- MVC = vwma(candleValue, rsiMFIperiod)
- color_area = MVC > 0 ? color.green : color.red
- // RSI
- up = rma(max(change(close), 0), 14)
- down = rma(-min(change(close), 0), 14)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
- rsiColor = rsi < bullish_div_rsi ? color.green : rsi > bearish_div_rsi ? color.red : color.purple
- out = ema(rsi,14)
- plot(out, color=color.yellow)
- // Calculates WaveTrend
- //useHA=input(true,"Use heikin ashi candles?")
- //ha_AP=security(heikinashi(tickerid), period, AP)
- //ap = useHA?ha_AP:AP
- esa = ma(wtMA, ap, n1)
- de = ma(wtMA1, abs(ap - esa), n1)
- ci = (ap - esa) / (0.015 * de)
- tci = ma(wtMA2, ci, n2)
- wt1 = tci
- wt2 = ma(wtMA3, wt1, sp)
- wt3 = ma(wtMA4, wt1, sp1)
- wt4 = ma(wtMA5, wt1, sp2)
- // VWAP
- vwap_area = wt1 - wt2
- // WaveTrend Conditions
- WTCross = cross(wt1, wt2)
- WTCrossUp = wt2 - wt1 <= 0
- WTCrossDown = wt2 - wt1 >= 0
- WTOverSold = wt2 <= osLevel
- WTOverBought = wt2 >= obLevel
- WTGoldBuy = wt2 <= osLevel3
- // Godmode
- extended = wt2<-75 ? wt2-5 : na//? wt2+5 : wt2>75 ? wt2-5 : na
- extended2 = wt2<20// ? wt2+5 : wt2>80 ? wt2-5 : na
- extended3 = wt2>85 ? wt2+5 : na// ? wt2+5 : wt2>85 ? wt2-5 : na
- bgcolor(color=extended ? #008C8C : na, transp=90)
- //bgcolor(color=extended2 ? yellow : na, transp=90)
- bgcolor(color=extended3 ? #B20000 : na, transp=80)
- //DIVERGENCE
- f_top_fractal(_src) => _src[4] < _src[2] and _src[3] < _src[2] and _src[2] > _src[1] and _src[2] > _src[0]
- f_bot_fractal(_src) => _src[4] > _src[2] and _src[3] > _src[2] and _src[2] < _src[1] and _src[2] < _src[0]
- f_fractalize(_src) => f_top_fractal(_src) ? 1 : f_bot_fractal(_src) ? -1 : 0
- //DIVERGENCE WAVETREND
- WTFractal_top = f_fractalize(wt2) > 0 and wt2[2] >= WTDivOBLevel ? wt2[2] : na
- WTFractal_bot = f_fractalize(wt2) < 0 and wt2[2] <= WTDivOSLevel ? wt2[2] : na
- WTHigh_prev = valuewhen(WTFractal_top, wt2[2], 0)[2]
- WTHigh_price = valuewhen(WTFractal_top, high[2], 0)[2]
- WTLow_prev = valuewhen(WTFractal_bot, wt2[2], 0)[2]
- WTLow_price = valuewhen(WTFractal_bot, low[2], 0)[2]
- WTRegular_bearish_div = WTFractal_top and high[2] > WTHigh_price and wt2[2] < WTHigh_prev
- WTRegular_bullish_div = WTFractal_bot and low[2] < WTLow_price and wt2[2] > WTLow_prev
- bearWTSignal = WTRegular_bearish_div and WTCrossDown
- bullWTSignal = WTRegular_bullish_div and WTCrossUp
- WTCol1 = bearWTSignal ? color.red : na
- WTCol2 = bullWTSignal ? #00FF00EB : na
- //DIVERGENCE RSI
- RSIFractal_top = f_fractalize(rsi) > 0 and rsi[2] >= RSIDivOBLevel ? rsi[2] : na
- RSIFractal_bot = f_fractalize(rsi) < 0 and rsi[2] <= RSIDivOSLevel ? rsi[2] : na
- RSIHigh_prev = valuewhen(RSIFractal_top, rsi[2], 0)[2]
- RSIHigh_price = valuewhen(RSIFractal_top, high[2], 0)[2]
- RSILow_prev = valuewhen(RSIFractal_bot, rsi[2], 0)[2]
- RSILow_price = valuewhen(RSIFractal_bot, low[2], 0)[2]
- bearRSISignal = RSIFractal_top and high[2] > RSIHigh_price and rsi[2] < RSIHigh_prev
- bullRSISignal = RSIFractal_bot and low[2] < RSILow_price and rsi[2] > RSILow_prev
- RSICol1 = bearRSISignal ? #ff0000: na
- RSICol2 = bullRSISignal ? #00FF00EB : na
- // Small Circles WT Cross
- signalColor = wt2 - wt1 > 0 ? color.red : color.lime
- // Buy signal
- buySignal = WTCross and WTCrossUp and WTOverSold
- bigBuySignal = cross(wt1[2], wt2[2]) and WTCrossUp and (bullRSISignal or bullWTSignal)
- buySignalColor = bigBuySignal ? colorPurple : buySignal ? colorGreen : na
- plotBuy = bigBuySignal ? bigBuySignal : buySignal
- // Sell signal
- sellSignal = WTCross and WTCrossDown and WTOverBought
- bigSellSignal = cross(wt1[2], wt2[2]) and WTCrossDown and (bearRSISignal or bearWTSignal)
- sellSignalColor = bigSellSignal ? colorPurple : sellSignal ? colorRed : na
- plotSell = bigSellSignal ? bigSellSignal : sellSignal
- // Gold Buy
- plotWTGoldBuy = WTCross and WTCrossUp and WTGoldBuy
- // } CALCULATE INDICATORS
- // DRAW {
- // 0 Line
- plot(0, title="0 Line", color=color.gray)
- // Draw Overbought & Oversold lines
- plot(obLevel, title="Over Bought Level 1", color=color.gray, linewidth=2, style=plot.style_stepline, transp=15)
- plot(obLevel2, title="Over Bought Level 2", color=color.gray, style=plot.style_cross, transp=60)
- plot(osLevel, title="Over Sold Level 1", color=color.gray, linewidth=2, style=plot.style_stepline, transp=15)
- plot(osLevel2, title="Over Sold Level 2", color=color.gray, style=plot.style_cross, transp=60)
- plot(obLevel3, title="Overbought Level 3", color=#00FFAA, style=plot.style_line, transp=70)
- plot(obLevel4, title="Overbought Level 4", color=#00FFFF, style=plot.style_line, transp=70)
- plot(osLevel4, title="Oversold Level 4", color=#00FFAA, style=plot.style_line, transp=70)
- plot(osLevel5, title="Oversold Level 5", color=#00FFFF, style=plot.style_line, transp=70)
- // DIVERGENCES
- plot(series = WTFractal_top ? wt2[2] : na, title='Bearish Divergence', color=WTCol1, linewidth=2, transp=40)
- plot(series = WTFractal_bot ? wt2[2] : na, title='Bullish Divergence', color=WTCol2, linewidth=2, transp=40)
- plot(series = RSIFractal_top ? rsi[2] : na, title='Bearish Divergence', color=RSICol1, linewidth=2, transp=40)
- plot(series = RSIFractal_bot ? rsi[2] : na, title='Bullish Divergence', color=RSICol2, linewidth=2, transp=40)
- // RSI
- plot(rsi, title="RSI", color=rsiColor, linewidth=1, transp=35)
- // RSI + MFI AREA
- RSIMFIplot = plot(MVC * rsiMFIMultiplier, title="RSI+MFI Area", color=color_area, transp=35)
- fill(RSIMFIplot, plot(0), color_area, transp=35)
- // RSI + MFI BAR
- rsimfiBarTopLine = plot(-85, title="RSI+MFI Bar TOP Line", color=color.black, transp=60)
- rsimfiBarBottomLine = plot(-95, title="RSI+MFI Bar BOTTOM Line", color=color.black, transp=60)
- fill(rsimfiBarTopLine, rsimfiBarBottomLine, color=color_area)
- // WT Area 1
- plot(wt1, style=plot.style_area, title="WT Wave 1", color=#0ae6ff, transp=10)
- // WT Area 2
- plot(wt2, style=plot.style_area, title="WT Wave 2", color=#0042ff, transp=10)
- // WT line 3 (Yewel pink)
- plot(wt3, style=plot.style_line, title="WT Wave 3", color=#D900D9, transp=0, linewidth=2)
- // WT line 4 (Yewel yellow)
- plot(wt4, style=plot.style_line, title="WT Wave 4", color=#FFFF00, transp=0, linewidth=2)
- // VWAP
- plot(vwap_area, title="VWAP", color=color.yellow, style=plot.style_area, transp=35)
- plot(WTCross ? wt2 : na, title="Buy and sell signals", color=signalColor, style=plot.style_circles, linewidth=3, transp=55) // CIRCULOS PEQUEÑOS
- plot(plotBuy ? -90 : na, title="Big buy signal", color=buySignalColor, style=plot.style_circles, linewidth=4, transp=0) // SEÑAL DE COMPRA CIRCULO VERDE GRANDE
- plot(plotSell ? 90 : na, title="Big short signal", color=sellSignalColor, style=plot.style_circles, linewidth=4, transp=15) // SEÑAL DE VENTA CIRCULO ROJO GRANDE
- plot(plotWTGoldBuy ? -110 : na, title="Big short signal", color=color.orange, style=plot.style_circles, linewidth=4, transp=15) // SEÑAL DE VENTA CIRCULO ROJO GRANDE
- // } DRAW
- // ALERTS {
- // BUY
- alertcondition(plotBuy != 0, "Buy Signal (Big green circle)", "Green circle WaveTrend Oversold")
- alertcondition(bigBuySignal != 0, "Buy Signal (Big green circle + Div)", "Buy signal & WT Bullish Divergence & WT Overbought ")
- alertcondition(plotWTGoldBuy != 0, "GOLD Buy Signal (Big GOLDEN circle)", "Green & GOLD circle WaveTrend Overbought")
- // SELL
- alertcondition(plotSell != 0, "Sell Signal (Big red circle)", "Red Circle WaveTrend Overbought")
- alertcondition(bigSellSignal != 0, "Sell Signal (Big red circle + Div)", "Buy signal & WT Bearish Divergence & WT Overbought ")
- // } ALERTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement