Indicator · Pine Script v6 · Own pane

Oscillator

by TamTH-Dev· code credited to tamth_

This indicator plots a composite oscillator in a separate pane, integrating squeeze momentum, directional flux, divergence detection, and confluence gauges.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv6current
Lines of code489
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update5 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

489 lines of Pine Script v6 from strategies/strategies1/Oscillator.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Oscillator.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("Oscillator", overlay=false, precision=2, max_labels_count=500, max_lines_count=500, max_boxes_count=1000, max_bars_back=1000)


//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
// Colors
color TRANSPARENT_COLOR = color.new(#000000, 100)
color WHITE_COLOR      = #ffffff
color BLACK_COLOR      = #000000
color RED_COLOR        = #ff006e
color ORANGE_COLOR     = #fb5607
color YELLOW_COLOR     = #ffbe0b
color GREEN_COLOR      = #2a9d8f
color AQUA_COLOR       = #00b4d8
color BLUE_COLOR       = #3a86ff
color PURPLE_COLOR     = #8338ec
color PINK_COLOR       = #df3bf1
color LIGHT_GRAY_COLOR = #212d40
color DARK_GRAY_COLOR  = #212d40
color TEXT_COLOR       = #ced4da

//-----------------------------------------------------------------------------
// Common Variables
//-----------------------------------------------------------------------------
// Bar index and input
series int barIdx = bar_index

//-----------------------------------------------------------------------------
// Common Methods
//-----------------------------------------------------------------------------
// Debug label function
debug(simple string txt) =>
    var label lbl = label.new(barIdx, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, WHITE_COLOR, size.large, text.align_left)
    label.set_xy(lbl, barIdx, ta.highest(10)[1])
    label.set_text(lbl, txt)

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


//-----------------------------------------------------------------------------
// Squeeze Momentum
//-----------------------------------------------------------------------------
// Settings
//-----------------------------------------------------------------------------
const string tg  = 'Choose how to display the Confluence Gauges.'
const string tm  = 'Calibrates the length of the main oscillator ribbon as well as the period for the squeeze algorithm.'
const string ts  = 'Controls the width of the ribbon.\nLower values result in faster responsiveness at the cost of premature positives.'
const string td  = 'Adjusts a threshold to limit the amount of divergences detected based on strength.\nHigher values result in less detections.'
const string go  = 'Squeeze Momentum'
const string gd  = 'Directional Flux'
const string gl  = 'Divergences'
const string gg  = 'Gauges'
const string ss  = 'Sell Signal'
const string sb  = 'Buy Signal'
const string sob = 'Momentum Bullish'
const string sos = 'Momentum Bearish'
const string sfb = 'Flux Bullish'
const string sfs = 'Flux Bearish'
const string ssb = 'Bullish Swing'
const string sss = 'Bearish Swing'
const string sgb = 'Strong Bull Gauge'
const string sgs = 'Strong Bear Gauge'
const string swb = 'Weak Bull Gauge'
const string sws = 'Weak Bear Gauge'
const string shs = 'High Squeeze'
const string sms = 'Normal Squeeze'
const string sls = 'Low Squeeze'
const string sds = 'Bearish Divergence'
const string sdb = 'Bullish Divergence'

dfb = input.bool(true, "", inline='1', group=gd)
dfl = input.int(30, "Length", 7, 50, 1, inline='1', group=gd, tooltip=tm)
dfh = input.bool(false, "Trend Bias", group=gd)
cps = input.color(GREEN_COLOR, "", inline='2', group=gd)
cng = input.color(RED_COLOR, "", inline='2', group=gd)
cpo = input.color(GREEN_COLOR, "", inline='3', group=gd)
cno = input.color(RED_COLOR, "", inline='3', group=gd)
smb = input.bool(true, "", inline='1', group=go)
len = input.int(20, "Length", 7, 50, 1, inline='1', group=go, tooltip=tm)
sig = input.int(3, "Signal", 2, 7, 1, inline='2', group=go, tooltip=ts)
cup = input.color(WHITE_COLOR, "", inline='3', group=go)
cdn = input.color(AQUA_COLOR, "", inline='3', group=go)
cpf = input.color(WHITE_COLOR, "", inline='4', group=go)
cdf = input.color(AQUA_COLOR, "", inline='4', group=go)
trs = input.int(25, "Sensitivity", 20, 40, 1, inline='5', group=gl, tooltip=td)
dbl = input.bool(true, "Lines", group=gl)
dbs = input.bool(true, "Labels", group=gl)
cdu = input.color(WHITE_COLOR, "", inline='1', group=gl)
cdd = input.color(AQUA_COLOR, "", inline='1', group=gl)
gds = input.string('Both', "Showcase", ['Both', 'Bull', 'Bear', 'None'], inline='4', group=gg, tooltip=tg)
cgp = input.color(GREEN_COLOR, "", inline='2', group=gg)
cgn = input.color(RED_COLOR, "", inline='2', group=gg)

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

//-----------------------------------------------------------------------------
// UDTs
//-----------------------------------------------------------------------------
// Bar data type
type bar
    float o = open
    float h = high
    float l = low
    float c = close
    int   i = bar_index

// Oscillator data type
type osc
    float o = na
    float s = na

// Squeeze status type
type squeeze
    bool h = false
    bool m = false
    bool l = false

// Gauge display type
type gauge
    float u = na
    float l = na
    color c = chart.fg_color
    bool  p = true

// Divergence data type
type divergence
    float p = na
    float s = na
    int   i = na

// Alerts state type
type alerts
    bool b = false
    bool s = false
    bool u = false
    bool d = false
    bool p = false
    bool n = false
    bool x = false
    bool y = false
    bool a = false
    bool c = false
    bool q = false
    bool w = false
    bool h = false
    bool m = false
    bool l = false
    bool e = false
    bool f = false

// Prompt message type
type prompt
    string s = ''
    bool   c = false

//-----------------------------------------------------------------------------
// Methods
//-----------------------------------------------------------------------------
method notify(prompt p) =>
    if p.c
        alert(p.s, alert.freq_once_per_bar_close)
        
method any(alerts a) =>
    string s = switch
        a.s => ss       
        a.b => sb       
        a.u => sob  
        a.d => sos  
        a.p => sfb  
        a.n => sfs  
        a.x => sss     
        a.y => ssb     
        a.q => sgb 
        a.w => sgs 
        a.a => swb 
        a.c => sws 
        a.h => shs    
        a.m => sms    
        a.l => sls    
        a.e => sds
        a.f => sdb
        => na
    prompt.new(s, not na(s))
        
method src(bar b, simple string src) =>
    if na(b)
        na
    else
        float x = switch src
            'oc2' => math.avg(b.o, b.c)
            'hl2' => math.avg(b.h, b.l)
            'hlc3' => math.avg(b.h, b.l, b.c)
            'ohlc4' => math.avg(b.o, b.h, b.l, b.c)
            'hlcc4' => math.avg(b.h, b.l, b.c, b.c)
        x

method ha(bar b, simple bool p = true) =>
    bar x = bar.new()
    x.c := barstate.isfirst or na(b) ? close : b.src('ohlc4')
    x := barstate.isfirst or na(b) or na(b.h) or na(x) or na(x[1]) ? na : bar.new(na((x[1]).o) ? b.src('oc2') : nz(x.src('oc2')[1]), math.max(b.h, math.max(x.o, x.c)), math.min(b.l, math.min(x.o, x.c)), x.c)
    p ? x : b

method atr(bar b, simple int len = 1) =>
    float tr = barstate.isfirst or na(b) or na(b.h) or na(b.l) or na(b.c) or na((b[1]).h) or na((b[1]).c) ? na : math.max(math.max(b.h - b.l, math.abs(b.h - (b[1]).c)), math.abs(b.l - (b[1]).c))
    len == 1 ? tr : ta.rma(tr, len)

method stdev(float src, simple int len) =>
    float sq = 0.
    float psq = 0.
    float sum = 0.
    for k = 0 to len - 1
        val = nz(src[k])
        psq := sq
        sq += (val - sq) / (1 + k)
        sum += (val - sq) * (val - psq)
    math.sqrt(sum / (len - 1))

method osc(bar b, simple int sig, simple int len) =>
    float av = ta.sma(b.src('hl2'), len)
    bar z = bar.new(b.o, ta.highest(len), ta.lowest(len), b.c)
    float x = ta.linreg((z.c - math.avg(z.src('hl2'), av)) / z.atr() * 100, len, 0)
    osc.new(x, ta.sma(x, sig))

method dfo(bar b, simple int len) =>
    float tr = b.atr(len)
    float up = ta.rma(math.max(ta.change(b.h), 0), len) / tr
    float dn = ta.rma(math.max(ta.change(b.l) * -1, 0), len) / tr
    float x = ta.rma((up - dn) / (up + dn), len / 2) * 100
    osc.new(x, x > 25 ? x - 25 : x < -25 ? x + 25 : na)

method sqz(bar b, simple int len) =>
    array<bool> sqz = array.new<bool>()
    float dev = b.c.stdev(len)
    float atr = b.atr(len)
    for i = 2 to 4
        sqz.unshift(dev < atr * 0.25 * i)
    squeeze.new(sqz.pop(), sqz.pop(), sqz.pop())

method draw(bar b, osc o, simple int trs, simple bool s) =>
    var divergence d = divergence.new()
    bool u = ta.crossunder(o.o, o.s)
    bool l = ta.crossover(o.o, o.s)
    float x = o.s
    bool p = false

    switch
        // Bearish divergence
        o.o > trs and u and barstate.isconfirmed =>
            switch
                na(d.p) =>
                    d := divergence.new(b.h, x, b.i)
                    p := false

                not na(d.p) =>
                    if b.h > d.p and x < d.s
                        if s
                            line.new(d.i, d.s, b.i, x, xloc.bar_index, extend.none, cdd)
                        d := divergence.new()
                        p := true
                    else
                        d := divergence.new(b.h, x, b.i)
                        p := false
        // Bullish divergence
        o.o < -trs and l and barstate.isconfirmed =>
            switch
                na(d.p) =>
                    d := divergence.new(b.l, x, b.i)
                    p := false

                not na(d.p) =>
                    if b.l < d.p and x > d.s
                        if s
                            line.new(d.i, d.s, b.i, x, xloc.bar_index, extend.none, cdu)
                        d := divergence.new()
                        p := true
                    else
                        d := divergence.new(b.l, x, b.i)
                        p := false

    p

//-----------------------------------------------------------------------------
// Calculation
//-----------------------------------------------------------------------------
bar     b = bar.new(open, high, low, close)
squeeze s = b.sqz(len)
osc     o = b.osc(sig, len)
osc     v = b.ha(dfh).dfo(dfl)
bool    p = b.draw(o, trs, dbl)
u = gauge.new(+75, +70, v.o > 0 and o.o > 0 ? cgp : v.o > 0 or o.o > 0 ? color.new(cgp, 40) : DARK_GRAY_COLOR, gds == 'Both' or gds == 'Bull')
d = gauge.new(-75, -70, v.o < 0 and o.o < 0 ? cgn : v.o < 0 or o.o < 0 ? color.new(cgn, 40) : DARK_GRAY_COLOR, gds == 'Both' or gds == 'Bear')

alerts a = alerts.new(ta.crossover(o.o, o.s) and o.o < -40 and v.o < 0, ta.crossunder(o.o, o.s) and o.o > +40 and v.o > 0, ta.crossover(o.o, 0), ta.crossunder(o.o, 0), ta.crossover(v.o, 0), ta.crossunder(v.o, 0), ta.crossunder(o.o, o.s) and smb, ta.crossover(o.o, o.s) and smb, ta.change(u.c == LIGHT_GRAY_COLOR) and u.c == color.new(cgp, 40), ta.change(d.c == LIGHT_GRAY_COLOR) and d.c == color.new(cgn, 40), ta.change(u.c == LIGHT_GRAY_COLOR) and u.c == cgp, ta.change(d.c == LIGHT_GRAY_COLOR) and d.c == cng, ta.change(s.h) and s.h, ta.change(s.m) and s.m, ta.change(s.l) and s.l, p and o.o > trs, p and o.o < -trs)

//-----------------------------------------------------------------------------
// Render
//-----------------------------------------------------------------------------
color colsq = s.h ? #023e8a : s.m ? #0096c7 : #48cae4
color colvf = v.o > 0 ? color.new(cps, 70) : color.new(cng, 70)
color colof = v.s > 0 ? color.new(cpo, 70) : color.new(cno, 70)
color colsf = o.o > o.s ? color.new(cpf, 50) : color.new(cdf, 50)
color colzf = o.o > o.s ? cup : cdn

l  = plot(dfb ? v.o : na, "Flux", colvf, 1, plot.style_area, display = display.pane)
z  = plot(dfb ? v.s : na, "OverFlux", colof, 1, plot.style_areabr, display = display.pane)
w  = plot(smb ? o.o : na, "Mom", colzf, 1, plot.style_line, display = display.pane)
q  = plot(1, "Squeeze", color = s.l ? colsq : LIGHT_GRAY_COLOR, linewidth = 1, style = plot.style_columns, trackprice = false, histbase = -1, display=display.pane)
j  = plot(a.x ? o.s : na, "Trend Shift", cdf, 2, plot.style_circles, display=display.pane)
k  = plot(a.y ? o.o : na, "Trend Shift", cpf, 2, plot.style_circles, display=display.pane)
c  = plot(smb ? o.s : na, "Signal", display=display.none)
ll = plot(d.p ? d.l : na, "Lower Gauge", display=display.none)
hl = plot(d.p ? d.u : na, "Lower Gauge", display=display.none)
hh = plot(u.p ? u.u : na, "Upper Gauge", display=display.none)
lh = plot(u.p ? u.l : na, "Upper Gauge", display=display.none)

plotshape(u.p and a.s ? u.u + 10 : na, "Confluence Sell", shape.triangledown, location.absolute, AQUA_COLOR, size=size.tiny, display = display.pane)
plotshape(d.p and a.b ? d.l - 15 : na, "Confluence Buy", shape.triangleup, location.absolute, WHITE_COLOR, size=size.tiny, display = display.pane)

fill(w, c, colsf)
fill(lh, hh, u.c)
fill(ll, hl, d.c)

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


//-----------------------------------------------------------------------------
// ATR Levels
//-----------------------------------------------------------------------------
// Settings
//-----------------------------------------------------------------------------
alGrp= "ATR Levels"
alShowed= input.bool(true, title="Show", group=alGrp)
alDayTradingOption = 'Day'
alMultidayTradingOption = 'Multiday'
alSwingTradingOption = 'Swing'
alTradingType = input.string(alDayTradingOption, 'Trading Type', options=[alDayTradingOption, alMultidayTradingOption, alSwingTradingOption], group=alGrp)
alLength = input.int(14, 'ATR Length', group=alGrp)
alTriggerPerc = input.float(0.236, 'Trigger Percentage', group=alGrp)
alPrevCloseLevelColor = input.color(WHITE_COLOR, 'Previous Close Level Color', group=alGrp)
alLowerTriggerLevelColor = input.color(PURPLE_COLOR, 'Lower Trigger Level Color', group=alGrp)
alUpperTriggerLevelColor = input.color(PURPLE_COLOR, 'Upper Trigger Level Color', group=alGrp)
alKeyTargetLevelColor = input.color(YELLOW_COLOR, 'Key Target Level Color', group=alGrp)
alAtrTargetLevelColor = input.color(WHITE_COLOR, 'ATR Target Level Color', group=alGrp)
alIntermediateTargetLevelColor = input.color(LIGHT_GRAY_COLOR, 'Intermediate Target Level Color', group=alGrp)
alShowAllFibLevels = input.bool(true, 'Show All Fibonacci Levels', group=alGrp)
alFastEma = input.int(8, 'Fast EMA', group=alGrp)
alPivotEma = input.int(21, 'Pivot EMA', group=alGrp)
alSlowEma = input.int(34, 'Slow EMA', group=alGrp)
alOffset = input.int(5, "Offset", group=alGrp)

//-----------------------------------------------------------------------------
// Methods
//-----------------------------------------------------------------------------
// Set the appropriate timeframe based on trading mode
getAlTf() =>
    timeframe = 'D'
    if alTradingType == alDayTradingOption
        timeframe := 'D'
    else if alTradingType == alMultidayTradingOption
        timeframe := 'W'
    else if alTradingType == alSwingTradingOption
        timeframe := 'M'
    else
        timeframe := 'D'

//-----------------------------------------------------------------------------
// Values
//-----------------------------------------------------------------------------
// Trend
price = close
alFastEmaVal = ta.ema(price, alFastEma)
alPivotEmaVal = ta.ema(price, alPivotEma)
alSlowEmaVal = ta.ema(price, alSlowEma)

// Data
alPeriodIdx = 1
alTicker = ticker.new(syminfo.prefix, syminfo.ticker, session=session.extended)
alPrevClose = request.security(alTicker, getAlTf(), close[alPeriodIdx], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
atr = request.security(alTicker, getAlTf(), ta.atr(alLength)[alPeriodIdx], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
alPeriodHigh = request.security(alTicker, getAlTf(), high, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
alPeriodLow = request.security(alTicker, getAlTf(), low, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
alRange1 = alPeriodHigh - alPeriodLow
alTrPercOfAtr = alRange1 / atr * 100
alLowerTrigger = alPrevClose - alTriggerPerc * atr
alUpperTrigger = alPrevClose + alTriggerPerc * atr
alLower0382 = alPrevClose - atr * 0.382
alUpper0382 = alPrevClose + atr * 0.382
alLower0500 = alPrevClose - atr * 0.5
alUpper0500 = alPrevClose + atr * 0.5
alLower0618 = alPrevClose - atr * 0.618
alUpper0618 = alPrevClose + atr * 0.618
alLower0786 = alPrevClose - atr * 0.786
alUpper0786 = alPrevClose + atr * 0.786
alLower1000 = alPrevClose - atr
alUpper1000 = alPrevClose + atr

//-----------------------------------------------------------------------------
// Render
//-----------------------------------------------------------------------------
alChar = '-'
plotchar(alLower1000, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alAtrTargetLevelColor, size=size.normal, title="-100%", force_overlay = true, display = display.pane)
plotchar(alShowAllFibLevels ? alLower0786 : na, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alIntermediateTargetLevelColor, size=size.normal, title="-78.6%", force_overlay = true, display = display.pane)
plotchar(alLower0618, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alKeyTargetLevelColor, size=size.normal, title="-78.6%", force_overlay = true, display = display.pane)
plotchar(alShowAllFibLevels ? alLower0500 : na, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alIntermediateTargetLevelColor, size=size.normal, title="-50.0%", force_overlay = true, display = display.pane)
plotchar(alShowAllFibLevels ? alLower0382 : na, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alIntermediateTargetLevelColor, size=size.normal, title="-38.2%", force_overlay = true, display = display.pane)
plotchar(alLowerTrigger, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alLowerTriggerLevelColor, size=size.normal, title="Lower Trigger", force_overlay = true, display = display.pane)
plotchar(alPrevClose, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alPrevCloseLevelColor, size=size.normal, title="Previous Close", force_overlay = true, display = display.pane)
plotchar(alUpperTrigger, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alUpperTriggerLevelColor, size=size.normal, title="Upper Trigger", force_overlay = true, display = display.pane)
plotchar(alShowAllFibLevels ? alUpper0382 : na, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alIntermediateTargetLevelColor, size=size.normal, title="38.2%", force_overlay = true, display = display.pane)
plotchar(alShowAllFibLevels ? alUpper0500 : na, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alIntermediateTargetLevelColor, size=size.normal, title="50.0%", force_overlay = true, display = display.pane)
plotchar(alUpper0618, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alKeyTargetLevelColor, size=size.normal, title="61.8%", force_overlay = true, display = display.pane)
plotchar(alShowAllFibLevels ? alUpper0786 : na, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alIntermediateTargetLevelColor, size=size.normal, title="78.6%", force_overlay = true, display = display.pane)
plotchar(alUpper1000, char=alChar, show_last=1, location=location.absolute, offset=alOffset, color=alAtrTargetLevelColor, size=size.normal, title="100%", force_overlay = true, display = display.pane)

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


//-----------------------------------------------------------------------------
// Ripster EMA Clouds
//-----------------------------------------------------------------------------
// Settings
//-----------------------------------------------------------------------------
ripsterEmaCloudsGrp    = "Ripster EMA Clouds"
ripsterEmaCloudsShowed = input.bool(true, title="Show", group=ripsterEmaCloudsGrp)
ripsterEmaCloudsSrc    = input.source(hl2, title="Source", group=ripsterEmaCloudsGrp)
ripsterEmaCloudsTf     = input.timeframe("", title="Timeframe", group=ripsterEmaCloudsGrp)
shortEma1Len           = input.int(8, title="Short EMA 1 Length", group=ripsterEmaCloudsGrp)
longEma1Len            = input.int(9, title="Long EMA 1 Length", group=ripsterEmaCloudsGrp)
ema1CloudShowed        = input.bool(true, title="Show EMA Cloud 1", group=ripsterEmaCloudsGrp)
shortEma2Len           = input.int(5, title="Short EMA 2 Length", group=ripsterEmaCloudsGrp)
longEma2Len            = input.int(12, title="Long EMA 2 Length", group=ripsterEmaCloudsGrp)
ema2CloudShowed        = input.bool(true, title="Show EMA Cloud 2", group=ripsterEmaCloudsGrp)
shortEma3Len           = input.int(20, title="Short EMA 3 Length", group=ripsterEmaCloudsGrp)
longEma3Len            = input.int(21, title="Long EMA 3 Length", group=ripsterEmaCloudsGrp)
ema3CloudShowed        = input.bool(true, title="Show EMA Cloud 3", group=ripsterEmaCloudsGrp)
shortEma4Len           = input.int(34, title="Short EMA 4 Length", group=ripsterEmaCloudsGrp)
longEma4Len            = input.int(50, title="Long EMA 4 Length", group=ripsterEmaCloudsGrp)
ema4CloudShowed        = input.bool(true, title="Show EMA Cloud 4", group=ripsterEmaCloudsGrp)
shortEma5Len           = input.int(180, title="Short EMA 5 Length", group=ripsterEmaCloudsGrp)
longEma5Len            = input.int(200, title="Long EMA 5 Length", group=ripsterEmaCloudsGrp)
ema5CloudShowed        = input.bool(true, title="Show EMA Cloud 5", group=ripsterEmaCloudsGrp)

//-----------------------------------------------------------------------------
// Values
//-----------------------------------------------------------------------------
shortEma1 = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, shortEma1Len))
longEma1  = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, longEma1Len))
shortEma2 = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, shortEma2Len))
longEma2  = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, longEma2Len))
shortEma3 = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, shortEma3Len))
longEma3  = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, longEma3Len))
shortEma4 = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, shortEma4Len))
longEma4  = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, longEma4Len))
shortEma5 = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, shortEma5Len))
longEma5  = request.security(syminfo.tickerid, ripsterEmaCloudsTf, ta.ema(ripsterEmaCloudsSrc, longEma5Len))

