November 17, 2019

Market Cipher A and B For Free

Please Help!

If you found this review useful, then please say thank you with a little donation. I am a 1 man band, trying to give you free information that you hopefully find useful. I welcome any amount and your donation helps me maintain the site with updates, and pay for the servers required to keep this site alive!

Scan to Donate Bitcoin to admin
Buy Me A Beer With Bitcoin!!
Hopefully this information helped you and saved you a lot of money! Please tip only if you can afford it!

Get Market Cipher For Free

So we have taken the code from a number of scripts freely available on trading view and changed the settings to make them exactly like Market Cipher. Find each of the indicators below.

How to Add The Script To Trading View

Follow these simple steps to add the scripts.

  1. Open the Pine Script Editor within trading view by clicking the square icon at the bottom right of the screen.
  2. Click the ‘Pine Script’ tab at the top of the page
  3. Remove all the code in the window and copy and paste the code below
  4. Click the “save as” button and name it Market Cipher A or B.
  5. Click the “add to chart” button and your all done!
  6. If you close the indicator, you can click open within pine script and repeat step 5 above

Market Cipher A

The code below is the exact same settings for Market Cipher A which includes the blood diamonds, red crosses, blue triangles and yellow crosses

Market Cipher A

//@version=4
study("MarketCipher A", shorttitle="MarketCipher A", overlay=true)


//Blood diamonds and yellow x's
// PARAMETERS {

// WaveTrend Overbought & Oversold lines
obLevel = input(53, "WT Overbought Level 1")
obLevel2 = input(60, "WT Overbought Level 2")
osLevel = input(-53, "WT Oversold Level 1")
osLevel2 = input(-60, "WT Oversold Level 2")

//EMA Ribbon
showRibbon = input(true, "Show Ribbon")

ema1 = input(5)
ema2 = input(11)
ema3 = input(15)
ema4 = input(18)
ema5 = input(21)
ema6 = input(25)
ema7 = input(29)
ema8 = input(33)
// }


// CALCULATE INDICATORS {

//EMA Ribbon
ema1_ = ema(close, ema1)
ema2_ = ema(close, ema2)
ema3_ = ema(close, ema3)
ema4_ = ema(close, ema4)
ema5_ = ema(close, ema5)
ema6_ = ema(close, ema6)
ema7_ = ema(close, ema7)
ema8_ = ema(close, ema8)

// 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)

// WT
n1 = input(7, "WT Channel Length")
n2 = input(12, "WT Average Length")

ap = input(ohlc4)
esa = ema(ap, n1)
de = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * de)
tci = ema(ci, n2)
wt1 = tci
wt2 = sma(wt1, 3)

vwap_area = wt1 - wt2

// WaveTrend Conditions
WTCross = cross(wt1, wt2)
WTCrossUp = wt2 - wt1 <= 0
WTCrossDown = wt2 - wt1 >= 0
WTOverSold = wt2 <= osLevel2
WTOverBought = wt2 >= obLevel2

// Signals

longEma = crossover(ema2_, ema8_)
redCross = crossunder(ema1_, ema2_)
blueTriangle = crossover(ema2_, ema3_)
redDiamond = WTCross and WTCrossDown
yellowCross = redDiamond and rsi <= 30 and wt2 <= osLevel
bloodDiamond = redDiamond and redCross
shortEma = crossover(ema8_, ema2_)


               
// } CALCULATE INDICATORS

// DRAW {

// EMA Ribbon
colorEma = ema8_ < ema2_ ? color.green : color.red

