// Thanks to dynausmaux for the code..
// Thanks to falconCoin for https://www.tradingview.com/script/KVfgBvDd-Market-Cipher-B-Free-version-with-Buy-and-sell/ inspired me to start this.
// Thanks to LazyBear for WaveTrend Oscillator https://www.tradingview.com/script/2KE8wTuF-Indicator-WaveTrend-Oscillator-WT/
// Thanks to RicardoSantos for https://www.tradingview.com/script/3oeDh0Yq-RS-Price-Divergence-Detector-V2/
// Thanks to LucemAnb for Plain Stochastic Divergence https://www.tradingview.com/script/FCUgF8ag-Plain-Stochastic-Divergence/
// Thanks to andreholanda73 for MFI+RSI Area https://www.tradingview.com/script/UlGZzUAr/
// I especially thanks to TradingView for its platform that facilitates development and learning.
//
// CIRCLES & TRIANGLES:
// - LITTLE CIRCLE: They appear at all WaveTrend wave crossings.
// - GREEN CIRCLE: The wavetrend waves are at the oversold level and have crossed up (bullish).
// - RED CIRCLE: The wavetrend waves are at the overbought level and have crossed down (bearish).
// - GOLD/ORANGE CIRCLE: When RSI is below 20, WaveTrend waves are below or equal to -80 and have crossed up after good bullish divergence (DONT BUY WHEN GOLD CIRCLE APPEAR).
// - None of these circles are certain signs to trade. It is only information that can help you.
// - PURPLE TRIANGLE: Appear when a bullish or bearish divergence is formed and WaveTrend waves crosses at overbought and oversold points.
//
// NOTES:
// - I am not an expert trader or know how to program pine script as such, in fact it is my first indicator only to study and all the code is copied and modified from other codes that are published in TradingView.
// - I am very grateful to the entire TV community that publishes codes so that other newbies like me can learn and present their results. This is an attempt to imitate Market Cipher B.
// - Settings by default are for 4h timeframe, divergences are more stronger and accurate. Haven't tested in all timeframes, only 2h and 4h.
// - If you get an interesting result in other timeframes I would be very grateful if you would comment your configuration to implement it or at least check it.
//
// CONTRIBUTIONS:
// - Tip/Idea: Add higher timeframe analysis for bearish/bullish patterns at the current timeframe.
// + Bearish/Bullish FLAG:
// - MFI+RSI Area are RED (Below 0).
// - Wavetrend waves are above 0 and crosses down.
// - VWAP Area are below 0 on higher timeframe.
// - This pattern reversed becomes bullish.
// - Tip/Idea: Check the last heikinashi candle from 2 higher timeframe
// + Bearish/Bullish DIAMOND:
// - HT Candle is red
// - WT > 0 and crossed down
Assistant
Bu kodu işlev ve fonksiyonlarına göre 17 parçaya ayırabiliriz.
study(title = 'VuManChu B Divergences', shorttitle = 'VMC Cipher_B_Divergences')
// PARAMETERS {
// WaveTrend
wtShow = input(true, title = 'Show WaveTrend', type = input.bool, group = 'WaveTrend Settings')
wtBuyShow = input(true, title = 'Show Buy dots', type = input.bool, group = 'WaveTrend Settings')
wtGoldShow = input(true, title = 'Show Gold dots', type = input.bool, group = 'WaveTrend Settings')
wtSellShow = input(true, title = 'Show Sell dots', type = input.bool, group = 'WaveTrend Settings')
wtDivShow = input(true, title = 'Show Div. dots', type = input.bool, group = 'WaveTrend Settings')
vwapShow = input(true, title = 'Show Fast WT', type = input.bool, group = 'WaveTrend Settings')
wtChannelLen = input(9, title = 'WT Channel Length', type = input.integer, group = 'WaveTrend Settings')
wtAverageLen = input(12, title = 'WT Average Length', type = input.integer, group = 'WaveTrend Settings')
wtMASource = input(hlc3, title = 'WT MA Source', type = input.source, group = 'WaveTrend Settings')
wtMALen = input(3, title = 'WT MA Length', type = input.integer, group = 'WaveTrend Settings')
// WaveTrend Overbought & Oversold lines
obLevel = input(53, title = 'WT Overbought Level 1', type = input.integer, group = 'WaveTrend Settings')
obLevel2 = input(60, title = 'WT Overbought Level 2', type = input.integer, group = 'WaveTrend Settings')
obLevel3 = input(100, title = 'WT Overbought Level 3', type = input.integer, group = 'WaveTrend Settings')
osLevel = input(-53, title = 'WT Oversold Level 1', type = input.integer, group = 'WaveTrend Settings')
osLevel2 = input(-60, title = 'WT Oversold Level 2', type = input.integer, group = 'WaveTrend Settings')
osLevel3 = input(-75, title = 'WT Oversold Level 3', type = input.integer, group = 'WaveTrend Settings')
// Divergence WT
wtShowDiv = input(true, title = 'Show WT Regular Divergences', type = input.bool, group = 'WaveTrend Settings')
wtShowHiddenDiv = input(false, title = 'Show WT Hidden Divergences', type = input.bool, group = 'WaveTrend Settings')
showHiddenDiv_nl = input(true, title = 'Not apply OB/OS Limits on Hidden Divergences', type = input.bool, group = 'WaveTrend Settings')
wtDivOBLevel = input(45, title = 'WT Bearish Divergence min', type = input.integer, group = 'WaveTrend Settings')
wtDivOSLevel = input(-65, title = 'WT Bullish Divergence min', type = input.integer, group = 'WaveTrend Settings')
// Divergence extra range
wtDivOBLevel_addshow = input(true, title = 'Show 2nd WT Regular Divergences', type = input.bool, group = 'WaveTrend Settings')
wtDivOBLevel_add = input(15, title = 'WT 2nd Bearish Divergence', type = input.integer, group = 'WaveTrend Settings')
wtDivOSLevel_add = input(-40, title = 'WT 2nd Bullish Divergence 15 min', type = input.integer, group = 'WaveTrend Settings')
// RSI+MFI
rsiMFIShow = input(true, title = 'Show MFI', type = input.bool, group = 'MFI Settings')
rsiMFIperiod = input(60,title = 'MFI Period', type = input.integer, group = 'MFI Settings')
rsiMFIMultiplier = input(150, title = 'MFI Area multiplier', type = input.float, group = 'MFI Settings')
rsiMFIPosY = input(2.5, title = 'MFI Area Y Pos', type = input.float, group = 'MFI Settings')
// RSI
rsiShow = input(true, title = 'Show RSI', type = input.bool, group = 'RSI Settings')
rsiSRC = input(close, title = 'RSI Source', type = input.source, group = 'RSI Settings')
rsiLen = input(14, title = 'RSI Length', type = input.integer, group = 'RSI Settings')
rsiOversold = input(30, title = 'RSI Oversold', minval = 50, maxval = 100, type = input.integer, group = 'RSI Settings')
rsiOverbought = input(60, title = 'RSI Overbought', minval = 0, maxval = 50, type = input.integer, group = 'RSI Settings')
// Divergence RSI
rsiShowDiv = input(false, title = 'Show RSI Regular Divergences', type = input.bool, group = 'RSI Settings')
rsiShowHiddenDiv = input(false, title = 'Show RSI Hidden Divergences', type = input.bool, group = 'RSI Settings')
rsiDivOBLevel = input(60, title = 'RSI Bearish Divergence min', type = input.integer, group = 'RSI Settings')
rsiDivOSLevel = input(30, title = 'RSI Bullish Divergence min', type = input.integer, group = 'RSI Settings')
// RSI Stochastic
stochShow = input(true, title = 'Show Stochastic RSI', type = input.bool, group = 'Stoch Settings')
stochUseLog = input(true, title=' Use Log?', type = input.bool, group = 'Stoch Settings')
stochAvg = input(false, title='Use Average of both K & D', type = input.bool, group = 'Stoch Settings')
stochSRC = input(close, title = 'Stochastic RSI Source', type = input.source, group = 'Stoch Settings')
stochLen = input(14, title = 'Stochastic RSI Length', type = input.integer, group = 'Stoch Settings')
stochRsiLen = input(14, title = 'RSI Length ', type = input.integer, group = 'Stoch Settings')
stochKSmooth = input(3, title = 'Stochastic RSI K Smooth', type = input.integer, group = 'Stoch Settings')
stochDSmooth = input(3, title = 'Stochastic RSI D Smooth', type = input.integer, group = 'Stoch Settings')
// Divergence stoch
stochShowDiv = input(false, title = 'Show Stoch Regular Divergences', type = input.bool, group = 'Stoch Settings')
stochShowHiddenDiv = input(false, title = 'Show Stoch Hidden Divergences', type = input.bool, group = 'Stoch Settings')
// Schaff Trend Cycle
tcLine = input(false, title="Show Schaff TC line", type=input.bool, group = 'Schaff Settings')
tcSRC = input(close, title = 'Schaff TC Source', type = input.source, group = 'Schaff Settings')
tclength = input(10, title="Schaff TC", type=input.integer, group = 'Schaff Settings')
tcfastLength = input(23, title="Schaff TC Fast Lenght", type=input.integer, group = 'Schaff Settings')
tcslowLength = input(50, title="Schaff TC Slow Length", type=input.integer, group = 'Schaff Settings')
tcfactor = input(0.5, title="Schaff TC Factor", type=input.float, group = 'Schaff Settings')
// Sommi Flag
sommiFlagShow = input(false, title = 'Show Sommi flag', type = input.bool, group = 'Sommi Settings')
sommiShowVwap = input(false, title = 'Show Sommi F. Wave', type = input.bool, group = 'Sommi Settings')
sommiVwapTF = input('720', title = 'Sommi F. Wave timeframe', type = input.string, group = 'Sommi Settings')
sommiVwapBearLevel = input(0, title = 'F. Wave Bear Level (less than)', type = input.integer, group = 'Sommi Settings')
sommiVwapBullLevel = input(0, title = 'F. Wave Bull Level (more than)', type = input.integer, group = 'Sommi Settings')
soomiFlagWTBearLevel = input(0, title = 'WT Bear Level (more than)', type = input.integer, group = 'Sommi Settings')
soomiFlagWTBullLevel = input(0, title = 'WT Bull Level (less than)', type = input.integer, group = 'Sommi Settings')
soomiRSIMFIBearLevel = input(0, title = 'Money flow Bear Level (less than)', type = input.integer, group = 'Sommi Settings')
soomiRSIMFIBullLevel = input(0, title = 'Money flow Bull Level (more than)', type = input.integer, group = 'Sommi Settings')
// Sommi Diamond
sommiDiamondShow = input(false, title = 'Show Sommi diamond', type = input.bool, group = 'Sommi Settings')
sommiHTCRes = input('60', title = 'HTF Candle Res. 1', type = input.string, group = 'Sommi Settings')
sommiHTCRes2 = input('240', title = 'HTF Candle Res. 2', type = input.string, group = 'Sommi Settings')
soomiDiamondWTBearLevel = input(0, title = 'WT Bear Level (More than)', type = input.integer, group = 'Sommi Settings')
soomiDiamondWTBullLevel = input(0, title = 'WT Bull Level (Less than)', type = input.integer, group = 'Sommi Settings')
// macd Colors
macdWTColorsShow = input(false, title = 'Show MACD Colors', type = input.bool, group = 'MACD Settings')
macdWTColorsTF = input('240', title = 'MACD Colors MACD TF', type = input.string, group = 'MACD Settings')
darkMode = input(false, title = 'Dark mode', type = input.bool, group = 'Mode Settings')
bearPattern = rsimfi < soomiRSIMFIBearLevel and
wt2 > soomiFlagWTBearLevel and
wtCross and
wtCrossDown and
hwtVwap < sommiVwapBearLevel
bullPattern = rsimfi > soomiRSIMFIBullLevel and
wt2 < soomiFlagWTBullLevel and
wtCross and
wtCrossUp and
hwtVwap > sommiVwapBullLevel
[bearPattern, bullPattern, hwtVwap]
content_copy
Use code with caution.
f_findSommiDiamond(tf, tf2, wt1, wt2, wtCross, wtCrossUp, wtCrossDown) =>
[candleBodyDir, newBar] = f_getTFCandle(tf)
[candleBodyDir2, newBar2] = f_getTFCandle(tf2)
bearPattern = wt2 >= soomiDiamondWTBearLevel and
wtCross and
wtCrossDown and
not candleBodyDir and
not candleBodyDir2
bullPattern = wt2 <= soomiDiamondWTBullLevel and
wtCross and
wtCrossUp and
candleBodyDir and
candleBodyDir2
[bearPattern, bullPattern]
wtBearDivColor = (wtShowDiv and wtBearDiv) or (wtShowHiddenDiv and wtBearDivHidden_) ? WTBearDivColorDown : na
wtBullDivColor = (wtShowDiv and wtBullDiv) or (wtShowHiddenDiv and wtBullDivHidden_) ? wtBullDivColorUp : na
wtBearDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBearDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBearDivHidden_add)) ? WTBearDivColorDown: na
wtBullDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBullDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBullDivHidden_add)) ? wtBullDivColorUp : na
rsiBearDivColor = (rsiShowDiv and rsiBearDiv) or (rsiShowHiddenDiv and rsiBearDivHidden_) ? rsiBearColor : na
rsiBullDivColor = (rsiShowDiv and rsiBullDiv) or (rsiShowHiddenDiv and rsiBullDivHidden_) ? rsiBullColor : na
stochBearDivColor = (stochShowDiv and stochBearDiv) or (stochShowHiddenDiv and stochBearDivHidden) ? stochbearcolor : na
stochBullDivColor = (stochShowDiv and stochBullDiv) or (stochShowHiddenDiv and stochBullDivHidden) ? stochbullcolor : na
// Small Circles WT Cross
signalcolorup = input(color.new(#00e676, 0), 'WT Buy Dot', group = 'Color Settings')
signalcolordown = input(color.new(#ff5252, 0), 'WT Sell Dot', group = 'Color Settings')
// Gold Buy
lastRsi = valuewhen(wtFractalBot, rsi[2], 0)[2]
wtGoldBuy = ((wtShowDiv and wtBullDiv) or (rsiShowDiv and rsiBullDiv)) and
wtLow_prev <= osLevel3 and
wt2 > osLevel3 and
wtLow_prev - wt2 <= -5 and
lastRsi < 30
//plot(obLevel, title = 'Over Bought Level 1', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 85)
plot(obLevel2, title = 'Over Bought Level 2', color = oblvl2color, linewidth = 1, style = plot.style_stepline, transp = 85)
plot(obLevel3, title = 'Over Bought Level 3', color = oblvl3color, linewidth = 1, style = plot.style_circles, transp = 95)
//plot(osLevel, title = 'Over Sold Level 1', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 85)
plot(osLevel2, title = 'Over Sold Level 2', color = oslvl2color, linewidth = 1, style = plot.style_stepline, transp = 85)
// Sommi flag
plotchar(sommiFlagShow and sommiBearish ? 108 : na, title = 'Sommi bearish flag', char='⚑', color = colorPink, location = location.absolute, size = size.tiny, transp = 0)
plotchar(sommiFlagShow and sommiBullish ? -108 : na, title = 'Sommi bullish flag', char='⚑', color = colorBluelight, location = location.absolute, size = size.tiny, transp = 0)
plot(sommiShowVwap ? ema(hvwap, 3) : na, title = 'Sommi higher VWAP', color = colorYellow, linewidth = 2, style = plot.style_line, transp = 55)
// Sommi diamond
plotchar(sommiDiamondShow and sommiBearishDiamond ? 108 : na, title = 'Sommi bearish diamond', char='◆', color = colorPink, location = location.absolute, size = size.tiny, transp = 0)
plotchar(sommiDiamondShow and sommiBullishDiamond ? -108 : na, title = 'Sommi bullish diamond', char='◆', color = colorBluelight, location = location.absolute, size = size.tiny, transp = 0)
// Circles
plot(wtCross ? wt2 : na, title = 'Buy and sell circle', color = signalColor, style = plot.style_circles, linewidth = 3, transp = 15)
plotchar(wtBuyShow and buySignal ? -107 : na, title = 'Buy circle', char='·', color = colorGreen, location = location.absolute, size = size.small, transp = 50)
plotchar(wtSellShow and sellSignal ? 105 : na , title = 'Sell circle', char='·', color = colorRed, location = location.absolute, size = size.small, transp = 50)
plotchar(wtDivShow and buySignalDiv ? -106 : na, title = 'Divergence buy circle', char='•', color = buySignalDiv_color, location = location.absolute, size = size.small, offset = -2, transp = 15)
plotchar(wtDivShow and sellSignalDiv ? 106 : na, title = 'Divergence sell circle', char='•', color = sellSignalDiv_color, location = location.absolute, size = size.small, offset = -2, transp = 15)
plotchar(wtGoldBuy and wtGoldShow ? -106 : na, title = 'Gold buy gold circle', char='•', color = colorOrange, location = location.absolute, size = size.normal, offset = -2, transp = 15)
// } DRAW
// ALERTS {
// BUY
alertcondition(buySignal, 'Buy (Big green circle)', 'Green circle WaveTrend Oversold')
alertcondition(buySignalDiv, 'Buy (Big green circle + Div)', 'Buy & WT Bullish Divergence & WT Overbought')
alertcondition(wtGoldBuy, 'GOLD Buy (Big GOLDEN circle)', 'Green & GOLD circle WaveTrend Overbought')
alertcondition(sommiBullish or sommiBullishDiamond, 'Sommi bullish flag/diamond', 'Blue flag/diamond')
alertcondition(wtCross and wtCrossUp, 'Buy (Small green dot)', 'Buy small circle')
// SELL
alertcondition(sommiBearish or sommiBearishDiamond, 'Sommi bearish flag/diamond', 'Purple flag/diamond')
alertcondition(sellSignal, 'Sell (Big red circle)', 'Red Circle WaveTrend Overbought')
alertcondition(sellSignalDiv, 'Sell (Big red circle + Div)', 'Buy & WT Bearish Divergence & WT Overbought')
alertcondition(wtCross and wtCrossDown, 'Sell (Small red dot)', 'Sell small circle')
// } ALERTS BU KODU PARÇALARINA AYIR İŞLEV VE FONKSİYONLARINA GÖRE. VE HER BİR FONKSİYONUN KODLARINI ALT ALTA YAZACAĞIZ. ŞİMDİ BURADA KAÇ PARÇA VAR. SADECE SAYI YAZ SONRASINDA HER ALANI AYRI AYRI YAZACAĞIZ.