cloudcolour1 = shortEma1 >= longEma1 ? AQUA_COLOR : RED_COLOR
cloudcolour2 = shortEma2 >= longEma2 ? AQUA_COLOR : RED_COLOR
cloudcolour3 = shortEma3 >= longEma3 ? PINK_COLOR : YELLOW_COLOR
cloudcolour4 = shortEma4 >= longEma4 ? GREEN_COLOR : PURPLE_COLOR
cloudcolour5 = shortEma5 >= longEma5 ? BLUE_COLOR : ORANGE_COLOR

//-----------------------------------------------------------------------------
// Render
//-----------------------------------------------------------------------------
shortEma1Line = plot(ripsterEmaCloudsShowed and ema1CloudShowed ? shortEma1 : na, color=na, linewidth=1, title="Short EMA 1", display = display.pane, force_overlay = true)
shortEma2Line = plot(ripsterEmaCloudsShowed and ema2CloudShowed ? shortEma2 : na, color=na, linewidth=1, title="Short EMA 2", display = display.pane, force_overlay = true)
shortEma3Line = plot(ripsterEmaCloudsShowed and ema3CloudShowed ? shortEma3 : na, color=na, linewidth=1, title="Short EMA 3", display = display.pane, force_overlay = true)
shortEma4Line = plot(ripsterEmaCloudsShowed and ema4CloudShowed ? shortEma4 : na, color=na, linewidth=1, title="Short EMA 4", display = display.pane, force_overlay = true)
shortEma5Line = plot(ripsterEmaCloudsShowed and ema5CloudShowed ? shortEma5 : na, color=na, linewidth=1, title="Short EMA 5", display = display.pane, force_overlay = true)

longEma1Line = plot(ripsterEmaCloudsShowed and ema1CloudShowed ? longEma1 : na, color=na, linewidth=3, title="Long EMA 1", display = display.pane, force_overlay = true)
longEma2Line = plot(ripsterEmaCloudsShowed and ema2CloudShowed ? longEma2 : na, color=na, linewidth=3, title="Long EMA 2", display = display.pane, force_overlay = true)
longEma3Line = plot(ripsterEmaCloudsShowed and ema3CloudShowed ? longEma3 : na, color=na, linewidth=3, title="Long EMA 3", display = display.pane, force_overlay = true)
longEma4Line = plot(ripsterEmaCloudsShowed and ema4CloudShowed ? longEma4 : na, color=na, linewidth=3, title="Long EMA 4", display = display.pane, force_overlay = true)
longEma5Line = plot(ripsterEmaCloudsShowed and ema5CloudShowed ? longEma5 : na, color=na, linewidth=3, title="Long EMA 5", display = display.pane, force_overlay = true)

fill(shortEma1Line, longEma1Line, color=color.new(cloudcolour1, 80), title="EMA Cloud 1")
fill(shortEma2Line, longEma2Line, color=color.new(cloudcolour2, 80), title="EMA Cloud 2")
fill(shortEma3Line, longEma3Line, color=color.new(cloudcolour3, 60), title="EMA Cloud 3")
fill(shortEma4Line, longEma4Line, color=color.new(cloudcolour4, 80), title="EMA Cloud 4")
fill(shortEma5Line, longEma5Line, color=color.new(cloudcolour5, 80), title="EMA Cloud 5")

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

