Indicator · Pine Script v6 · Own pane

Market Cipher B

by TamTH-Dev· code credited to tamth_

Market Cipher B is a multi-oscillator indicator that draws in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code167
Settings22inputs
LicenceNone statedfile: MPL-2.0
Last update6 weeks ago18 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

167 lines of Pine Script v6 from collections/MarketCipher/MarketCipherB.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

MarketCipherB.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tamth_

// @version=6
indicator("Market Cipher B", overlay = false)


//-----------------------------------------------------------------------------
//  Constants
//-----------------------------------------------------------------------------
// Colors
color TRANSPARENT_COLOR = #ffffff00
color WHITE_COLOR       = #dee2e6
color BLACK_COLOR       = #000000
color RED_COLOR         = #F72585
color ORANGE_COLOR      = #fb5607
color YELLOW_COLOR      = #ffbe0b
color GREEN_COLOR       = #2a9d8f
color AQUA_COLOR        = #4CC9F0
color BLUE_COLOR        = #4361ee
color PURPLE_COLOR      = #3F37C9
color PINK_COLOR        = #B5179E
color LIGHT_GRAY_COLOR  = #364156
color DARK_GRAY_COLOR   = #212d40
color TEXT_COLOR        = #ced4da

//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// Common Functions
//-----------------------------------------------------------------------------
debug(simple string txt) =>
    // Create label on the first bar
    var label = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, WHITE_COLOR, size.large, text.align_left)
    // On next bars, update the label"s x and y position, and the text it displays
    label.set_xy(label, bar_index, ta.highest(10)[1])
    label.set_text(label, txt)


//-----------------------------------------------------------------------------
// Settings
//-----------------------------------------------------------------------------
string thresholdGrp = "Threshold"
bool thresholdShowed = input.bool(true, title = "Show", group = thresholdGrp)
int overboughtThreshold = input.int(60, title = "Overbought Threshold", group = thresholdGrp)
int oversoldThreshold = input.int(-60, title = "Oversold Threshold", group = thresholdGrp)
string wtGrp = "Waves Trend"
bool wtShowed = input.bool(true, title = "Show", group = wtGrp)
int wtChlPrd = input.int(9, title = "Channel Period", group = wtGrp)
int wtAvgPrd = input.int(12, title = "Average Period", group = wtGrp)
float wtMaSrc = input.source(hlc3, title = "MA Source", group = wtGrp)
int wtMaLen = input.int(3, title = "MA Length", group = wtGrp)
bool wtDivShowed = input.bool(false, title = "Show Divergence", group = wtGrp)
int wtLongBearishDivLevel = input.int(45, title = "Long Bearish Divergence Level", group = wtGrp)
int wtLongBullishDivLevel = input.int(-65, title = "Long Bullish Divergence Level", group = wtGrp)
int wtShortBrearishDivLevel = input.int(15, title = "Short Bearish Divergence Level", group = wtGrp)
int wtShortBullishDivLevel = input.int(-40, title = "Short Bullish Divergence Level", group = wtGrp)
string mfoGrp = "MFO"
bool mfoShowed = input.bool(true, title = "Show", group = mfoGrp)
bool mfoBarShowed = input.bool(false, title = "Support Bar", group = mfoGrp)
int mfoPrd = input.int(60, title = "Period", group = mfoGrp)
int mfoMult = input.int(150, title = "Area Multiplier", group = mfoGrp)
string rsiGrp = "RSI"
bool rsiShowed = input.bool(true, title = "Show", group = rsiGrp)
int rsiPrd = input.int(40, title = "Period", group = rsiGrp)
string stochRsiGrp = "Stochastic RSI"
bool stochRsiShowed = input.bool(true, title = "Show", group = stochRsiGrp)
int stochRsiPrd = input.int(81, title = "Period", group = stochRsiGrp)
string vwapGrp = "VWAP"
bool vwapShowed = input.bool(true, title = "Show", group = vwapGrp)

//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
getTopFractal(series float src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0]
getBotFractal(series float src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0]
fractalize(series float src) =>
    series bool isBotFractal = getBotFractal(src)
    series bool isTopFractal = getTopFractal(src)
    isTopFractal ? 1 : isBotFractal ? -1 : 0

getDivPoints(series float src, int topLimit, int botLimit) =>
    series bool isTopFractal = not na(fractalize(src) > 0 and src[2] >= topLimit ? src[2] : na)
    series bool isBotFractal = not na(fractalize(src) < 0 and src[2] <= botLimit ? src[2] : na)
    float highPrev = ta.valuewhen(isTopFractal, src[2], 0)[2]
    float highPrice = ta.valuewhen(isTopFractal, high[2], 0)[2]
    float lowPrev = ta.valuewhen(isBotFractal, src[2], 0)[2]
    float lowPrice = ta.valuewhen(isBotFractal, low[2], 0)[2]
    bool isBearish = isTopFractal and high[2] > highPrice and src[2] < highPrev
    bool isBullish = isBotFractal and low[2] < lowPrice and src[2] > lowPrev
    [isTopFractal, isBotFractal, lowPrev, isBearish, isBullish]

