Indicator · Pine Script v5 · Own pane

Intermediate Stochastic

by benso87

This indicator plots a smoothed stochastic oscillator in a separate pane, with K and D lines, a midsection background, and adjustable overbought and oversold levels.

View on GitHub

GitHub stars24on the repository
Pine versionv5runs as is
Lines of code246
Settings40inputs
LicenceMPL-2.0
Last update4 years ago5 Oct 2022

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

246 lines of Pine Script v5 from Intermediate Stoch.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Intermediate Stoch.pine
//@version=5
//
// Author: benso87
// benso87.com
//
// Credit to Alex Orekhov (everget) for Stoch crossovers
// Credit to SparkyFlary for ADX Historgram with DI Lines
// Credit to The_Caretaker for BBWP
// Credit to KVDB for the Advanced Stochastic indicator for inspiration
//
indicator('Intermediate Stochastic', shorttitle='Int Stoch', precision=2, max_bars_back=500)


////////////////////////////////////////////////////////////
// Variables

var c_prcntSpctrm1 = array.new_color(na)
if barstate.isfirst
    array.push(c_prcntSpctrm1, #0000FF )
    array.push(c_prcntSpctrm1, #000AFF ), array.push(c_prcntSpctrm1, #0014FF ), array.push(c_prcntSpctrm1, #001FFF ), array.push(c_prcntSpctrm1, #0029FF ), array.push(c_prcntSpctrm1, #0033FF ),
    array.push(c_prcntSpctrm1, #003DFF ), array.push(c_prcntSpctrm1, #0047FF ), array.push(c_prcntSpctrm1, #0052FF ), array.push(c_prcntSpctrm1, #005CFF ), array.push(c_prcntSpctrm1, #0066FF ),
    array.push(c_prcntSpctrm1, #0070FF ), array.push(c_prcntSpctrm1, #007AFF ), array.push(c_prcntSpctrm1, #0085FF ), array.push(c_prcntSpctrm1, #008FFF ), array.push(c_prcntSpctrm1, #0099FF ),
    array.push(c_prcntSpctrm1, #00A3FF ), array.push(c_prcntSpctrm1, #00ADFF ), array.push(c_prcntSpctrm1, #00B8FF ), array.push(c_prcntSpctrm1, #00C2FF ), array.push(c_prcntSpctrm1, #00CCFF ),
    array.push(c_prcntSpctrm1, #00D6FF ), array.push(c_prcntSpctrm1, #00E0FF ), array.push(c_prcntSpctrm1, #00EBFF ), array.push(c_prcntSpctrm1, #00F5FF ), array.push(c_prcntSpctrm1, #00FFFF ),
    array.push(c_prcntSpctrm1, #00FFF5 ), array.push(c_prcntSpctrm1, #00FFEB ), array.push(c_prcntSpctrm1, #00FFE0 ), array.push(c_prcntSpctrm1, #00FFD6 ), array.push(c_prcntSpctrm1, #00FFCC ),
    array.push(c_prcntSpctrm1, #00FFC2 ), array.push(c_prcntSpctrm1, #00FFB8 ), array.push(c_prcntSpctrm1, #00FFAD ), array.push(c_prcntSpctrm1, #00FFA3 ), array.push(c_prcntSpctrm1, #00FF99 ),
    array.push(c_prcntSpctrm1, #00FF8F ), array.push(c_prcntSpctrm1, #00FF85 ), array.push(c_prcntSpctrm1, #00FF7A ), array.push(c_prcntSpctrm1, #00FF70 ), array.push(c_prcntSpctrm1, #00FF66 ),
    array.push(c_prcntSpctrm1, #00FF5C ), array.push(c_prcntSpctrm1, #00FF52 ), array.push(c_prcntSpctrm1, #00FF47 ), array.push(c_prcntSpctrm1, #00FF3D ), array.push(c_prcntSpctrm1, #00FF33 ),
    array.push(c_prcntSpctrm1, #00FF29 ), array.push(c_prcntSpctrm1, #00FF1F ), array.push(c_prcntSpctrm1, #00FF14 ), array.push(c_prcntSpctrm1, #00FF0A ), array.push(c_prcntSpctrm1, #00FF00 ),
    array.push(c_prcntSpctrm1, #0AFF00 ), array.push(c_prcntSpctrm1, #14FF00 ), array.push(c_prcntSpctrm1, #1FFF00 ), array.push(c_prcntSpctrm1, #29FF00 ), array.push(c_prcntSpctrm1, #33FF00 ),
    array.push(c_prcntSpctrm1, #3DFF00 ), array.push(c_prcntSpctrm1, #47FF00 ), array.push(c_prcntSpctrm1, #52FF00 ), array.push(c_prcntSpctrm1, #5CFF00 ), array.push(c_prcntSpctrm1, #66FF00 ),
    array.push(c_prcntSpctrm1, #70FF00 ), array.push(c_prcntSpctrm1, #7AFF00 ), array.push(c_prcntSpctrm1, #85FF00 ), array.push(c_prcntSpctrm1, #8FFF00 ), array.push(c_prcntSpctrm1, #99FF00 ),
    array.push(c_prcntSpctrm1, #A3FF00 ), array.push(c_prcntSpctrm1, #ADFF00 ), array.push(c_prcntSpctrm1, #B8FF00 ), array.push(c_prcntSpctrm1, #C2FF00 ), array.push(c_prcntSpctrm1, #CCFF00 ),
    array.push(c_prcntSpctrm1, #D6FF00 ), array.push(c_prcntSpctrm1, #E0FF00 ), array.push(c_prcntSpctrm1, #EBFF00 ), array.push(c_prcntSpctrm1, #F5FF00 ), array.push(c_prcntSpctrm1, #FFFF00 ),
    array.push(c_prcntSpctrm1, #FFF500 ), array.push(c_prcntSpctrm1, #FFEB00 ), array.push(c_prcntSpctrm1, #FFE000 ), array.push(c_prcntSpctrm1, #FFD600 ), array.push(c_prcntSpctrm1, #FFCC00 ),
    array.push(c_prcntSpctrm1, #FFC200 ), array.push(c_prcntSpctrm1, #FFB800 ), array.push(c_prcntSpctrm1, #FFAD00 ), array.push(c_prcntSpctrm1, #FFA300 ), array.push(c_prcntSpctrm1, #FF9900 ),
    array.push(c_prcntSpctrm1, #FF8F00 ), array.push(c_prcntSpctrm1, #FF8500 ), array.push(c_prcntSpctrm1, #FF7A00 ), array.push(c_prcntSpctrm1, #FF7000 ), array.push(c_prcntSpctrm1, #FF6600 ),
    array.push(c_prcntSpctrm1, #FF5C00 ), array.push(c_prcntSpctrm1, #FF5200 ), array.push(c_prcntSpctrm1, #FF4700 ), array.push(c_prcntSpctrm1, #FF3D00 ), array.push(c_prcntSpctrm1, #FF3300 ),
    array.push(c_prcntSpctrm1, #FF2900 ), array.push(c_prcntSpctrm1, #FF1F00 ), array.push(c_prcntSpctrm1, #FF1400 ), array.push(c_prcntSpctrm1, #FF0000 ), array.push(c_prcntSpctrm1, #FF0000 )

var c_prcntSpctrm2 = array.new_color(na)
if barstate.isfirst
    array.push(c_prcntSpctrm2, #0000FF )
    array.push(c_prcntSpctrm2, #0200FC ), array.push(c_prcntSpctrm2, #0500F9 ), array.push(c_prcntSpctrm2, #0700F7 ), array.push(c_prcntSpctrm2, #0A00F4 ), array.push(c_prcntSpctrm2, #0C00F2 ),
    array.push(c_prcntSpctrm2, #0F00EF ), array.push(c_prcntSpctrm2, #1100ED ), array.push(c_prcntSpctrm2, #1400EA ), array.push(c_prcntSpctrm2, #1600E8 ), array.push(c_prcntSpctrm2, #1900E5 ),
    array.push(c_prcntSpctrm2, #1C00E2 ), array.push(c_prcntSpctrm2, #1E00E0 ), array.push(c_prcntSpctrm2, #2100DD ), array.push(c_prcntSpctrm2, #2300DB ), array.push(c_prcntSpctrm2, #2600D8 ),
    array.push(c_prcntSpctrm2, #2800D6 ), array.push(c_prcntSpctrm2, #2B00D3 ), array.push(c_prcntSpctrm2, #2D00D1 ), array.push(c_prcntSpctrm2, #3000CE ), array.push(c_prcntSpctrm2, #3300CC ),
    array.push(c_prcntSpctrm2, #3500C9 ), array.push(c_prcntSpctrm2, #3800C6 ), array.push(c_prcntSpctrm2, #3A00C4 ), array.push(c_prcntSpctrm2, #3D00C1 ), array.push(c_prcntSpctrm2, #3F00BF ),
    array.push(c_prcntSpctrm2, #4200BC ), array.push(c_prcntSpctrm2, #4400BA ), array.push(c_prcntSpctrm2, #4700B7 ), array.push(c_prcntSpctrm2, #4900B5 ), array.push(c_prcntSpctrm2, #4C00B2 ),
    array.push(c_prcntSpctrm2, #4F00AF ), array.push(c_prcntSpctrm2, #5100AD ), array.push(c_prcntSpctrm2, #5400AA ), array.push(c_prcntSpctrm2, #5600A8 ), array.push(c_prcntSpctrm2, #5900A5 ),
    array.push(c_prcntSpctrm2, #5B00A3 ), array.push(c_prcntSpctrm2, #5E00A0 ), array.push(c_prcntSpctrm2, #60009E ), array.push(c_prcntSpctrm2, #63009B ), array.push(c_prcntSpctrm2, #660099 ),
    array.push(c_prcntSpctrm2, #680096 ), array.push(c_prcntSpctrm2, #6B0093 ), array.push(c_prcntSpctrm2, #6D0091 ), array.push(c_prcntSpctrm2, #70008E ), array.push(c_prcntSpctrm2, #72008C ),
    array.push(c_prcntSpctrm2, #750089 ), array.push(c_prcntSpctrm2, #770087 ), array.push(c_prcntSpctrm2, #7A0084 ), array.push(c_prcntSpctrm2, #7C0082 ), array.push(c_prcntSpctrm2, #7F007F ),
    array.push(c_prcntSpctrm2, #82007C ), array.push(c_prcntSpctrm2, #84007A ), array.push(c_prcntSpctrm2, #870077 ), array.push(c_prcntSpctrm2, #890075 ), array.push(c_prcntSpctrm2, #8C0072 ),
    array.push(c_prcntSpctrm2, #8E0070 ), array.push(c_prcntSpctrm2, #91006D ), array.push(c_prcntSpctrm2, #93006B ), array.push(c_prcntSpctrm2, #960068 ), array.push(c_prcntSpctrm2, #990066 ),
    array.push(c_prcntSpctrm2, #9B0063 ), array.push(c_prcntSpctrm2, #9E0060 ), array.push(c_prcntSpctrm2, #A0005E ), array.push(c_prcntSpctrm2, #A3005B ), array.push(c_prcntSpctrm2, #A50059 ),
    array.push(c_prcntSpctrm2, #A80056 ), array.push(c_prcntSpctrm2, #AA0054 ), array.push(c_prcntSpctrm2, #AD0051 ), array.push(c_prcntSpctrm2, #AF004F ), array.push(c_prcntSpctrm2, #B2004C ),
    array.push(c_prcntSpctrm2, #B50049 ), array.push(c_prcntSpctrm2, #B70047 ), array.push(c_prcntSpctrm2, #BA0044 ), array.push(c_prcntSpctrm2, #BC0042 ), array.push(c_prcntSpctrm2, #BF003F ),
    array.push(c_prcntSpctrm2, #C1003D ), array.push(c_prcntSpctrm2, #C4003A ), array.push(c_prcntSpctrm2, #C60038 ), array.push(c_prcntSpctrm2, #C90035 ), array.push(c_prcntSpctrm2, #CC0033 ),
    array.push(c_prcntSpctrm2, #CE0030 ), array.push(c_prcntSpctrm2, #D1002D ), array.push(c_prcntSpctrm2, #D3002B ), array.push(c_prcntSpctrm2, #D60028 ), array.push(c_prcntSpctrm2, #D80026 ),
    array.push(c_prcntSpctrm2, #DB0023 ), array.push(c_prcntSpctrm2, #DD0021 ), array.push(c_prcntSpctrm2, #E0001E ), array.push(c_prcntSpctrm2, #E2001C ), array.push(c_prcntSpctrm2, #E50019 ),
    array.push(c_prcntSpctrm2, #E80016 ), array.push(c_prcntSpctrm2, #EA0014 ), array.push(c_prcntSpctrm2, #ED0011 ), array.push(c_prcntSpctrm2, #EF000F ), array.push(c_prcntSpctrm2, #F2000C ),
    array.push(c_prcntSpctrm2, #F4000A ), array.push(c_prcntSpctrm2, #F70007 ), array.push(c_prcntSpctrm2, #F90005 ), array.push(c_prcntSpctrm2, #FC0002 ), array.push(c_prcntSpctrm2, #FF0000 )

var string STM = 'Spectrum'
var string SLD = 'Solid'
var string BGR = 'Blue Green Red'
var string BR  = 'Blue Red'


////////////////////////////////////////////////////////////
// Inputs

midBackground = input.color(color.new(#311b92, transp=80), title='Midsection Background')

// Stoch
periodK = input.int(title='K', minval=1, defval=14, group='Stochastic')
smoothK = input.int(title='K Smoothing', minval=1, defval=6, group='Stochastic')
periodD = input.int(title='D Smoothing', minval=1, defval=3, group='Stochastic')
src = input(title='Source', defval=close, group='Stochastic')
iKColor = input.color(color.blue, title='K Color', group='Stochastic', inline='0')
iDColor = input.color(color.red, title='D Color', group='Stochastic', inline='0')
obLevel = input(title='Overbought Level', defval=80, group='Stochastic', inline='1')
obLevelColor = input.color(color.new(color.yellow, transp=50), title='', group='Stochastic', inline='1')
osLevel = input(title='Oversold Level', defval=20, group='Stochastic', inline='2')
osLevelColor = input.color(color.new(color.yellow, transp=50), title='', group='Stochastic', inline='2')
highlightBreakouts = input(title='Highlight Overbought/Oversold Breakouts ?', defval=false, group='Stochastic', inline='4')
breakoutColorHigh = input.color(color.new(color.blue, transp=70), title='Overbought', group='Stochastic', inline='5')
breakoutColorLow = input.color(color.new(color.red, transp=70), title='Oversold', group='Stochastic', inline='5')
highlightCrossovers = input(title='Highlight K/D Crossovers ?', defval=false, group='Stochastic', inline='6')
applyRibbonFilling = input(title='Apply Ribbon Filling ?', defval=false, group='Stochastic', inline='7')

// BBWP
i_priceSrc = input.source(close, 'Price Source', group='BBWP Properties')
i_basisType = input.string('SMA', 'Basis Type', options=['SMA', 'EMA', 'VWMA'], group='BBWP Properties')
i_bbwpLen = input.int(13, 'Length', minval=1, group='BBWP Properties')
i_bbwpLkbk = input.int(252, 'Lookback', minval=1, group='BBWP Properties')

i_c_bbwpTyped = input.string(STM, 'Color Type', options=[STM, SLD], inline='1', group='BBWP Plot Settings')
i_c_spctrmType = input.string(BGR, 'Spectrum', options=[BR, BGR], inline='1', group='BBWP Plot Settings')
i_c_bbwpsolid = input.color(#FFFF00, 'Solid', inline='1', group='BBWP Plot Settings')
i_bbwpWidth = input.int(2, 'Line Width', minval=1, maxval=4, inline='2', group='BBWP Plot Settings')

i_alrtsOn = input.bool(false, 'Alerts On', group='BBWP Visual Alerts')
i_upperLevel = input.int(98, 'Extreme High', minval=1, inline='1', group='BBWP Visual Alerts')
i_upperLevelCol = input.color(color.new(color.red, transp=70), '', inline='1', group='BBWP Visual Alerts')
i_lowerLevel = input.int(2, 'Extreme Low', minval=1, inline='2', group='BBWP Visual Alerts')
i_lowerLevelCol = input.color(color.new(color.aqua, transp=70), '', inline='2', group='BBWP Visual Alerts')

// ADX/DMI
dmiLength = input.int(14, title="Length", group='ADX/DMI')
dmiSmooth = input.int(8, title='Smoothing', group='ADX/DMI')
withAdx = input.bool(true, title="with ADX line?", group='ADX/DMI')
showFlips = input.bool(false, title='Mark DMI Flips?', group='ADX/DMI')
dmiColorPos = input.color(#008000, title='DMI Histogram Positive', group='ADX/DMI')
dmiColorNeg = input.color(#800000, title='DMI Histogram Negative', group='ADX/DMI')
dmiLineColor = input.color(color.new(color.white, transp=50), title='DMI Line', group='ADX/DMI')

adxColorType = input.string(STM, title='Color Type', options=[STM, SLD], inline='1', group='ADX Plot Settings')
adxColorSolid = input.color(color.white, title='Solid Color', inline='2', group='ADX Plot Settings')
adxColorLow = input.color(color.aqua, title='Low', inline='3', group='ADX Plot Settings')
adxColorMid = input.color(color.yellow, title='Mid', inline='3', group='ADX Plot Settings')
adxColorHigh = input.color(color.red, title='High', inline='3', group='ADX Plot Settings')
adxDirection = input.bool(false, title='Color ADX based on direction', inline='4', group='ADX Plot Settings')
adxUpColor = input.color(color.green, title='ADX Rising', inline='5', group='ADX Plot Settings')
adxDownColor = input.color(color.red, title='ADX Falling', inline='5', group='ADX Plot Settings')
adxLineWidth = input.int(2, title='Line Width', minval=1, maxval=4, inline='6', group='ADX Plot Settings')


////////////////////////////////////////////////////////////
// Functions

f_maType(_price, _len, _type ) =>
    _type == 'SMA' ? ta.sma(_price, _len ) : _type == 'EMA' ? ta.ema(_price, _len ) : ta.vwma(_price, _len )

f_bbwp(_price, _bbwLen, _bbwpLen, _type ) =>
    float _basis = f_maType(_price, _bbwLen, _type )
    float _dev = ta.stdev(_price, _bbwLen )
    _bbw =(_basis + _dev -(_basis - _dev )) / _basis
    _bbwSum = 0.0
    _len = bar_index < _bbwpLen ? bar_index : _bbwpLen
    for _i = 1 to _len by 1
        _bbwSum +=(_bbw[_i] > _bbw ? 0 : 1 )
        _bbwSum
    _return = bar_index >= _bbwLen ?(_bbwSum / _len) * 100 : na
    _return

f_clrSlct(_percent, _select, _type, _solid, _array1, _array2 ) =>
    _select == 'Solid' ? _solid : array.get(_type == 'Blue Green Red' ? _array1 : _array2, math.round(_percent ) )


////////////////////////////////////////////////////////////
// Calculations

noColor = color.new(color.white, 100)

// Stoch
k = ta.sma(ta.stoch(src, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

trendColor = k >= d ? iKColor : iDColor
kColor = applyRibbonFilling ? trendColor : iKColor
dColor = applyRibbonFilling ? trendColor : iDColor

defaultPlotColor = color.new(#989898, transp=0)

obFillColor = k > obLevel and highlightBreakouts ? breakoutColorHigh : na
osFillColor = k < osLevel and highlightBreakouts ? breakoutColorLow : na

kSlope = k - k[1]

kForecast = k + kSlope
dForecast = ta.sma(kForecast, periodD)

// BBWP
bbwp  = f_bbwp(i_priceSrc, i_bbwpLen, i_bbwpLkbk, i_basisType )
c_bbwp  = f_clrSlct(bbwp, i_c_bbwpTyped, i_c_spctrmType, i_c_bbwpsolid, c_prcntSpctrm1, c_prcntSpctrm2 )
hiAlrtBar = i_alrtsOn and bbwp >= i_upperLevel ? bbwp : na
loAlrtBar = i_alrtsOn and bbwp <= i_lowerLevel ? bbwp : na

// ADX/DMI
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, dmiLength)
plus = fixnan(100 * ta.rma(plusDM, dmiLength) / trur)
minus = fixnan(100 * ta.rma(minusDM, dmiLength) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), dmiLength)

diff = plus - minus
diffMA = ta.ema(diff, dmiSmooth)

dmiColor = plus>minus and diff>5 ? dmiColorPos : plus<minus and diff<-5 ? dmiColorNeg : plus>minus ? color.new(dmiColorPos, transp=50) : color.new(dmiColorNeg, transp=50)
adxColorSpectrum = adx >= 50 ? adxColorHigh : adx < 50 and adx >= 20 ? adxColorMid : adxColorLow
adxNormColor = adxColorType == STM ? adxColorSpectrum : adxColorSolid
adxDirColor = adx > adx[1] ? adxUpColor : adx < adx[1] ? adxDownColor : adxNormColor
adxColor = adxDirection ? adxDirColor : adxNormColor

dmiFlipUp = diff > 0 and diff[1] < 0
dmiFlipDown = diff < 0 and diff[1] > 0


////////////////////////////////////////////////////////////
// Plots

// Lines
maxLevelPlot = hline(100, title='Max Level', linestyle=hline.style_solid, color=defaultPlotColor)
level5Plot = hline(80, title='Level 5', linestyle=hline.style_dashed, color=defaultPlotColor)
level4Plot = hline(65, title='Level 4', linestyle=hline.style_dotted, color=defaultPlotColor)
midLevelPlot = hline(50, title='Mid Level', linestyle=hline.style_dashed, color=defaultPlotColor)
level2Plot = hline(35, title='Level 2', linestyle=hline.style_dotted, color=defaultPlotColor)
level1Plot = hline(20, title='Level 1', linestyle=hline.style_dashed, color=defaultPlotColor)
minLevelPlot = hline(0, title='Min Level', linestyle=hline.style_solid, color=defaultPlotColor)
fill(level1Plot, level5Plot, title='Midsection Background', color=midBackground)

obLevelPlot = hline(obLevel, title='Overbought Level', linestyle=hline.style_dashed, color=obLevelColor)
osLevelPlot = hline(osLevel, title='Oversold Level', linestyle=hline.style_dashed, color=osLevelColor)
fill(obLevelPlot, osLevelPlot, title='Middle Zone', color=color.new(color.purple, transp=95))

fill(maxLevelPlot, obLevelPlot, title='Upper Band Breakout', color=obFillColor)
fill(minLevelPlot, osLevelPlot, title='Lower Band Breakout', color=osFillColor)

// Stoch
kPlot = plot(k, title='K', color=kColor, linewidth=3)
dPlot = plot(d, title='D', color=dColor, linewidth=3)
fillColor = applyRibbonFilling ? color.new(trendColor, transp=70) : noColor
fill(kPlot, dPlot, title='Ribbon', color=fillColor)
plotshape(highlightCrossovers and barstate.isconfirmed and ta.crossover(k, d) ? k : na, title='K/D Crossover', location=location.absolute, style=shape.circle, size=size.tiny, color=kColor)
plotshape(highlightCrossovers and barstate.isconfirmed and ta.crossunder(k, d) ? d : na, title='K/D Crossunder', location=location.absolute, style=shape.circle, size=size.tiny, color=dColor)

plot(kForecast, title='K Forecast', color=iKColor, style=plot.style_circles, offset=1, show_last=1, linewidth=2)
plot(dForecast, title='D Forecast', color=iDColor, style=plot.style_circles, offset=1, show_last=1, linewidth=2)

// BBWP
p_bbwp = plot(bbwp,  'BBWP', c_bbwp, i_bbwpWidth, plot.style_line, editable=false )
p_hiAlrt = plot(hiAlrtBar, 'Extreme Hi', i_upperLevelCol, 1, plot.style_columns, histbase=0, editable=false )
p_loAlrt = plot(loAlrtBar, 'Extreme Lo', i_lowerLevelCol, 1, plot.style_columns, histbase=100, editable=false )

// ADX/DMI
plot(diff, title="DI Histogram", style=plot.style_histogram, linewidth=4, color=dmiColor)
plot(diffMA, title="DI Line", style=plot.style_line, color=dmiLineColor, linewidth=2)
plot(withAdx ? adx : na, title="ADX", style=plot.style_cross, color=adxColor, linewidth=adxLineWidth)
plotshape(showFlips ? dmiFlipUp : na, title='DMI Flips Up', style=shape.triangleup, location=location.bottom, color=dmiColorPos)
plotshape(showFlips ? dmiFlipDown : na, title='DMI Flips Down', style=shape.triangledown, location=location.bottom, color=dmiColorNeg)

Overview

Optional highlights mark overbought or oversold breakouts and K/D crossovers, and ribbon filling can shade the space between the lines. Settings also include Bollinger Band Width Percentile coloring, extreme high and low levels, optional alerts, and a DMI length. It does not define trade entries, exits, or a stop loss.

Details

Published by

benso87 on GitHub

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volatility & bands, Trend

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
Midsection Backgroundcolorcolor.new(#311b92, transp=80)midBackground
Kint14periodK
K Smoothingint6smoothK
D Smoothingint3periodD
Sourcesourceclosesrc
K Colorcolorcolor.blueiKColor
D Colorcolorcolor.rediDColor
Overbought Levelint80obLevel
obLevelColorcolorcolor.new(color.yellow, transp=50)obLevelColor
Oversold Levelint20osLevel
osLevelColorcolorcolor.new(color.yellow, transp=50)osLevelColor
Highlight Overbought/Oversold Breakouts ?boolfalsehighlightBreakouts
Show all 40 settings
SettingTypeDefaultVariable
Overboughtcolorcolor.new(color.blue, transp=70)breakoutColorHigh
Oversoldcolorcolor.new(color.red, transp=70)breakoutColorLow
Highlight K/D Crossovers ?boolfalsehighlightCrossovers
Apply Ribbon Filling ?boolfalseapplyRibbonFilling
Price Sourcesourceclosei_priceSrc
Basis TypestringSMAi_basisType
Lengthint13i_bbwpLen
Lookbackint252i_bbwpLkbk
Color TypestringSTMi_c_bbwpTyped
SpectrumstringBGRi_c_spctrmType
Solidcolor#FFFF00i_c_bbwpsolid
Line Widthint2i_bbwpWidth
Alerts Onboolfalsei_alrtsOn
Extreme Highint98i_upperLevel
i_upperLevelColcolorcolor.new(color.red, transp=70)i_upperLevelCol
Extreme Lowint2i_lowerLevel
i_lowerLevelColcolorcolor.new(color.aqua, transp=70)i_lowerLevelCol
Lengthint14dmiLength
Smoothingint8dmiSmooth
with ADX line?booltruewithAdx
Mark DMI Flips?boolfalseshowFlips
DMI Histogram Positivecolor#008000dmiColorPos
DMI Histogram Negativecolor#800000dmiColorNeg
DMI Linecolorcolor.new(color.white, transp=50)dmiLineColor
Color TypestringSTMadxColorType
Solid Colorcolorcolor.whiteadxColorSolid
Lowcolorcolor.aquaadxColorLow
Midcolorcolor.yellowadxColorMid
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

147 stars

This indicator generates trade entry signals and target levels optimized for 1-hour timeframes, designed for external signal extraction. It calculates 7-period and 16-period EMAs alongside 10-period RSI and ATR filters. Long signals occur when the fast EMA cro

Indicator v5 TrendOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of Signal Strategy 100 Candles of 1H Timeframe

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator

This indicator plots an oscillator in a separate pane. It builds several SuperTrend series across a user-defined factor range and step, using ATR as the band width. On each bar it measures the distance between the close and each SuperTrend output, then groups

Indicator v5 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of AI SuperTrend Clustering Oscillator [LuxAlgo]
29 stars

The Supertrended RSI [AlgoAlpha] indicator plots the Relative Strength Index combined with a Supertrend overlay in a separate indicator pane. It first computes standard RSI, with an optional Hull Moving Average smoothing step, and computes a secondary moving a

Indicator v5 Oscillators & momentumTrend
Updated 11 months ago · Custom licence GitHub repository of Supertrended RSI [AlgoAlpha]

Manias, Panics and Crashes

by MeridianAlgo
9 stars

Manias, Panics and Crashes is a separate-pane market regime indicator that quantifies market sentiment and systemic risk. It processes technical metrics including RSI, moving averages, and volume alongside optional intermarket data such as VIX volatility and c

Indicator v6 Oscillators & momentumVolatility & bands
Updated 4 months ago · MIT GitHub repository of Manias, Panics and Crashes

This indicator computes and plots multiple technical analysis features on a separate pane. It calculates EMA-based trend indicators including fast and slow EMAs along with their slope, momentum oscillators such as RSI, Stochastic RSI, and MACD histogram, WaveT

Indicator v6 TrendOscillators & momentum
Updated yesterday · MIT GitHub repository of Vein Feature Exporter Core 4H [WavesUnchained]

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