Indicator · Pine Script v5 · Own pane

DTEK Candles

by g-moe· code credited to goodgains

This indicator calculates dual trend filters by combining a custom SuperTrend with a Commodity Channel Index ATR trailing stop.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code47
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

47 lines of Pine Script v5 from Tradingview/dtek-candles.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

dtek-candles.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("DTEK Candles")

// @keywords: supertrend-atr, cci-atr-trend, dual-trend-filter, background-trend-state, hull-moving-average, atr-band-stops, cci-deviation, green-red-gray-bg, multi-ma-types, trend-alignment, candle-state-cci, candle-state-supertrend, volatility-adaptive, short-atr-length, cci-length-settings, combined-trend-signal, intraday-trend-candles, trend-confluence, market-direction-bg, bgcolor-signal


// DTEK CANDLES
getMA(src, len, type) =>
    ma_value = type == 'SMA' ? ta.sma(src, len) : type == 'WMA' ? ta.wma(src, len) : type == 'VWMA' ? ta.vwma(src, len) : type == 'EMA' ? ta.ema(src, len) : type == 'HMA' ? ta.hma(src, len) : ta.sma(src, len)
    ma_value

ST_Atr_Mult = input.float(1.0, title = 'ST ATR Mult')
ST_Length = input.int(4, title = 'ST Length')
ST_AvgType = input.string('HMA', title = 'ST AvgType', options = ['SMA', 'WMA','VWMA', 'EMA', 'HMA'])

ATR = getMA( ta.tr(false), ST_Length, ST_AvgType )
UP = hl2 + (ST_Atr_Mult* ATR) 
DN = hl2 + (-ST_Atr_Mult * ATR) 
var float ST = na
ST := close < ST[1] ? UP : DN 

SuperTrend = ST 

lengthCCI = input.int(50, title = 'CCI Length')
lengthATR = input.int(21, title = 'CCI ATR Length')
AtrFactor = input.float(1.0, title = 'CCI ATR Factor')

ATRcci = ta.sma( ta.tr(false), lengthATR) * AtrFactor
price = close + low + high
pricedata = hl2
CCI = (price - ta.sma(price, lengthCCI)) / (0.015 * ta.dev(price, lengthCCI))

var float MT1 = 0
MT1 := CCI > 0 ? math.max(nz(MT1[1],0), pricedata - ATRcci) : math.min(nz(MT1[1],0), pricedata + ATRcci)
CCI_ATR_TREND = MT1

green_candles =  close > MT1 and close > ST
red_candles =  close < MT1 and close < ST

bgcolor(green_candles ? color.green : red_candles ? color.red : color.gray)


// DTEK CANDLES

Overview

The SuperTrend component utilizes customizable moving average types, including Hull, Exponential, and Simple Moving Averages. When price rises above both trailing stop levels, the background highlights green to signal a bullish trend confluence. When price falls below both levels, the background turns red for a bearish trend, while conflicting conditions result in a gray background. Input parameters allow users to adjust ATR lengths, multipliers, and CCI periods.

Details

Published by

g-moe on GitHub

Code credit

goodgains, 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
ST ATR Multfloat1.0ST_Atr_Mult
ST Lengthint4ST_Length
ST AvgTypestringHMAST_AvgType
CCI Lengthint50lengthCCI
CCI ATR Lengthint21lengthATR
CCI ATR Factorfloat1.0AtrFactor
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]
24 stars

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. Optional highlights mark overbought or oversold breakouts and K/D crossovers, and ribbon filli

Indicator v5 Oscillators & momentumVolatility & bands
Updated 4 years ago · MPL-2.0 GitHub repository of Intermediate Stochastic

The Adaptive Cycle Detector estimates the dominant market cycle from WaveTrend oscillator zero-crossing frequency and applies smoothing to recommend adaptive indicator lengths. Fast markets with frequent crossings receive shorter lengths while slow swing marke

Indicator v6 Oscillators & momentumVolatility & bands
Updated 3 days ago · MIT GitHub repository of Adaptive Cycle Detector [WavesUnchained]

More Trend 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