getWtAndVwap() =>
    float src = request.security(syminfo.tickerid, timeframe.period, wtMaSrc)
    float esa = ta.ema(src, wtChlPrd)
    float d = ta.ema(math.abs(src - esa), wtChlPrd)
    float ci = (src - esa) / (0.015 * d)
    float leadingWt = ta.ema(ci, wtAvgPrd)
    float laggingWt = ta.sma(leadingWt, wtMaLen)
    float vwap = leadingWt - laggingWt
    [leadingWt, laggingWt, vwap]

getHaVal(series float src) => request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, src)

getMfo() =>
    series float haOpen = getHaVal(open)
    series float haClose = getHaVal(close)
    series float haHigh = getHaVal(high)
    series float haLow = getHaVal(low)
    mfo = ta.sma((haClose - haOpen) / (haHigh - haLow) * mfoMult, mfoPrd)

getRsi(series float _close, series float _high, series float _low) =>
    ta.sma(ta.stoch(_close, _high, _low, rsiPrd), 2)

getStochRsi(series float _close, series float _high, series float _low) =>
    ta.sma(ta.stoch(_close, _high, _low, stochRsiPrd), 2)

//-----------------------------------------------------------------------------
// Get values
//-----------------------------------------------------------------------------
series float _close = request.security(syminfo.tickerid, timeframe.period, close)
series float _high = request.security(syminfo.tickerid, timeframe.period, high)
series float _low = request.security(syminfo.tickerid, timeframe.period, low)
float rsi = getRsi(_close, _high, _low)
float stochRsi = getStochRsi(_close, _high, _low)
float mfo = getMfo()
[leadingWt, laggingWt, vwap] = getWtAndVwap()
[wtLongTopFractal, wtLongBotFractal, wtLongLowPrev, isWtLongBearishDiv, isWtLongBullishDiv] = getDivPoints(laggingWt, wtLongBearishDivLevel, wtLongBullishDivLevel)
[wtShortTopFractal, wtShortBotFractal, wtShortLowPrev, isWtShortBearishDiv, isWtShortBullishDiv] =  getDivPoints(laggingWt, wtShortBrearishDivLevel, wtShortBullishDivLevel)

//-----------------------------------------------------------------------------
// Render values
//-----------------------------------------------------------------------------
plot(thresholdShowed ? overboughtThreshold : na, title = "Overbought Threshold", color = color.new(GREEN_COLOR, 60), display = display.pane, linewidth = 4)
plot(thresholdShowed ? oversoldThreshold : na, title = "Oversold Threshold", color = color.new(RED_COLOR, 60), display = display.pane, linewidth = 4)

var mfoBarTopLine = plot(mfoShowed and mfoBarShowed ? -100 : na, title = "MFO Bar", color = color.new(WHITE_COLOR, 100), editable = false, display = display.pane)
var mfoBarBotLine = plot(mfoShowed and mfoBarShowed ? -105 : na, title = "MFO Bar", color = color.new(WHITE_COLOR, 100), editable = false, display = display.pane)
fill(mfoBarTopLine, mfoBarBotLine, title = "MFO Bar", color = mfo > 0 ? color.new(GREEN_COLOR, 40) : color.new(RED_COLOR, 40))

plot(wtShowed ? leadingWt : na, title = "Leading Wave Trend", color = LIGHT_GRAY_COLOR, linewidth = 1, style = plot.style_area)
plot(wtShowed ? laggingWt : na, title = "Lagging Wave Trend", color = color.new(DARK_GRAY_COLOR, 50), linewidth = 1, style = plot.style_area)

plot(vwapShowed ? vwap : na, title = "VWAP", color = color.new(YELLOW_COLOR, 40), style = plot.style_area)

plot(mfoShowed ? mfo : na, title = "MFO", color = mfo > 0 ? color.new(GREEN_COLOR, 60) : color.new(RED_COLOR, 60), linewidth = 2, style = plot.style_area)

plot(0, title = "Zero Line", color = color.new(WHITE_COLOR, 50), display = display.pane)

plot(ta.crossover(leadingWt, laggingWt) ? laggingWt : na, title = "Buy Signal", color = GREEN_COLOR, linewidth = 2, style = plot.style_circles, display = display.pane)
plot(ta.crossunder(leadingWt, laggingWt) ? laggingWt : na, title = "Sell Signal", color = RED_COLOR, linewidth = 2, style = plot.style_circles, display = display.pane)

