Indicator · Pine Script v6 · Own pane

Double Smoothed Stochastic MTF

by SiegerTerpstra· code credited to sajjetti

This indicator plots a multi-timeframe Double Smoothed Stochastic in a separate pane.

View on GitHub

GitHub stars5on the repository
Pine versionv6current
Lines of code143
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update9 months ago14 Jan 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

143 lines of Pine Script v6 from 4 - DSS MTF (v6).pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

4 - DSS MTF (v6).pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sajjetti

//@version=6

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

// Release:                     2025-12-29
// Update:                      2025-12-29
// Author:                      sajjetti
// Email:                       contact@sajjetti.ai
// Website:                     sajjetti.ai
// Profile:                     https://www.tradingview.com/u/stmd/
// Pineversion:                 6
// Filename:                    4 - DSS MTF (v6).pine

//-------------------------------------
// PURPOSE
// Double Smoothed Stochastic Multi-Timeframe (DSS MTF) - Used for
// higher timeframe confirmation signals in Confluence indicator.
// Combines EMA ratio analysis with stochastic normalization.

//-------------------------------------
// FEATURES
// - Multi-timeframe support via Indicator Timeframe input (default 60)
// - Configurable fast/slow EMA lengths for ratio calculation
// - Double stochastic smoothing (K and D normalization)
// - Optional final smoothing via MA
// - Offset parameter for historical analysis
// - Dynamic color based on rising/falling values

//-------------------------------------
// NOTES
// - Values oscillate between 0 and 100
// - Above 85 = overbought zone
// - Below 15 = oversold zone
// - Default timeframe: 60 minutes for higher TF confirmation
// - Division-by-zero protected with fallback to 0.5 (midpoint)

//-------------------------------------
// INDICATOR PARAMETERS

vVersion                        = "V1.0"
vPineVersion                    = "ps6"
vTitle                          = "Double Smoothed Stochastic MTF"
vShort                          = "DSS MTF"
vOverlay                        = false
vPrecision                      = 0

indicator( title = vTitle+" ["+vVersion+"|"+vPineVersion+"]", shorttitle = vShort+" ["+vVersion+"|"+vPineVersion+"]", overlay = vOverlay, precision = vPrecision )

//-------------------------------------
// INPUTS

var groupDssMtf                 = "DSS MTF (Standard: close, 3, 9, 1, 10, 90)"

vTimeframe                      = input.timeframe( defval = "60", title = "Indicator Timeframe" )
vSource                         = input.source( defval = close, title = "Source", group = groupDssMtf )
vLengthFast                     = input.int( defval = 5, minval = 1, maxval = 1024, title = "Fast Length", group = groupDssMtf )
vLengthSlow                     = input.int( defval = 9, minval = 1, maxval = 1024, title = "Slow Length", group = groupDssMtf )
vSmooth                         = input.int( defval = 1, minval = 1, maxval = 1024, title = "Smooth", group = groupDssMtf )
vOffSet                         = input.int( defval = 0, minval = 0, maxval = 1024, title = "Offset", group = groupDssMtf )
vLowerBandValue                 = input.int( defval = 15, minval = 0, maxval = 100, title = "Lower Band", group = groupDssMtf )
vUpperBandValue                 = input.int( defval = 85, minval = 0, maxval = 100, title = "Upper Band", group = groupDssMtf )

//-------------------------------------
// COLORS

cBullish                        = #2196F3
cBearish                        = #FF9800
cUpperBand                      = #666666
cLowerBand                      = #666666

//-------------------------------------
// FUNCTIONS

// @function    Simple Moving Average
// @param       n (int) Offset for lookback starting point
// @param       s (series float) Source data
// @param       le (int) Length of the averaging period
// @returns     (float) Average value over the specified period
fMa( n, s, le ) =>
    r = float( 0 )
    for i = n + 0 to ( n + ( le - 1 ) )
        r := ( r + s[ i ] )
    a = r / le
    a

