Indicator · Pine Script v4 · Own pane

All-In-One Oscillator

by ZachLegros· code credited to legroszach

This indicator combines multiple momentum and volume metrics into a single separate pane.

View on GitHub

GitHub stars6on the repository
Pine versionv4older, still runs
Lines of code123
Settings17inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago25 Jun 2024

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

123 lines of Pine Script v4 from indicator.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

indicator.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © legroszach
//@version=4
study("All-In-One Oscillator", overlay=false)

ha_t = heikinashi(syminfo.tickerid)
ha_close = security(ha_t, timeframe.period, close)
ha_hlc3 = security(ha_t, timeframe.period, hlc3)

map(input, inputMin, inputMax, outputMin, outputMax) =>
    outputMin + ((outputMax - outputMin) / (inputMax - inputMin)) * (input - inputMin)

color noColor = na
zero = plot(0, title="Zero", color=noColor)


// Stochastic Oscillator
stochObLevel1 = 60
stochObLevel2 = 53
stochOsLevel1 = -60
stochOsLevel2 = -53

n1 = input(5, "STOCH Channel Length")
n2 = input(3, "STOCH Average Length")
stochSmooting = input(3, "STOCH Smoothing")
 
ap = ha_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, stochSmooting)

plot(wt1, color=#54b1e3, style=4, title="STOCH")
plot(wt2, color=#00398a, transp=10, style=4, title="STOCH EMA")
// Cross
plot(crossover(wt1, wt2) ? wt2 : na, style=6, color=color.green, title="Cross over", linewidth=2)
plot(crossunder(wt1, wt2) ? wt2 : na, style=6, color=color.red, title="Cross under", linewidth=2)
// OB & OS levels
plot(stochObLevel1, color=color.white, title="Overbought level 1", editable=false)
plot(stochOsLevel1, color=color.white, title="Oversold level 1", editable=false)
plot(stochObLevel2, color=color.white, style=6, transp=50, title="Overbought level 2", editable=false)
plot(stochOsLevel2, color=color.white, style=6, transp=50, title="Oversold level 2", editable=false)


// MFI
mfiOsLevel = input(-8, "MFI Oversold level", minval=-50, maxval=0)
source = ha_hlc3
mfiLength = input(50, minval=1, title="MFI Period")
mfiSmooth = input(9, minval=1, title="MFI Smoothing")
value = high-low
upper = sum(volume * (change(source) <= 0 ? 0 : value), mfiLength)
lower = sum(volume * (change(source) >= 0 ? 0 : value), mfiLength)
mfi = rsi(upper, lower) - 50
mfi := sma(mfi, mfiSmooth)
mfiPlot = plot(mfi, title="Money Flow Index", color=mfi>=0 ? color.green : color.red, linewidth=2)
fill(mfiPlot, zero, color=mfi>=0 ? color.green : color.red, transp=60)


// RSI
rsiObLevel = 70
rsiOsLevel = 30
rsiPeriod = input(7, minval=1, title="RSI Period")
rsiSource = ha_close
up = rma(max(change(rsiSource), 0), rsiPeriod)
down = rma(-min(change(rsiSource), 0), rsiPeriod)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsi := ema(rsi, 5)
plot(rsi, color=color.purple, linewidth=2, title="RSI")


// VWAP
fastLength = input(12, minval=1, title="MACD Fast MA Length"), slowLength=input(25,minval=1, title="MACD Slow MA Length")
signalLength = input(9, title="MACD Signal Length")
lengthz = input(20, title="Z-VWAP Length")
lengthStdev = input(25, title="Stdev Length")
A = input(1.0, minval=-2.0, maxval=2.0, title="MACZ constant A")
B = input(1.0, minval=-2.0, maxval=2.0, title="MACZ constant B")

calc_zvwap(pds) =>
    mean = sum(volume*close,pds)/sum(volume,pds)
    vwapsd = sqrt(sma(pow(close-mean, 2), pds) )
    (close-mean)/vwapsd

zscore = calc_zvwap(lengthz)
fastMA = sma(source, fastLength)
slowMA = sma(source, slowLength)
macd = fastMA - slowMA
macz_t=zscore*A+ macd/stdev(source, lengthStdev)*B
signal=sma(macz_t, signalLength)
hist=macz_t-signal
plot(hist*10, color=color.yellow, style=plot.style_area, title="VWAP", transp=50)


// indicator weightss
sm2w = input(0.6, title="SM 2 Weight")
mfiw = input(0.15, title="MFI Weight")
rsiw = input(0.35, title="RSI Weight")

// BUY signal
buySignal(mom, momSmooth, rsi, mfi) =>
    if crossover(mom, momSmooth) and momSmooth <= -25 and mfi <= -5
        smval = momSmooth < stochOsLevel1 ? (stochOsLevel2-momSmooth)*sm2w : (stochOsLevel1-momSmooth)*sm2w
        wsum = smval + (mfiOsLevel-mfi)*mfiw + (rsiOsLevel-rsi)*rsiw
        wsum
        if wsum >= 0
            -90
        else
            na
    else
        na
        

p1 = plot(-90, color=noColor, display=display.none)
p2 = plot(-100, color=noColor, display=display.none)
fill(p1, p2, color=mfi <= 0 ? color.red : color.green, transp=60)

plot(buySignal(wt1, wt2, rsi, mfi), style=6, color=#00ff26, title="Buy signal", linewidth=3)

// Median line
hline(0, color=color.white, linestyle=hline.style_dotted)

Overview

All-In-One Oscillator calculates a WaveTrend-style stochastic oscillator derived from Heikin Ashi values, a volume-weighted Money Flow Index (MFI) centered at zero, an exponential-smoothed Relative Strength Index (RSI), and a Z-score VWAP MACD composite oscillator. Visual outputs include oscillator lines, overbought and oversold thresholds, crossover plot markers, and area histograms. Inputs let users configure smoothing lengths, periods, constant multipliers, and indicator weighting parameters.

Details

Published by

ZachLegros on GitHub

Code credit

legroszach, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volume

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
STOCH Channel Lengthint5n1
STOCH Average Lengthint3n2
STOCH Smoothingint3stochSmooting
MFI Oversold levelint-8mfiOsLevel
MFI Periodint50mfiLength
MFI Smoothingint9mfiSmooth
RSI Periodint7rsiPeriod
MACD Fast MA Lengthint12fastLength
MACD Slow MA Lengthint25slowLength
MACD Signal Lengthint9signalLength
Z-VWAP Lengthint20lengthz
Stdev Lengthint25lengthStdev
Show all 17 settings
SettingTypeDefaultVariable
MACZ constant Afloat1.0A
MACZ constant Bfloat1.0B
SM 2 Weightfloat0.6sm2w
MFI Weightfloat0.15mfiw
RSI Weightfloat0.35rsiw
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

Money Flow Index

by everget
948 stars

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought

Indicator v4 Oscillators & momentumVolume
Updated 10 days ago · GPL-3.0 GitHub repository of Money Flow Index

Commitment Gauge

by harryguiacorn
219 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge

Aggregate Signal

by capissimo
114 stars

This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig

Indicator v4 Oscillators & momentumVolume Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal

This indicator calculates the Bill Williams Market Facilitation Index as the high-low range divided by volume, or zero when volume is zero. It compares the index and volume with the previous bar and assigns one of four zones: green for both rising, fade for bo

Indicator v6 VolumeOscillators & momentum
Updated 4 weeks ago · Apache-2.0 GitHub repository of Bill Williams Market Facilitation Index

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

Chaikin Oscillator

by be-thomas
65 stars

Calculates the Chaikin Oscillator by taking the difference between a fast exponential moving average and a slow exponential moving average of the Accumulation/Distribution line. It plots the resulting line in a separate pane alongside a dashed zero reference l

Indicator v4 Oscillators & momentumVolume
Updated 4 days ago · GPL-3.0 GitHub repository of Chaikin Oscillator

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers