Indicator · Pine Script v5 · On the chart

Double Screened Decision

by anandaanv· code credited to anand1711

Double Screened Decision is a multi-timeframe trend and momentum indicator overlaid directly on the price chart.

View on GitHub

Repaints

GitHub stars56on the repository
Pine versionv5runs as is
Lines of code330
Settings2inputs
LicenceNone statedfile: MPL-2.0
Last update4 months ago29 Jun 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

330 lines of Pine Script v5 from spec/pines/imp-technicals.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

imp-technicals.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © anand1711

//@version=5
// strategy("Double Screened Decision", overlay = true)
indicator("Double Screened Decision", overlay = true, explicit_plot_zorder = true)
import TradingView/ta/7

backdatedCrossover(xoSeries, lookbackDays) =>
    xo = false
    for i = 0 to lookbackDays by 1
        xo := xo or xoSeries[i]
    xo

tideTimeframe = timeframe.period
upperTideTimeframe = timeframe.period

if timeframe.period == "5" or timeframe.period == "3"
    tideTimeframe := "15"
    upperTideTimeframe := "2h"
else if timeframe.period == "30" or timeframe.period == "15"
    tideTimeframe := "60"
    upperTideTimeframe := "2h"
else if timeframe.period == "60" or timeframe.period == "120"
    tideTimeframe := "D"
    upperTideTimeframe := "2D"
else if timeframe.period == "D" or timeframe.period == "240"
    tideTimeframe := "W"
    upperTideTimeframe := "2W"
else if timeframe.period == "W"
    tideTimeframe := "M"
    upperTideTimeframe := "2M"

offset = 0

[mLine, sLine, hLine]  = request.security(syminfo.tickerid, tideTimeframe, ta.macd(close, 9, 26, 9))

[macdLine, signalLine, histLine]  = request.security(syminfo.tickerid, tideTimeframe, ta.macd(close, 9, 26, 9))
[tbbbasis, tbbupper, tbblower]  = request.security(syminfo.tickerid, tideTimeframe, ta.bb(close, 20, 2))
trsi  = request.security(syminfo.tickerid, tideTimeframe, ta.rsi(close, 14))
tstoc  = request.security(syminfo.tickerid, tideTimeframe, ta.stoch(close, 3,3,14))

[bbbasis, bbupper, bblower] = ta.bb(close, 20, 2)
bbLowerEma = ta.ema(bblower, 3)
bbUpperEma = ta.ema(bbupper, 3)

bbcup = bbupper > bbupper[1]
bbcdn = bblower < bblower[1]

//// EMA crossover
ema5 = ta.ema(close, 5)
ema13 = ta.ema(close, 13)
ema26 = ta.ema(close, 26)

// RSI and Stochestic and MACD
rsi = ta.rsi(close, 14)
stoch = ta.stoch(close, 3,3,14)

// buy side
emaCrossoverLatest = ta.crossover(ema5[offset], ema13[offset]) or ta.crossover(ema5[offset], ema26[offset]) or ta.crossover(ema13[offset], ema26[offset])
emaCrossover1 = ta.crossover(ema5[offset +1], ema13[offset +1]) or ta.crossover(ema5[offset +1], ema26[offset +1]) or ta.crossover(ema13[offset +1], ema26[offset +1])
emaCrossover2 = ta.crossover(ema5[offset +2], ema13[offset +2]) or ta.crossover(ema5[offset +2], ema26[offset +2]) or ta.crossover(ema13[offset +2], ema26[offset +2])
emaCrossover3 = ta.crossover(ema5[offset +3], ema13[offset +3]) or ta.crossover(ema5[offset +3], ema26[offset +3]) or ta.crossover(ema13[offset +3], ema26[offset +3])
emaAlreadyAlignedUpside = ema5[offset] > ema13[offset] and ema13[offset] > ema26[offset]
emaCrossover = emaCrossoverLatest or emaCrossover1 or emaCrossover2 or emaCrossover3 or emaAlreadyAlignedUpside

// sell side
emaCrossunderLatest = ta.crossunder(ema5[offset], ema13[offset]) or ta.crossunder(ema5[offset], ema26[offset]) or ta.crossunder(ema13[offset], ema26[offset])
emaCrossunder1 = ta.crossunder(ema5[offset +1], ema13[offset +1]) or ta.crossunder(ema5[offset +1], ema26[offset +1]) or ta.crossunder(ema13[offset +1], ema26[offset +1])
emaCrossunder2 = ta.crossunder(ema5[offset +2], ema13[offset +2]) or ta.crossunder(ema5[offset +2], ema26[offset +2]) or ta.crossunder(ema13[offset +2], ema26[offset +2])
emaCrossunder3 = ta.crossunder(ema5[offset +3], ema13[offset +3]) or ta.crossunder(ema5[offset +3], ema26[offset +3]) or ta.crossunder(ema13[offset +3], ema26[offset +3])
emaAlreadyAlignedDownsideside = ema5[offset] < ema13[offset] and ema13[offset] < ema26[offset]
emaCrossunder = emaCrossunderLatest or emaCrossunder1 or emaCrossunder2 or emaCrossunder3 or emaAlreadyAlignedDownsideside


mDown = mLine[offset] < mLine[offset+1]
mUp = mLine[offset] > mLine[offset+1]

rsiDowntick = rsi[offset] < rsi[offset+1]
stockDowntick = stoch[offset] < stoch[offset+1]
macdDown = macdLine[offset] < macdLine[offset+1]

rsiUptick = rsi[offset] > rsi[offset+1]
stockUptick = stoch[offset] > stoch[offset+1]
macdUp = macdLine[offset] > macdLine[offset+1]

isbkp = bblower > bblower[1] and backdatedCrossover(ta.crossover(close, bblower), 15) //and macdUp
isbkt = bbupper < bbupper[1] and backdatedCrossover(ta.crossunder(close,bbUpperEma), 15) //and macdDown

if mDown
    smmDirection = "SELL"
    doubleScreenDecision = "SELL"
if mUp
    doubleScreenDecision = "BUY"
    smmDirection = "BUY"


doubleScreenDecision = ""
smmDirection = ""
alertColor = color.yellow
if(macdDown and (rsiDowntick or stockDowntick) and emaCrossunder)
    doubleScreenDecision := "SELL"
    smmDirection := "SELL"
    alertColor := color.red
else if(macdUp and (rsiUptick or stockUptick) and emaCrossover)
    doubleScreenDecision := "BUY"
    smmDirection := "BUY"
    alertColor := color.green
else if macdDown
    alertColor := color.red
    smmDirection := "SELL"
    if not rsiDowntick
        doubleScreenDecision := doubleScreenDecision + " RSI"
    if not stockDowntick
        doubleScreenDecision := doubleScreenDecision + " STOCH"
    if not emaCrossunder
        doubleScreenDecision := doubleScreenDecision + " EMA"
else if macdUp
    alertColor := color.green
    smmDirection := "BUY"
    if not rsiUptick
        doubleScreenDecision := doubleScreenDecision + " RSI"
    if not stockUptick
        doubleScreenDecision := doubleScreenDecision + " STOCH"
    if not emaCrossover
        doubleScreenDecision := doubleScreenDecision + " EMA"

//// PAPA Details
bbcStatus = (bbcup or bbcdn) ? "BBC" : bbcup ? "BBCUP" : bbcdn ? "BBCDN" : ""
bbStatus = isbkp? "BKP" : isbkt ? "BKT" : ""

isBuy = smmDirection=="BUY"
isSell = smmDirection=="SELL"

// RSI
rsiColor = color.yellow
PAPADecision = "Watch"
rsiDirection = rsi[0] > rsi[1] ? ">" : rsi[0] == rsi[1] ? "=" : "<"
if isBuy and rsi > 60 and bbcup
    PAPADecision :="Momentum Buy "
    rsiColor := color.green
else if isSell and rsi < 40 and bbcdn
    PAPADecision := "Momentum Sell "
    rsiColor := color.red
else if isBuy and rsi > 40 and rsi < 60 and isbkp
    PAPADecision :="Swing Buy "
    rsiColor := color.green
else if isSell and rsi > 40 and rsi < 60 and isbkt
    PAPADecision :="Swing Sell "
    rsiColor := color.red

PAPADecision += " " + bbcStatus + " " + bbStatus + " " + str.tostring(rsi[0],  "#.#") + rsiDirection + str.tostring(rsi[1],  "#.#")

// ADX
adxSignal = ""
adxcolor = color.yellow
[diplus, diminus, adx] = ta.dmi(14, 14)
adxUptick = adx > adx[1] and adx < 60
adxDowntick = adx < adx[1]
adxDirection = diplus > diminus ? ">" : diplus == diminus ? "=" : "<"
if isBuy and ((diplus - diminus > 3 and adxUptick) or (diminus - diplus > 3 and adxDowntick))
    adxcolor := color.green
if isSell and ((diminus - diplus > 3 and adxUptick) or (diplus - diminus > 3 and adxDowntick))
    adxcolor := color.red
adxSignal += str.tostring(adx, "# ") + (adxUptick ? " > " : " < ") + str.tostring(adx[1], " #")  + " => " + str.tostring(diplus, "# ") + adxDirection + str.tostring(diminus, " #")


// Plot future price on spot
string symbolOnly = syminfo.ticker
string futureCode = syminfo.type == "futures" ? syminfo.prefix + ":" + syminfo.ticker : syminfo.prefix + ":" + syminfo.ticker + "1!"
string futureCode2 = syminfo.type == "futures" ? syminfo.prefix + ":" + syminfo.ticker : syminfo.prefix + ":" + syminfo.ticker + "2!"
string timeframe = timeframe.period //timeframe.isintraday ? "1D" :
[fOpen, fiHigh, fLow, fClose, fvolume] = request.security(futureCode, timeframe, [open, high, low, close, volume], ignore_invalid_symbol = true)
diff = fClose - close
plot(fClose, "Future price", color = diff>diff[1]? color.green : color.red, style = plot.style_line, editable = true, show_last = 50)


//// Advanced Indicators
// Get Tide Details
tbbLowerEma = ta.ema(bblower, 3)
btbUpperEma = ta.ema(bbupper, 3)

tbbcup = tbbupper > tbbupper[1]
tbbcdn = tbblower < tbblower[1]
tbbc = tbbcdn and tbbcup
istbkp = tbblower > tbblower[1] and backdatedCrossover(ta.crossover(close, tbblower), 15) and not tbbcdn
istbkt = tbbupper < tbbupper[1] and backdatedCrossover(ta.crossunder(close,tbbupper), 15) and not tbbcup

//// EMA crossover
tema50 = ta.ema(close, 50)

gueDecision = ""
if isBuy
    if trsi < trsi[1]
        gueDecision += "RSI" + " "
    if tstoc < tstoc[1]
        gueDecision += "STOCH" + " "
    if not (not tbbcdn or istbkp or tbbc)
        gueDecision += "BB" + " "
    if close < tema50
        gueDecision += "EMA50" + " "
    if macdLine < 0
        gueDecision += "MACD " + str.tostring(macdLine, "#.#")
else if isSell
    if trsi > trsi[1]
        gueDecision += "RSI " + " "
    if tstoc > tstoc[1]
        gueDecision += "STOCH" + " "
    if not (not tbbcup or istbkt or tbbc)
        gueDecision += "BB" + " "
    if close > tema50
        gueDecision += "EMA50" + " "
    if macdLine > 0
        gueDecision += "MACD " + str.tostring(macdLine, "#.#")

if gueDecision == ""
    gueDecision := isBuy ? "BUY" : isSell ? "SELL" : "Watch"
gueColor = gueDecision == "BUY" ? color.green : gueDecision == "SELL" ? color.red : color.yellow

int i_ofset = input(5)
float mhi = high
float mlo = low
for i = 1 to i_ofset by 1
    if mhi <= high[i] and mlo >= low[i]
        mhi := high[i]
        mlo := low[i]

insideMother = high < mhi and low > mlo

motherCandleBreakout = insideMother[1] == true and insideMother == false

// MACD Histogram
// Define variables for trendline
var line trendline = na
var float trendlineStart = na
var float trendlineEnd = na

// Define breakout condition
var bool breakout = na

// Lookback period for identifying higher highs
rsilookback = input.int(30, title="Lookback Period")

// Find highest high in the lookback period
highestHigh = ta.highest(histLine, rsilookback)
// Find the index of the highest high
highestHighIndex = ta.highestbars(histLine, rsilookback)

// Determine trendline points based on highest highs
if highestHighIndex <= 0
    trendlineStart := na
    trendlineEnd := na
else
    trendlineStart := highestHigh
    trendlineEnd := histLine[highestHighIndex]

// Draw trendline
if not na(trendlineStart) and not na(trendlineEnd)
    trendline := line.new(bar_index[highestHighIndex], trendlineStart, bar_index, trendlineEnd, color=color.blue)

histBreakout = ta.crossover(histLine, trendlineEnd)


string openInterestTicker = str.format("{0}_OI", futureCode)
string openInterestTicker2 = str.format("{0}_OI", futureCode2)
[oiOpen1, oiHigh1, oiLow1, oiClose1] = request.security(openInterestTicker, timeframe, [open, high, low, close], ignore_invalid_symbol = true)
[oiOpen2, oiHigh2, oiLow2, oiClose2] = request.security(openInterestTicker2, timeframe, [open, high, low, close], ignore_invalid_symbol = true)
oiClose = oiClose1 + oiClose2

highIndexO = ta.highestbars(oiClose, 15)
lowIndexO = ta.lowestbars(oiClose, 15)
highIndex = math.abs(highIndexO)
lowIndex = math.abs(lowIndexO)
oiDecision = ""
if highIndex > lowIndex
    oiHighDir = close[highIndex] - close[lowIndex] < 0
    if oiHighDir and close > close[lowIndex]
        oiDecision := " OI - Buy"
    else if not oiHighDir and close < close[lowIndex]
        oiDecision := " OI - Sell"


otherData = motherCandleBreakout ? "Mother Breakout" : insideMother ? "Mother Candle" : ""
otherData += histBreakout ? "MACD Breakout" : ""
otherData += oiDecision
otherDataColor = motherCandleBreakout ? alertColor : color.yellow

symbol = syminfo.tickerid
earnings = request.earnings(symbol, earnings.estimate)
// Get the next earnings date and calculate days until next earnings
next_earnings_date = earnings.future_time
days_until_earnings = (next_earnings_date - time) / 86400000
finantialsColor = days_until_earnings < 15 ? color.yellow : gueColor
// Prepare the text for the label
earnings_text = str.tostring(days_until_earnings, "#") + " days "

var resultTable = table.new(position = position.top_right, columns = 2, rows = 6, bgcolor = color.yellow, border_width = 1)
if barstate.islast
    table.cell(table_id = resultTable, column = 0, row = 0, text = "SMM", bgcolor=alertColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 1, row = 0, text = doubleScreenDecision, bgcolor=alertColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 0, row = 1, text = "PAPA", bgcolor=rsiColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 1, row = 1, text = PAPADecision, bgcolor=rsiColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 0, row = 2, text = "ADX", bgcolor=adxcolor, text_size = size.small)
    table.cell(table_id = resultTable, column = 1, row = 2, text = adxSignal, bgcolor=adxcolor, text_size = size.small)
    table.cell(table_id = resultTable, column = 0, row = 3, text = "TIDE", bgcolor=gueColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 1, row = 3, text = gueDecision, bgcolor=gueColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 0, row = 4, text = "OTHER", bgcolor=gueColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 1, row = 4, text = otherData, bgcolor=gueColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 0, row = 5, text = "EARNINGS", bgcolor=finantialsColor, text_size = size.small)
    table.cell(table_id = resultTable, column = 1, row = 5, text = earnings_text, bgcolor=finantialsColor, text_size = size.small)

finalBuy = doubleScreenDecision == "BUY" and str.contains(PAPADecision, "Momentum Buy") and adxcolor == color.green
finalSell = doubleScreenDecision == "SELL" and str.contains(PAPADecision, "Momentum Sell") and adxcolor == color.red

swing_Buy = rsi > 40 and isbkp and trsi > 40
swing_sell = rsi < 60 and isbkt and trsi < 60


alertcondition(not swing_Buy[1] and swing_Buy, "Swing Buy" , "ASTA Swing Buy")
alertcondition(not swing_sell[1] and swing_sell, "Swing Sell" , "ASTA Swing Sell")
alertcondition(not finalBuy[1] and finalBuy, "ASTA Buy" , "ASTA Buy")
alertcondition(not finalSell[1] and finalSell, "ASTA Sell" , "ASTA Sell")


isIncreasing(series, days) =>
    increasing = true
    for i = 0 to days by 1
        if series[i] < series[i+2]
            increasing := false
    increasing

Overview

Double Screened Decision dynamically selects a higher timeframe based on the active chart resolution to evaluate higher-timeframe MACD, Bollinger Bands, RSI, and Stochastic values. Simultaneously, it tracks short-term exponential moving average crossovers (5, 13, and 26 EMAs) alongside local volatility and oscillator conditions. Higher-timeframe security calculations without historical bar offsets cause repainting on historical lower-timeframe bars.

Details

Published by

anandaanv on GitHub

Code credit

anand1711, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Oscillators & momentum, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Settings

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

SettingTypeDefaultVariable
i_ofsetint5i_ofset
Lookback Periodint30rsilookback
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

114 stars

ADX Strategy (original) is an overlay indicator that identifies trend-following trade signals using the Average Directional Index (ADX) combined with a Simple Moving Average filter. A long signal is generated when the ADX rises above a user-defined trend level

Indicator v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Strategy (original)
24 stars

This indicator plots Bollinger Bands on the price chart alongside a baseline moving average to identify trend-aligned swing setups. It calculates trend bias by comparing the Bollinger Bands basis to a customizable moving average, such as a 200 EMA. Trade signa

Indicator v5 Volatility & bandsOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of Bollinger Band Swing

Index Intraday Analyst

by chris-c-thomas
14 stars

Index Intraday Analyst overlays CBOE cash indices such as SPX, NDX, RUT, and DJX. It plots a multi-EMA ribbon, a session-anchored TWAP with standard-deviation bands, and session levels such as prior-day high, low, and close, the opening range, and the high and

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · MIT GitHub repository of Index Intraday Analyst

RePaNoCHa V4

by wocclyl
9 stars

RePaNoCHa V4 is an overlay alert indicator that plots a Tillson T3 moving average on the price chart and colors it by whether the line is rising or falling. It combines that slope with a range filter, ADX, parabolic SAR, RSI, and MACD to mark long and short si

Indicator v4 TrendOscillators & momentum
Updated 7 years ago · MIT GitHub repository of RePaNoCHa V4

Confluence

by trsdn
6 stars

The Confluence indicator combines Bollinger Bands, RSI and MACD to generate signals on the price chart. It plots the upper Bollinger Band in green, lower Bollinger Band in red, the middle basis in blue, the RSI value and the MACD line with signal. A confluence

Indicator v5 TrendOscillators & momentum
Updated 5 days ago · MIT GitHub repository of Confluence

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