Indicator · Pine Script v5 · Own pane

STC+TrendTrader

by theupslidedown· code credited to by HPotter v1.0 21/01/2021

This indicator combines the Schaff Trend Cycle (STC) oscillator with Andrew Abraham's Trend Trader indicator in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code107
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update3 years ago17 Feb 2023

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

107 lines of Pine Script v5 from stc+trendtracker.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

stc+trendtracker.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// converted from original to this new style with new addons by upslidedown
//@version=5
//

//[SHK] STC colored indicator
//https://www.tradingview.com/u/shayankm/

indicator(title='STC+TrendTrader [upslidedown]', overlay=false)
EEEEEE = input(12, 'Length')
BBBB = input(26, 'FastLength')
BBBBB = input(50, 'SlowLength')
require_threshold = input.bool(false)
threshold = input.int(10, step=5)

low_threshold = threshold
high_threshold = 100 - threshold

AAAA(BBB, BBBB, BBBBB) =>
    fastMA = ta.ema(BBB, BBBB)
    slowMA = ta.ema(BBB, BBBBB)
    AAAA = fastMA - slowMA
    AAAA

AAAAA(EEEEEE, BBBB, BBBBB) =>
    AAA = input(0.5)
    var CCCCC = 0.0
    var DDD = 0.0
    var DDDDDD = 0.0
    var EEEEE = 0.0
    BBBBBB = AAAA(close, BBBB, BBBBB)
    CCC = ta.lowest(BBBBBB, EEEEEE)
    CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
    CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
    DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
    DDDD = ta.lowest(DDD, EEEEEE)
    DDDDD = ta.highest(DDD, EEEEEE) - DDDD
    DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
    EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
    EEEEE

mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
mColor = mAAAAA > mAAAAA[1] ? color.new(color.blue, 20) : color.new(color.red, 20)

bull_cross = false
bear_cross = false
if require_threshold
    bull_cross := ta.crossover(mAAAAA, low_threshold) and not bull_cross[1]
    bear_cross := ta.crossunder(mAAAAA, high_threshold) and not bear_cross[1]
else 
    bull_cross := mAAAAA > mAAAAA[1]
    bear_cross := mAAAAA < mAAAAA[1]
//bull_cross =  ? 
//bull_cross := not require_threshold ? bull_cross and not bull_cross[1] : bull_cross
//bear_cross = require_threshold ? ta.crossunder(mAAAAA, high_threshold) : 
//bull_cross := not require_threshold ? bear_cross and not bear_cross[1] : bear_cross


//plotchar(bull_cross, location=location.bottom, color=color.blue)
//plotchar(bear_cross, location=location.top, color=color.red)

plot(mAAAAA, color=mColor, title='STC', linewidth=2)

ul = plot(low_threshold, color=color.new(color.gray, 70))
ll = plot(high_threshold, color=color.new(color.gray, 70))
fill(ul, ll, color=color.new(color.gray, 96))




// Trend Trader Strategy
//  Copyright by HPotter v1.0 21/01/2021
// This is plots the indicator developed by Andrew Abraham 

Length = input.int(21, minval=1)
Multiplier = input.float(3, minval=0.000001)
avgTR = ta.wma(ta.atr(1), Length)
highestC = ta.highest(Length)
lowestC = ta.lowest(Length)
hiLimit = highestC[1] - avgTR[1] * Multiplier
loLimit = lowestC[1] + avgTR[1] * Multiplier
ret = 0.0
pos = 0.0
ret:= close > hiLimit and close > loLimit ? hiLimit :
         close < loLimit and close < hiLimit ? loLimit : nz(ret[1], close)
pos:=  close > ret ? 1 :close < ret ? -1 : nz(pos[1], 0)
if pos != pos[1] and pos == 1
    alert("Color changed - Buy", alert.freq_once_per_bar_close)
if pos != pos[1] and pos == -1
    alert("Color changed - Sell", alert.freq_once_per_bar_close)
//barcolor(pos == -1 ? color.red : pos == 1 ? color.green : color.blue)
//plot(ret, color=color.new(color.blue, 0), title='Trend Trader Strategy')

longc_tt = pos == 1 and pos[1] == -1
shortc_tt = pos == -1 and pos[1] == 1


plotshape(longc_tt, "Trend Trader Long", style=shape.triangleup, location=location.bottom, size=size.small, color=color.blue)
plotshape(shortc_tt, "Trend Trader Short", style=shape.triangledown, location=location.top, size=size.small, color=color.red)


longc = bull_cross and longc_tt
shortc = bear_cross and shortc_tt

strategy = longc ? 1 : shortc ? -1 : 0

plot(strategy, "Strategy Signal", display=display.none)

Overview

STC+TrendTrader calculates the STC oscillator using fast and slow moving averages combined with double stochastic smoothing, plotting a colored line that changes color based on directional momentum. Simultaneously, it calculates Trend Trader levels using an Average True Range filter and multi-bar price extremes to trigger bullish triangle up and bearish triangle down shape signals. Inputs allow adjustment of STC lengths, threshold values, and Trend Trader ATR parameters.

Details

Published by

theupslidedown on GitHub

Code credit

by HPotter v1.0 21/01/2021, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend, Volatility & bands

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
Lengthint12EEEEEE
FastLengthint26BBBB
SlowLengthint50BBBBB
require_thresholdboolfalserequire_threshold
thresholdint10threshold
AAAfloat0.5AAA
Lengthint21Length
Multiplierfloat3Multiplier
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 yesterday · MIT GitHub repository of Adaptive Cycle Detector [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