// @function    Exponential Moving Average with MA seeding
// @param       n (int) Offset for source indexing
// @param       s (series float) Source data
// @param       le (int) Length for EMA calculation
// @returns     (float) EMA value with persistent state
fEma( n, s, le ) =>
    ma = fMa( n, s, le )
    var float r = na
    r := na( r[ 1 ] ) ? ma : ( r[ 1 ] + ( 2 / ( le + 1 ) ) * ( s[ n ] - r[ 1 ] ) )
    r

// @function    Double Smoothed Stochastic calculation
// @param       n (int) Offset for source indexing
// @param       s (series float) Source data
// @param       ls (int) Slow length for stochastic range
// @param       lf (int) Fast length for EMA smoothing
// @returns     (float) DSS value between 0 and 100
fDss( n, s, ls, lf ) =>
    ratio   = ( fEma( 0, s[ n ], lf ) / fEma( 0, s[ n ], ls ) )
    diffr   = ( ta.highest( ratio, ls ) - ta.lowest( ratio, ls ) )
    kRaw    = diffr == 0 ? 0.5 : ( ( ratio - ta.lowest( ratio, ls ) ) / diffr )
    average = ( fEma( 0, kRaw, lf ) * 100 )
    diffa   = ( ta.highest( average, ls ) - ta.lowest( average, ls ) )
    dRaw    = diffa == 0 ? 0.5 : ( ( average - ta.lowest( average, ls ) ) / diffa )
    dss     = ( fEma( 0, dRaw, lf ) * 100 )
    r       = dss
    r

// @function    Main DSS calculation wrapper for MTF support
// @returns     (float) Final smoothed DSS value
fCalcDss() =>
    fMa( 0, fDss( vOffSet, vSource, vLengthSlow, vLengthFast ), vSmooth )

// @function    Determines plot color based on trend direction
// @param       n (int) Offset for comparison
// @param       s (series float) Source data to evaluate
// @returns     (color) Blue if rising, orange if falling
fColor( n, s ) =>
    r = ( s[ n + 1 ] < s[ n ] ) ? cBullish : cBearish
    r

//-------------------------------------
// CALCULATIONS

vDss                            = vTimeframe == "" ? fCalcDss() : request.security( syminfo.tickerid, vTimeframe, fCalcDss() )

//-------------------------------------
// PLOT

vUpperBand                      = hline( vUpperBandValue, color = cUpperBand, linestyle = hline.style_dashed, linewidth = 1, title = "Upper Band", editable = true )
vLowerBand                      = hline( vLowerBandValue, color = cLowerBand, linestyle = hline.style_dashed, linewidth = 1, title = "Lower Band", editable = true )

vPlotDss                        = plot( vDss, style = plot.style_line, color = fColor( 0, vDss ), linewidth = 2, title = "DSS MTF" )

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

Overview

Double Smoothed Stochastic MTF combines an exponential moving average ratio with stochastic normalization and optional moving-average smoothing, producing values from 0 to 100. Rising and falling values change the plot color. The timeframe, source, fast and slow lengths, smoothing, and offset change the calculation, while adjustable lower and upper bands mark oversold and overbought zones, defaulting to 15 and 85. It is meant for higher-timeframe confirmation and has no entry or exit rules.

Details

Published by

SiegerTerpstra on GitHub

Code credit

sajjetti, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Any symbol

Timeframes

M15-H1

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.

Topics

tradingviewindicatorindicators

Settings

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

SettingTypeDefaultVariable
Indicator Timeframetimeframe60vTimeframe
SourcesourceclosevSource
Fast Lengthint5vLengthFast
Slow Lengthint9vLengthSlow
Smoothint1vSmooth
Offsetint0vOffSet
Lower Bandint15vLowerBandValue
Upper Bandint85vUpperBandValue
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

Asymmetrical RSI

by everget
948 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 10 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

Indicator v6 Oscillators & momentumDivergence Repaints
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Indicator

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop
261 stars

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI

KD指標

by TaichiS
219 stars

This script calculates and plots a Stochastic Oscillator (KD indicator) in a separate chart pane. It determines the fast stochastic value over a 9-period lookback, then applies a 3-period Simple Moving Average (SMA) to create the %K line, and a second 3-period

Indicator v4 Oscillators & momentum
Updated 5 years ago · None stated GitHub repository of KD指標

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