Overview

Oscillator calculates momentum dynamics and squeeze conditions, highlights regular or hidden divergences with lines and labels, and computes ATR-based trigger and key target levels. Users can customize calculation lengths, divergence sensitivity, signal thresholds, and visual elements.

Details

Published by

TamTH-Dev on GitHub

Code credit

tamth_, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Divergence, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

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

SettingTypeDefaultVariable
dfbbooltruedfb
Lengthint30dfl
Trend Biasboolfalsedfh
cpscolorGREEN_COLORcps
cngcolorRED_COLORcng
cpocolorGREEN_COLORcpo
cnocolorRED_COLORcno
smbbooltruesmb
Lengthint20len
Signalint3sig
cupcolorWHITE_COLORcup
cdncolorAQUA_COLORcdn
Show all 40 settings
SettingTypeDefaultVariable
cpfcolorWHITE_COLORcpf
cdfcolorAQUA_COLORcdf
Sensitivityint25trs
Linesbooltruedbl
Labelsbooltruedbs
cducolorWHITE_COLORcdu
cddcolorAQUA_COLORcdd
ShowcasestringBothgds
cgpcolorGREEN_COLORcgp
cgncolorRED_COLORcgn
ShowbooltruealShowed
Trading TypestringalDayTradingOptionalTradingType
ATR Lengthint14alLength
Trigger Percentagefloat0.236alTriggerPerc
Previous Close Level ColorcolorWHITE_COLORalPrevCloseLevelColor
Lower Trigger Level ColorcolorPURPLE_COLORalLowerTriggerLevelColor
Upper Trigger Level ColorcolorPURPLE_COLORalUpperTriggerLevelColor
Key Target Level ColorcolorYELLOW_COLORalKeyTargetLevelColor
ATR Target Level ColorcolorWHITE_COLORalAtrTargetLevelColor
Intermediate Target Level ColorcolorLIGHT_GRAY_COLORalIntermediateTargetLevelColor
Show All Fibonacci LevelsbooltruealShowAllFibLevels
Fast EMAint8alFastEma
Pivot EMAint21alPivotEma
Slow EMAint34alSlowEma
Offsetint5alOffset
ShowbooltrueripsterEmaCloudsShowed
Sourcesourcehl2ripsterEmaCloudsSrc
TimeframetimeframeripsterEmaCloudsTf
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

330 stars

This indicator plots a TTM Squeeze momentum oscillator and a MACD line in a separate pane. It builds the squeeze oscillator from a linear regression of price against a high-low and simple moving average midpoint, and colors the area by slope and sign. Circles

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of TTM Squeeze + MACD line [Alorse]

Bubbles Indicator

by capissimo
114 stars

The Bubbles Indicator measures volatility squeezes and expansion bursts using Bollinger Bands combined with a sinusoid oscillator and RSI divergence. It processes price data through scaled Bollinger Bands to highlight volatility changes while confirming trend

Indicator v4 Volatility & bandsOscillators & momentum Repaints
Updated 1 year ago · None stated GitHub repository of Bubbles Indicator

TTM Squeeze Divergence

by TamaraKGreen
46 stars

The TTM Squeeze Divergence indicator plots a classic TTM Squeeze momentum oscillator in a separate pane alongside Bollinger Bands and Keltner Channels squeeze status dots on the zero line. It detects regular and hidden bullish and bearish divergences between p

Indicator v6 Oscillators & momentumVolatility & bands Repaints
Updated 7 weeks ago · None stated GitHub repository of TTM Squeeze Divergence

Relative Strength Index

by deepentropy
13 stars

This indicator plots the Relative Strength Index in a separate pane from smoothed up and down price changes. It draws the RSI line with horizontal bands at 70, 50 and 30, plus overbought and oversold gradient fills. Optional settings add a smoothing moving ave

Indicator v6 Oscillators & momentumMoving averages
Updated 6 months ago · MIT GitHub repository of Relative Strength Index

QFA Pro Elite Refined

by JasonTeixeira
9 stars

This indicator plots a smoothed fear index in a separate pane. It measures how far the current low sits below the highest close over a lookback, scales that reading by an ATR percentile, and smooths it with a zero-lag EMA. A volatility regime raises or lowers

Indicator v6 Oscillators & momentumVolatility & bands
Updated 12 days ago · Custom licence GitHub repository of QFA Pro Elite Refined

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