plot(ema1_, color=showRibbon ? #265aa6 : na, linewidth=2, transp=50, title="EMA 1")
plot(ema2_, color=showRibbon ? #265aa6 : na, linewidth=2, transp=50, title="EMA 2")
plot(ema3_, color=showRibbon ? #1976d2 : na, linewidth=2, transp=50, title="EMA 3")
plot(ema4_, color=showRibbon ? #1976d2 : na, linewidth=2, transp=50, title="EMA 4")
plot(ema5_, color=showRibbon ? #7fb3ff : na, linewidth=2, transp=50, title="EMA 5")
plot(ema6_, color=showRibbon ? #7fb3ff : na, linewidth=2, transp=50, title="EMA 6")
plot(ema7_, color=showRibbon ? #bbdefb : na, linewidth=2, transp=50, title="EMA 7")
plot(ema8_, color=showRibbon ? #bbdefb : na, linewidth=2, transp=50, title="EMA 8")

plot(ema8_, color=showRibbon ? na : colorEma, linewidth=2, transp=50, title="EMA 8")

// SHAPES
plotshape(longEma, style=shape.circle, color=#00ff00, transp=50, location=location.abovebar, size=size.tiny, title="Long EMA Signal")
plotshape(shortEma, style=shape.circle, color=#ff0000, transp=50, location=location.abovebar, size=size.tiny, title="Short EMA Signal")
plotshape(redCross, style=shape.xcross, color=#ff0000, transp=50, location=location.abovebar, size=size.tiny, title="Red cross")
plotshape(blueTriangle, style=shape.triangleup, color=#0064ff, transp=50, location=location.abovebar, size=size.small, title="Blue Triangle")
plotshape(redDiamond, style=shape.diamond, color=#ff0000, location=location.abovebar, size=size.tiny, title="Red Diamond", transp=25)
plotshape(bloodDiamond, style=shape.diamond, color=#ff0000, location=location.abovebar, size=size.small, title="Blood Diamond", transp=15)
plotshape(yellowCross, style=shape.xcross, color=color.yellow, location=location.abovebar, size=size.small, title="Yellow Cross", transp=25)

// } DRAW
  
  
// ALERTS {
alertcondition(redDiamond != 0, "Red Diamond", "Red Diamond")
alertcondition(bloodDiamond != 0, "Blood Diamond", "Blood Diamond")
alertcondition(yellowCross != 0, "YellowX", "YellowX")
alertcondition(redCross != 0, "RedX", "RedX")
alertcondition(longEma != 0, "Longema", "Longema")
alertcondition(blueTriangle != 0, "Bluetriangle", "Bluetriangle")
// } ALERTS

Market Cipher B

The code below is the exact settings for Market Cipher B. We have included RSI divergence, Stock RSI divergence and wave trend divergence making it much better than the original Market Cipher B!

Notes For Market Cipher B:

The rsi inicators are as follows:

  • Bullish Divergence (green diamond)
  • Hidden Bullish Divergence (green circle)
  • Bearish Divergence (red diamond)
  • Hidden Bearish Divergence (red circle)

The stoch rsi inicators are as follows:

  • 'R': Regular
  • 'H': Hidden
  • Green: Bull
  • Red: Bear

Version 2 has the additional Wave divergences added, although this is not a feature of the original Market Cipher, it's nice to have it. I've added it to both waves, but I've noticed it does miss the odd divergence when the price or wave difference is close, it also ignores the divergence if there is a wave inbetween (which is a debate I don't want to get into)! So make sure you check it before placing a trade!

Market Cipher B - Version 2 - *8th Oct 2019 - Added Wave divergences


//@version=3
//Market Cipher Update 2 - updated 8th Oct 2019

//Momentum Curves with green and red dots
study(title="MarketCipher B", shorttitle="MarketCipher B")
n1 = input(9, "Channel Length")
n2 = input(12, "Average Length")
obLevel1 = input(60, "Over Bought Level 1")
obLevel2 = input(53, "Over Bought Level 2")
osLevel1 = input(-60, "Over Sold Level 1")
osLevel2 = input(-53, "Over Sold Level 2")
osLevel3 = input(-100, "Over Sold Level 2")

 
ap = hlc3 
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
 
wt1 = tci
wt2 = sma(wt1,3)

plot(0, color=gray, title="Zero Line")
plot(obLevel1, color=red, style=3, title="Bottom")
plot(osLevel1, color=green, style=3, title="Top")
plot(wt1, color=#BFE4FF, style=4, title= "Lt Blue Wave")
plot(wt2, color=#673ab7, style=4, title="Blue Wave", transp=40)
plot(wt1-wt2, color=yellow, style=4, transp=40, title="wave1-wave2")

//green dots and crosses
plotshape(crossover(wt1, wt2) and osLevel1 ? wt2 : na, title="Pos Crossover", location=location.absolute, style=shape.cross, size=size.tiny, color=#3FFF00, transp=20)
plotshape(crossover(wt2, wt1) and osLevel1 ? wt1 : na, title="Neg Crossover", location=location.absolute, style=shape.cross, size=size.tiny, color=red, transp=20)
plotshape(crossover(wt1, wt2) and wt2 < -59 ? wt2 : na, title="Pos Crossover", location=location.bottom, style=shape.circle, size=size.tiny, color=#3FFF00, transp=20)
plotshape(crossover(wt2, wt1) and wt1 > 59 ? wt2 : na, title="Neg Crossover", location=location.top, style=shape.circle, size=size.tiny, color=red, transp=20)

//soch RSI with divergences
smoothKw = input(3, minval=1)
smoothDw = input(3, minval=1)
lengthRSIw = input(14, minval=1)
lengthStochw = input(14, minval=1)
uselogw = input(true, title="Log")
srcInw = input(close, type=source, title="Source")
showdivsw = input(true, title="Show Divergences")
showhiddenw = input(false, title="Show Hidden Divergences")
showchanw = input(false, title="Show Divergences Channel")


srcw = uselogw ? log(srcInw) : srcInw
rsi1w = rsi(srcw, lengthRSIw)
kkw = sma(stoch(rsi1w, rsi1w, rsi1w, lengthStochw), smoothKw)
dw = sma(kkw, smoothDw)
hmw = input(false, title="Use Average of both K & D")
kw = hmw ? avg(kkw, dw) : kkw

aw = plot(kkw, color=blue, linewidth=1, transp=0, title="K")
bw = plot(dw, color=orange, linewidth=1, transp=0, title="D")
fw = kkw >= dw ? blue : orange
fill(aw, bw, title="KD Fill", color=white)


//------------------------------
//@RicardoSantos' Divergence Script

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
//-------------------------
fractal_top = f_fractalize(kw) > 0 ? kw[2] : na
fractal_bot = f_fractalize(kw) < 0 ? kw[2] : na

high_prev = valuewhen(fractal_top, kw[2], 0)[2]
high_price = valuewhen(fractal_top, high[2], 0)[2]
low_prev = valuewhen(fractal_bot, kw[2], 0)[2]
low_price = valuewhen(fractal_bot, low[2], 0)[2]

regular_bearish_diva = fractal_top and high[2] > high_price and kw[2] < high_prev
hidden_bearish_diva = fractal_top and high[2] < high_price and kw[2] > high_prev
regular_bullish_diva = fractal_bot and low[2] < low_price and kw[2] > low_prev
hidden_bullish_diva = fractal_bot and low[2] > low_price and kw[2] < low_prev
//-------------------------
plot(showchanw?fractal_top:na, title="Top Div Channel", offset=-2, color=gray)
plot(showchanw?fractal_bot:na, title="Bottom Div Channel", offset=-2, color=gray)

col1 = regular_bearish_diva ? red : hidden_bearish_diva and showhiddenw ? red : na
col2 = regular_bullish_diva ? green : hidden_bullish_diva and showhiddenw ? green : na
col3 = regular_bearish_diva ? red : hidden_bearish_diva and showhiddenw ? red : showchanw ? gray : na
col4 = regular_bullish_diva ? green : hidden_bullish_diva and showhiddenw ? green : showchanw ? gray : na

plot(title='H F', series=showdivsw and fractal_top ? kw[2] : na, color=col1, linewidth=2, offset=-2)
plot(title='L F', series=showdivsw and fractal_bot ? kw[2] : na, color=col2, linewidth=2, offset=-2)
plot(title='H D', series=showdivsw and fractal_top ? kw[2] : na, style=circles, color=col3, linewidth=3, offset=-2)
plot(title='L D', series=showdivsw and fractal_bot ? kw[2] : na, style=circles, color=col4, linewidth=3, offset=-2)

plotshape(title='+RBD', series=showdivsw and regular_bearish_diva ? kw[2] : na, text='R', style=shape.labeldown, location=location.absolute, color=red, textcolor=white, offset=-2)
plotshape(title='+HBD', series=showdivsw and hidden_bearish_diva and showhiddenw ? kw[2] : na, text='H', style=shape.labeldown, location=location.absolute, color=red, textcolor=white, offset=-2)
plotshape(title='-RBD', series=showdivsw and regular_bullish_diva ? kw[2] : na, text='R', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)
plotshape(title='-HBD', series=showdivsw and hidden_bullish_diva  and showhiddenw ? kw[2] : na, text='H', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)


//money flow
colorRed = #ff0000
colorGreen = #03ff00

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
                    if matype == "VWMA"
                        vwma(src, length)
                    else
                        src

rsiMFIperiod = input(60, "RSI+MFI Period")
rsiMFIMultiplier = input(190, "RSI+MFI Area multiplier")
MFRSIMA = input(defval="SMA", title="MFRSIMA", options=["RMA", "SMA", "EMA", "WMA", "VWMA"])

candleValue = (close - open) / (high - low)
MVC = ma(MFRSIMA, candleValue, rsiMFIperiod)
color_area = MVC > 0 ? green : red

RSIMFIplot = plot(MVC * rsiMFIMultiplier, title="RSI+MFI Area", color=color_area, transp=35)
fill(RSIMFIplot, plot(0), color_area, transp=50)

//rsi
//Bullish Divergence (green triangle)
//Hidden Bullish Divergence (green circle)
//Bearish Divergence (red triangle)
//Hidden Bearish Divergence (red circle)

lend = 14
bearish_div_rsi = input(60, "Min Bearish RSI", integer, minval=50, maxval=100)
bullish_div_rsi = input(40, "Max Bullish RSI", integer, minval=0, maxval=50)

// RSI code
rsi = rsi(close, lend)
plot(rsi,  color=#6DFFE1, linewidth=2, transp=0, title="RSI")

// DIVS code
xbars = 60
hb = abs(highestbars(rsi, xbars)) // Finds bar with highest value in last X bars
lb = abs(lowestbars(rsi, xbars)) // Finds bar with lowest value in last X bars

// Defining variable values, mandatory in Pine 3
max = na
max_rsi = na
min = na
min_rsi = na
bearish_div = na
bullish_div = na
hidden_bearish_div = na
hidden_bullish_div = na
div_alert = na
hidden_div_alert = na

// If bar with lowest / highest is current bar, use it's value
max := hb == 0 ? close : na(max[1]) ? close : max[1]
max_rsi := hb == 0 ? rsi : na(max_rsi[1]) ? rsi : max_rsi[1]
min := lb == 0 ? close : na(min[1]) ? close : min[1]
min_rsi := lb == 0 ? rsi : na(min_rsi[1]) ? rsi : min_rsi[1]

// Compare high of current bar being examined with previous bar's high
// If curr bar high is higher than the max bar high in the lookback window range
if close > max // we have a new high
    max := close // change variable "max" to use current bar's high value
if rsi > max_rsi // we have a new high
    max_rsi := rsi // change variable "max_rsi" to use current bar's RSI value
if close < min // we have a new low
    min := close // change variable "min" to use current bar's low value
if rsi < min_rsi // we have a new low
    min_rsi := rsi // change variable "min_rsi" to use current bar's RSI value

// Detects divergences between price and indicator with 1 candle delay so it filters out repeating divergences
if (max[1] > max[2]) and (rsi[1] < max_rsi) and (rsi <= rsi[1]) and (rsi[1] >= bearish_div_rsi)
    bearish_div := true
	div_alert := true
if (min[1] < min[2]) and (rsi[1] > min_rsi) and (rsi >= rsi[1]) and (rsi[1] <= bullish_div_rsi)
    bullish_div := true
	div_alert := true
// Hidden divergences
if (max[1] < max[2]) and (rsi[1] < max_rsi)
	hidden_bearish_div := true
	hidden_div_alert := true
if (min[1] > min[2]) and (rsi[1] > min_rsi)
	hidden_bullish_div := true
	hidden_div_alert := true
// Alerts
alertcondition(div_alert, title='RSI Divergence', message='RSI Divergence')
alertcondition(hidden_div_alert, title='Hidden RSI Divergence', message='Hidden RSI Divergence')

// Plots divergences with offest
plotshape((bearish_div ? rsi[1] + 3 : na), location=location.absolute, style=shape.diamond, color=#ff0000, size=size.tiny, transp=0, offset=0, title="RSI Bear Div")
plotshape((bullish_div ? rsi[1] - 3 : na), location=location.absolute, style=shape.diamond, color=#00ff01, size=size.tiny, transp=0, offset=0, title="RSI Bull Div")
plotshape((hidden_bearish_div ? rsi[1] + 3 : na), location=location.absolute, style=shape.circle, color=#ff0000, size=size.tiny, transp=0, offset=0, title="RSI Bear hDiv")
plotshape((hidden_bullish_div ? rsi[1] - 3 : na), location=location.absolute, style=shape.circle, color=#00ff01, size=size.tiny, transp=0, offset=0, title="RSI Bull hDiv")


//wave divergences
WTCross = cross(wt1, wt2)
WTCrossUp = wt2 - wt1 <= 0
WTCrossDown = wt2 - wt1 >= 0
WTFractal_top = f_fractalize(wt1) > 0 and wt1[2] ? wt1[2] : na
WTFractal_bot = f_fractalize(wt1) < 0 and wt1[2] ? wt1[2] : na

WTHigh_prev  = valuewhen(WTFractal_top, wt1[2], 0)[2]
WTHigh_price = valuewhen(WTFractal_top, high[2], 0)[2]
WTLow_prev  = valuewhen(WTFractal_bot, wt1, 0)[2]
WTLow_price  = valuewhen(WTFractal_bot, low[2], 0)[2]

WTRegular_bearish_div = WTFractal_top and high[2] > WTHigh_price and wt1[2] < WTHigh_prev
WTRegular_bullish_div = WTFractal_bot and low[2] < WTLow_price and wt1[2] > WTLow_prev

bearWTSignal = WTRegular_bearish_div and WTCrossDown
bullWTSignal = WTRegular_bullish_div and WTCrossUp

WTCol1 = bearWTSignal ? #ff0000 : na
WTCol2 = bullWTSignal ? #00FF00EB : na

plot(series = WTFractal_top ? wt1[2] : na, title='Bearish Divergence', color=WTCol1, linewidth=5, transp=60)
plot(series = WTFractal_bot ? wt1[2] : na, title='Bullish Divergence', color=WTCol2, linewidth=5, transp=60)


//2nd wave
WTFractal_topa = f_fractalize(wt2) > 0 and wt2[2] ? wt2[2] : na
WTFractal_bota = f_fractalize(wt2) < 0 and wt2[2] ? wt2[2] : na

WTHigh_preva  = valuewhen(WTFractal_topa, wt2[2], 0)[2]
WTHigh_pricea = valuewhen(WTFractal_topa, high[2], 0)[2]
WTLow_preva  = valuewhen(WTFractal_bota, wt2, 0)[2]
WTLow_pricea  = valuewhen(WTFractal_bota, low[2], 0)[2]


WTRegular_bearish_diva = WTFractal_topa and high[2] > WTHigh_pricea and wt2[2] < WTHigh_preva
WTRegular_bullish_diva = WTFractal_bota and low[2] < WTLow_pricea and wt2[2] > WTLow_preva

bearWTSignala = WTRegular_bearish_diva and WTCrossDown
bullWTSignala = WTRegular_bullish_diva and WTCrossUp

WTCol1a = bearWTSignala ? #ff0000 : na
WTCol2a = bullWTSignala ? #00FF00EB : na

plot(series = WTFractal_topa ? wt2[2] : na, title='Bearish Divergence', color=WTCol1a, linewidth=5, transp=60)
plot(series = WTFractal_bota ? wt2[2] : na, title='Bullish Divergence', color=WTCol2a, linewidth=5, transp=60)

38 thoughts on “Market Cipher A and B For Free

  1. Also for Market Cipher B following errors occurred:
    Add to Chart operation failed, reason: line 32: syntax error at input ‘plotshape’
    Add to Chart operation failed, reason: line 61: mismatched input ‘f_fractalize’ expecting ‘end of line without line continuation’

  2. Is there a bug in the code between the “HF” and “LF” divergences? The lines with an R at the end.

    I noticed the bearish ones tend to only show local divs (which is better imo, more reliable) but the bullish ones will calculate much further away at 3 or even 4 local lows instead of just 1 local top for the bearish ones.

    Is there a way to edit so that it will only show div relative to the past prior low/high?

    1. Yes, it works, just tested it again! Make sure you copy the whole script including the //@version=3 Let us know if you still have problems!

  3. Would be nice to put a timestamp on each script so we would know when it is updated and that a revised version is out. That way we can stay up to date. Thanks!

  4. Just copied and pasted A and B on the 6th Oct, seems to be okay (im not very savy with computers), are we all up to date or have there been any corrections, updates since?

    1. I’ve just added wave divergences to Market Cipher B, market with a green or red thick line, to help you identify when to actually trade. The original indicator does not have this, but it is really essential in my opinion. I’ve started putting dates within the code so you can see when you have an old version!

  5. These codes are poorly written. I have the EXACT market cipher A and B code if you, the author, are interested. I will be checking these comments for your reply.

    1. Our code comes from a number of free indicators, it’s possible they used the same. We would never claim it as our own, and the reason we give it to you for free! Unlike market cipher!!

      1. I do not say that the code is mine, I say that your code is copied and modified from mine simply because it has the same errors and names in the variables and the bad structure of when I started it.

        At the very least, put in comments all the sources where it comes from as we do all that we publish open codes.
        In this way people can continue it and/or learn how it was done.
        I am very grateful that you have created a space to publish about marketcipher, thanks to your page I will be inspired to create this code. Many thanks.

        (Sorry bad english, all translated <3)

    1. Either candles work with our code, Heiken Ashi is best for spotting price trend, but a little misleading for true price as each candle opens midway through the previous price.

  6. Im getting line 128 error n1= already declared, its on line 46 on market B. Do i need to copy and past it on a different script?

    1. If you’re asking if it’s illegal for CryptoFace to sell an indicator that’s essentially free, no it’s not. If you’re asking something else then please let us know!

Leave a Reply

Your email address will not be published. Required fields are marked *