color wtLongBearishDivColor = wtDivShowed and isWtLongBearishDiv ? RED_COLOR : na
color wtLongBullishDivColor = wtDivShowed and isWtLongBullishDiv ? GREEN_COLOR : na
color wtShortBearishDivColor = wtDivShowed and isWtShortBearishDiv ? color.new(RED_COLOR, 50) : na
color wtShortBullishDivColor = wtDivShowed and isWtShortBullishDiv ? color.new(GREEN_COLOR, 50) : na
plot(series = wtLongTopFractal ? laggingWt[2] : na, title = "Wave Trend Long Bearish Divergence", color = wtLongBearishDivColor, linewidth = 2, offset = -2, display = display.pane)
plot(series = wtLongBotFractal ? laggingWt[2] : na, title = "Wave Trend Long Bullish Divergence", color = wtLongBullishDivColor, linewidth = 2, offset = -2, display = display.pane)
plot(series = wtShortTopFractal ? laggingWt[2] : na, title = "Wave Trend Short Bearish Divergence", color = wtShortBearishDivColor, linewidth = 2, offset = -2, display = display.pane)
plot(series = wtShortBotFractal ? laggingWt[2] : na, title = "Wave Trend Short Bullish Divergence", color = wtShortBullishDivColor, linewidth = 2, offset = -2, display = display.pane)

plot(rsiShowed ? rsi : na, title = "RSI", color = PINK_COLOR, linewidth = 2)

plot(stochRsiShowed ? stochRsi : na, title = "Stochastic RSI", color = rsi > stochRsi ? AQUA_COLOR : PURPLE_COLOR, linewidth = 2)

//-----------------------------------------------------------------------------

Overview

Market Cipher B plots a Wave Trend line from a channel period, an average period, a moving-average source, and a moving-average length, with optional divergence markers at long and short bullish and bearish levels. It also shows an MFO area, an optional support bar, RSI, Stochastic RSI, and VWAP, each with its own show toggle and period or multiplier. Overbought and oversold threshold lines can be shown. No trade entries, exits, or stops are defined.

Details

Published by

TamTH-Dev on GitHub

Code credit

tamth_, as written in the script's header

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ShowbooltruethresholdShowed
Overbought Thresholdint60overboughtThreshold
Oversold Thresholdint-60oversoldThreshold
ShowbooltruewtShowed
Channel Periodint9wtChlPrd
Average Periodint12wtAvgPrd
MA Sourcesourcehlc3wtMaSrc
MA Lengthint3wtMaLen
Show DivergenceboolfalsewtDivShowed
Long Bearish Divergence Levelint45wtLongBearishDivLevel
Long Bullish Divergence Levelint-65wtLongBullishDivLevel
Short Bearish Divergence Levelint15wtShortBrearishDivLevel
Show all 22 settings
SettingTypeDefaultVariable
Short Bullish Divergence Levelint-40wtShortBullishDivLevel
ShowbooltruemfoShowed
Support BarboolfalsemfoBarShowed
Periodint60mfoPrd
Area Multiplierint150mfoMult
ShowbooltruersiShowed
Periodint40rsiPrd
ShowbooltruestochRsiShowed
Periodint81stochRsiPrd
ShowbooltruevwapShowed
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Oscillator Suite

by TamaraKGreen
46 stars

Oscillator Suite plots a normalised price oscillator in a separate pane and overlays a signal line that can use SMA, EMA, WMA, HMA, RMA, VWMA, T3, ZEMA, KAMA, or GKEMA. It marks bullish and bearish divergences, a smoothed money-flow series, confluence areas an

Indicator v5 Oscillators & momentumDivergence
Updated 8 weeks ago · None stated GitHub repository of Oscillator Suite

MFI Divergences

by tistaharahap
25 stars

This indicator plots the Money Flow Index in a separate pane and marks regular and hidden bullish and bearish divergences between price pivots and the oscillator. It builds the index from positive and negative money flow, then finds pivot highs and lows using

Indicator v4 Oscillators & momentumVolume
Updated 6 years ago · None stated GitHub repository of MFI Divergences
11 stars

This indicator plots a smoothed Z-score of cumulative volume delta in a separate pane, showing whether buying or selling pressure is dominant and when the reading enters extreme zones. It marks spot accumulation, climax or exhaustion, and pivot-based price-vol

Indicator v6 Oscillators & momentumVolume Repaints
Updated 7 weeks ago · MIT GitHub repository of CVD Z-Score [NeuNue]
9 stars

This indicator plots a heuristic volume-balance oscillator in a separate pane. It estimates signed volume from the close location inside each bar, multiplies that by volume, and sums the proxy over a rolling window. The sum is scaled between minus one and plus

Indicator v6 VolumeOscillators & momentum
Updated 3 days ago · MIT GitHub repository of CVD Bias [WavesUnchained]

DC-B v2.5

by crissrocca
9 stars

This indicator is an oscillator suite inspired by Market Cipher B and VuManChu Cipher B that plots in a separate pane. It combines a WaveTrend oscillator, a Money Flow Index (MFI) area, and an RSI indicator with automatic divergence detection. Visual signals h

Indicator v4 Oscillators & momentumDivergence
Updated 3 years ago · MPL-2.0 GitHub repository of DC-B v2.5

QPulse

by JasonTeixeira
9 stars

QPulse is a multi-factor indicator that draws in a separate pane to evaluate market momentum, volume flow, and volatility dynamics. It calculates volume delta, a cumulative delta proxy, advanced adaptive ATR, and a hybrid volume-weighted RSI with overbought an

Indicator v6 Oscillators & momentumVolatility & bands
Updated 2 weeks ago · Custom licence GitHub repository of QPulse

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers