Strategy · Pine Script v5 · On the chart

Bankai DTEK Strategy

by g-moe· code credited to goodgains

This strategy overlays the price chart to generate trading signals by combining Quantitative Qualitative Estimation (QQE), a custom SuperTrend, and a CCI ATR trend metric.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code174
Settings22inputs
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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

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

bankai-dtek-strategy.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
strategy("Bankai DTEK Strategy", overlay=true, margin_long=100, margin_short=100, max_bars_back=4999, max_lines_count=500, max_labels_count=10)

// @keywords: bankai-dtek, qqe-indicator, qqe-cross, dtek-candles, supertrend, cci-atr-trend, commodity-channel-index, smoothed-rsi, bollinger-reversal, reversal-confirmation, mean-reversion, rsi-confluence, overbought-oversold, hull-moving-average, long-entry-signal, short-entry-signal, trend-alignment, trading-session, atr-trailing, quantitative-qualitative-estimation

// --BANKAI + DTEK-- //
RSI_Period = input(14, title='RSI Length', group = 'Bankai + DTEK Settings')
SF = input(5, title='RSI Smoothing', group = 'Bankai + DTEK Settings')
QQE = input(4.238, title='Fast QQE Factor', group = 'Bankai + DTEK Settings')
ThreshHold = input(10, title='Thresh-hold', group = 'Bankai + DTEK Settings')

src = close
Wilders_Period = RSI_Period * 2 - 1

Rsi = ta.rsi(src, RSI_Period)
RsiMa = ta.ema(Rsi, SF)
AtrRsi = math.abs(RsiMa[1] - RsiMa)
MaAtrRsi = ta.ema(AtrRsi, Wilders_Period)
dar = ta.ema(MaAtrRsi, Wilders_Period) * QQE

longband = 0.0
shortband = 0.0
trend = 0

DeltaFastAtrRsi = dar
RSIndex = RsiMa
newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? math.max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? math.min(shortband[1], newshortband) : newshortband
cross_1 = ta.cross(longband[1], RSIndex)
trend := ta.cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband

// FINDING QQE CROSSES

QQExlong = 0
QQExlong := nz(QQExlong[1])
QQExshort = 0
QQExshort := nz(QQExshort[1])
QQExlong := FastAtrRsiTL < RSIndex ? QQExlong + 1 : 0
QQExshort := FastAtrRsiTL > RSIndex ? QQExshort + 1 : 0


// 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', group = 'Bankai + DTEK Settings')
ST_Length = input.int(4, title = 'ST Length', group = 'Bankai + DTEK Settings')
ST_AvgType = input.string('HMA', title = 'ST AvgType', options = ['SMA', 'WMA','VWMA', 'EMA', 'HMA'], group = 'Bankai + DTEK Settings')

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', group = 'Bankai + DTEK Settings')
lengthATR = input.int(21, title = 'CCI ATR Length', group = 'Bankai + DTEK Settings')
AtrFactor = input.float(1.0, title = 'CCI ATR Factor', group = 'Bankai + DTEK Settings')

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

barcolor(green_candles ? color.green : red_candles ? color.red : color.gray)
// DTEK CANDLES


qqeLong = QQExlong == 1 and green_candles ? FastAtrRsiTL[1] - 50 : na
qqeShort = QQExshort == 1 and red_candles ? FastAtrRsiTL[1] - 50 : na

plotshape(qqeLong, title='QQE long', text='Long', textcolor=color.new(color.white, 0), style=shape.labelup, location=location.belowbar, color=color.new(color.teal, 0), size=size.tiny)
plotshape(qqeShort, title='QQE short', text='Short', textcolor=color.new(color.white, 0), style=shape.labeldown, location=location.abovebar, color=color.new(color.maroon, 0), size=size.tiny)
// --BANKAI + DTEK-- //


// --REVERSAL-- //
// inputs
length = input.int(19, title="BBands Length", minval=1, tooltip="Bollinger band length used in calculation",  group="Reversal Bar Settings")   
mult = input.float(2, title="BBands Multiplier", minval=0.001, maxval=50, tooltip="Bollinger band multiplier used in calculation",  group="Reversal Bar Settings") 
showCheckmarks = input.bool( true , title="Show Checkmarks", tooltip="Checkmarks provide confirmation",  group="Reversal Bar Settings") 
isRsi = input.bool( false , title="RSI confluence", tooltip="Show reversal signal only when RSI is overbought/oversold",  group="Reversal Bar Settings") 
rsiLen = input.int( 14 , title="RSI Length",  group="Reversal Bar Settings") 
overSold = input.int( 30 , title="RSI Oversold",  group="Reversal Bar Settings") 
overBought = input.int ( 70 , title="RSI Overbought",  group="Reversal Bar Settings") 

//calculate bollinger bands
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev

//calculate RSI
vrsi = ta.rsi(close, rsiLen)
rsiBull = ta.crossover(vrsi, overSold)
rsiBear = ta.crossunder(vrsi, overBought)

// Reversal Bar - Bullish Signal
// Pseudo: went out lower band AND red candle AND came back in AND green candle
bullReversal =  low[1]<lower[1] and close[1]<open[1] and close>lower and close>open  
// Pseudo: everything above AND candle close above signal candles wick.
bullReversalConfirm =   low[2]<lower[2] and close[2]<open[2] and close[1]>lower[1] and close[1]>open[1] and close>high[1]

//  Reversal Bar - Bearish Signal
// Pseudo: went out upper band AND green candle AND came back in AND red candle
bearReversal  = high[1]>upper[1] and close[1]>open[1] and close<upper and close<open 
// Pseudo: everything above AND candle close below signal candles wick.
bearReversalConfirm =  high[2]>upper[2] and close[2]>open[2] and close[1]<upper[1] and close[1]<open[1] and close<low[1]

if isRsi
    bullReversal:=bullReversal and rsiBull
    bearReversal:=bearReversal and rsiBear
    bullReversalConfirm:=false
    bearReversalConfirm:=false
    
// UI    
plotchar(bullReversal, "Bull Reversal", "R", location.belowbar,color.rgb(124, 251, 216),size=size.tiny)
plotchar(bearReversal, "Bear Reversal", "R", location.abovebar,color=color.yellow,size=size.tiny)
plotchar(showCheckmarks?bullReversalConfirm:na, "Bull Reversal Confirm", "", location.belowbar, text="✓", color=color.rgb(124, 251, 216),size=size.tiny)
plotchar(showCheckmarks?bearReversalConfirm:na, "Bear Reversal Confirm", "", location.abovebar, text="✓", color=color.yellow,size=size.tiny)
// --REVERSAL-- //

// --STRATEGY INPUTS-- //
strategy_start = input.time(timestamp("01 January 2020 00:00:00 UTC-5"), "Strategy Start Date", group = "StrategySettings", inline = '1')
use_trading_hours = input.bool(false, title = "Use Trading Hours", tooltip = "This is ignored if the chart timeframe is greater than or equal to the daily timeframe.", group = "StrategySettings", inline = '2')
trading_time = input.session("0930-1600", title = " ", tooltip = "This uses Eastern Time Zone or U.S. NY Market Hours.", group = "StrategySettings", inline = '2')
trading_hours_cond = not use_trading_hours or time("",trading_time, "America/New_York")

long_trades = input.bool(true, title = "Long Trades", tooltip = "Do we want to take long trades?" , group = "StrategySettings", inline = '3')
short_trades = input.bool(true, title = "Short Trades", tooltip = "Do we want to take short trades?" , group = "StrategySettings", inline = '4')

long_entry = long_trades and trading_hours_cond and qqeLong
long_exit = long_trades and (not green_candles or bearReversal or (showCheckmarks and bearReversalConfirm))

short_entry = short_trades and trading_hours_cond and  qqeShort
short_exit = short_trades and (not red_candles or bullReversal or (showCheckmarks and bullReversalConfirm))

past_strategy_start_date = time >= strategy_start ? true : false
// --STRATEGY INPUTS-- //


// --ORDERS-- //
if past_strategy_start_date
    if long_exit
        strategy.close("LE", comment = 'LX')

    if short_exit
        strategy.close("SS_E", comment = 'SS_X')

    if long_entry
        strategy.entry("LE", strategy.long)

    if short_entry
        strategy.entry("SS_E", strategy.short)


// --ORDERS-- //

Overview

Bankai DTEK Strategy colors candles green or red according to combined trend alignment and enters long or short positions when directional criteria and optional RSI confluence conditions are met. Settings allow adjustments to QQE parameters, SuperTrend moving average types, CCI filters, Bollinger Bands, and intraday trading session times. The strategy does not include a default stop loss.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
RSI Lengthint14RSI_Period
RSI Smoothingint5SF
Fast QQE Factorfloat4.238QQE
Thresh-holdint10ThreshHold
ST ATR Multfloat1.0ST_Atr_Mult
ST Lengthint4ST_Length
ST AvgTypestringHMAST_AvgType
CCI Lengthint50lengthCCI
CCI ATR Lengthint21lengthATR
CCI ATR Factorfloat1.0AtrFactor
BBands Lengthint19length
BBands Multiplierfloat2mult
Show all 22 settings
SettingTypeDefaultVariable
Show CheckmarksbooltrueshowCheckmarks
RSI confluenceboolfalseisRsi
RSI Lengthint14rsiLen
RSI Oversoldint30overSold
RSI Overboughtint70overBought
Strategy Start Datetimetimestamp("01 January 2020 00:00:00 UTC-5")strategy_start
Use Trading Hoursboolfalseuse_trading_hours
session0930-1600trading_time
Long Tradesbooltruelong_trades
Short Tradesbooltrueshort_trades
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

106 stars

This trading strategy combines three Exponential Moving Averages (8, 14, and 50 periods by default) with Stochastic RSI and Average True Range (ATR). It enters a long position when EMA 1 is above EMA 2, EMA 2 is above EMA 3, and the Stochastic RSI %K line cros

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3 x EMA + Stochastic RSI + ATR

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL
57 stars

This strategy identifies trend reversals through market structure changes (CHoCH) filtered by MACD momentum. It initiates long positions on bullish structure breaks when MACD is positive and above its signal line, and short positions on bearish breaks when MAC

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure MACD 4H + Trailing

CombinedBinHAndClucV6

by viktors1982
36 stars

CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h

Strategy v4 Volatility & bandsOscillators & momentum Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV6
27 stars

LuxAlgo Hybrid Gold Scalper is a price-chart strategy aimed at gold. It stacks a fast, slow, trend and 200-period bias EMA to mark trend direction, then filters strength with RSI, ADX and an intraday VWAP. Swing highs and lows are marked from pivot length. Set

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of LuxAlgo Hybrid Gold Scalper

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers