Indicator · Pine Script v5 · On the chart

Supertrend Ichimoku Chop Combination

by hayashi19· code credited to HayashiHitsuji

This indicator combines three tools on the price chart: a Supertrend built from Heikin Ashi data with a one-bar ATR and a multiplier of 1.85, an Ichimoku cloud, and a chop candle colouring based on an arctangent measure of price movement.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code292
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago10 Jan 2022

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

292 lines of Pine Script v5 from indicator/COMBINATION INDICATOR Supertrend Ichimoku Chop (林19).pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

COMBINATION INDICATOR Supertrend Ichimoku Chop (林19).pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HayashiHitsuji

//@version=5
indicator("Supertrend Ichimoku Chop Combination Indicator (林19)", shorttitle = "Super Ichimoku Chopiness (林19)", overlay = true)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INDICATOR INPUT =============================================================
// SUPERTREND //
st_ind = input.bool(false, "--------------- ATR INDICATOR ---------------")

st_signal   = input.bool(true, "Show supertrend long short signal?")
atr_type    = input.bool(true, "Use atr highest lowest calculation?")

atr_src     = input.source(hl2, "ATR Source")
atr_length  = input.int(1, "ATR")
atr_mult    = input.float(1.85, "ATR Mult")

// ICHIMOKU CLOUD //
ichimoku_ind = input.bool(false, "--------------- ICHIMOKU INDICATOR ---------------")

ichimoku        = input.bool(true, 'Show Ichimoku?')

con_per         = input.int(9, 'Conversion Line Length')
base_per        = input.int(26, 'Base Line Length')
lagspan_per     = input.int(52, 'Leading Span Length')
displacement    = input.int(26, 'Displacement')

// CHOP CANDLE //
chop = input.bool(false, "--------------- CHOP CANDLE INDICATOR ---------------")

show_candle     = input.bool(true, "Show the candle?")
// ========================================================================== //

// INDICATOR CALCULATION =======================================================
// SUPERTREND //

// Algo: set the heikin ashi candle source =====================================
ha_open     = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
ha_high     = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
ha_low      = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
ha_close    = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
// ========================================================================== //

// Algo: ATR manual calculation, the source from the heikin ashi ===============
pine_atr(length) =>
    trueRange = na(ha_high[1])? ha_high-ha_low : math.max(math.max(ha_high - ha_low, math.abs(ha_high - ha_close[1])), math.abs(ha_low - ha_close[1]))
    ta.rma(trueRange, length)

atr = atr_mult * pine_atr(atr_length)
// ========================================================================== //

// Algo: set the supertrend value ==============================================
longStop        = (atr_type ? ta.highest(ha_close, atr_length) : ta.highest(atr_length)) - atr
longStopPrev    = nz(longStop[1], longStop) 
longStop        := ha_close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop

shortStop       = (atr_type ? ta.lowest(ha_close, atr_length) : ta.lowest(atr_length)) + atr
shortStopPrev   = nz(shortStop[1], shortStop)
shortStop       := ha_close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop

var int dir = 1
dir := ha_close > shortStopPrev ? 1 : ha_close < longStopPrev ? -1 : dir

// Supertrend color
var color longColor     = color.aqua
var color shortColor    = color.fuchsia
// ========================================================================== //

// INCHIMOKU CLOUD //
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))

con_line        = donchian(con_per)
base_line       = donchian(base_per)

lead_line_1     = math.avg(con_line, base_line)
lead_line_2     = donchian(lagspan_per)

lag_span        = close

// CHOP CANDLE //
src = input(close, title = "Source")

avg         = input.source(ohlc4, "Indicator Average Source")
pi          = math.atan(input.int(1, "Arctan")) * input.int(4, "Arctan Mult")
periods     = input.int(30, "High Low Period")
highestHigh = ta.highest(periods)
lowestLow   = ta.lowest(periods)
span        = input.int(25, "Span") / (highestHigh - lowestLow) * lowestLow
ema34       = ta.ema(src, input.int(34, "EMA"))

x1_ema34    = 0
x2_ema34    = 1
y1_ema34    = 0
y2_ema34    = (ema34[1] - ema34) / avg * span

c_ema34     = math.sqrt((x2_ema34 - x1_ema34) * (x2_ema34 - x1_ema34) + (y2_ema34 - y1_ema34)*(y2_ema34 - y1_ema34))
emaAngle_1  = math.round(180 * math.acos((x2_ema34 - x1_ema34)/c_ema34) / pi)
emaAngle    = y2_ema34 > 0 ? - emaAngle_1 : emaAngle_1

chopZoneColor = emaAngle >= 5 ? #00FF00 :
                     emaAngle < 5 and emaAngle >= 3.57 ? #00FFFF :
                         emaAngle < 3.57 and emaAngle >= 2.14 ? #005EFF :
                             emaAngle < 2.14 and emaAngle >= .71 ? #A4E600 :
                                 emaAngle <= -1 * 5 ? #FF0000 :
                                     emaAngle > -1 * 5 and emaAngle <= -1 * 3.57 ? #FF17FF :
                                         emaAngle > -1 * 3.57 and emaAngle <= -1 * 2.14 ? #BE0AFF :
                                             emaAngle > -1 * 2.14 and emaAngle <= -1 * .71 ? #FF5500 :
                                                 color.yellow
                                                 
// candle
plotcandle(show_candle ? open : na, high, low, close, color = chopZoneColor, wickcolor = chopZoneColor, bordercolor = chopZoneColor)
// ========================================================================== //

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INDICATOR CONDITION =========================================================
buy_signal      = dir == 1 and dir[1] == -1
sell_signal     = dir == -1 and dir[1] == 1
// ========================================================================== //

// INDICATOR PLOT ============================================================== 
plotshape(st_signal and buy_signal ? close - low/100 : na, text = "Long", location = location.absolute, style = shape.labelup, size = size.tiny, color = #00FF00, textcolor = color.white)
plotshape(st_signal and sell_signal ? close + high/100 : na, text = "Short", location = location.absolute, style = shape.labeldown, size = size.tiny, color = #FF0000, textcolor = color.white)

// ICHIMOKU CLOUD //
p1 = plot(ichimoku ? lead_line_1 : na, color = #00FF00, title = 'Leading Span A')
p2 = plot(ichimoku ? lead_line_2 : na, color = #FF0000, title = 'Leading Span B')

kumo_color      = lead_line_1 >= lead_line_2 ? #00FF00 : #FF0000
fill(p1, p2, color = color.new(kumo_color, 90))
// ========================================================================== //

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//add on
ema = input.bool(false, "EMA")

ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)

plot(ema ? ema50 : na, color = color.lime)
plot(ema ? ema100 : na, color = color.white)
plot(ema ? ema200 : na, color = color.red)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HayashiHitsuji

//@version=5
indicator("Supertrend Ichimoku Chop Combination Indicator (林19)", shorttitle = "Super Ichimoku Chopiness (林19)", overlay = true)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INDICATOR INPUT =============================================================
// SUPERTREND //
st_ind = input.bool(false, "--------------- ATR INDICATOR ---------------")

st_signal   = input.bool(true, "Show supertrend long short signal?")
atr_type    = input.bool(true, "Use atr highest lowest calculation?")

atr_src     = input.source(hl2, "ATR Source")
atr_length  = input.int(1, "ATR")
atr_mult    = input.float(1.85, "ATR Mult")

// ICHIMOKU CLOUD //
ichimoku_ind = input.bool(false, "--------------- ICHIMOKU INDICATOR ---------------")

ichimoku        = input.bool(true, 'Show Ichimoku?')

con_per         = input.int(9, 'Conversion Line Length')
base_per        = input.int(26, 'Base Line Length')
lagspan_per     = input.int(52, 'Leading Span Length')
displacement    = input.int(26, 'Displacement')

// CHOP CANDLE //
chop = input.bool(false, "--------------- CHOP CANDLE INDICATOR ---------------")

show_candle     = input.bool(true, "Show the candle?")
// ========================================================================== //

// INDICATOR CALCULATION =======================================================
// SUPERTREND //

// Algo: set the heikin ashi candle source =====================================
ha_open     = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
ha_high     = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
ha_low      = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
ha_close    = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
// ========================================================================== //

// Algo: ATR manual calculation, the source from the heikin ashi ===============
pine_atr(length) =>
    trueRange = na(ha_high[1])? ha_high-ha_low : math.max(math.max(ha_high - ha_low, math.abs(ha_high - ha_close[1])), math.abs(ha_low - ha_close[1]))
    ta.rma(trueRange, length)

atr = atr_mult * pine_atr(atr_length)
// ========================================================================== //

// Algo: set the supertrend value ==============================================
longStop        = (atr_type ? ta.highest(ha_close, atr_length) : ta.highest(atr_length)) - atr
longStopPrev    = nz(longStop[1], longStop) 
longStop        := ha_close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop

shortStop       = (atr_type ? ta.lowest(ha_close, atr_length) : ta.lowest(atr_length)) + atr
shortStopPrev   = nz(shortStop[1], shortStop)
shortStop       := ha_close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop

var int dir = 1
dir := ha_close > shortStopPrev ? 1 : ha_close < longStopPrev ? -1 : dir

// Supertrend color
var color longColor     = color.aqua
var color shortColor    = color.fuchsia
// ========================================================================== //

// INCHIMOKU CLOUD //
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))

con_line        = donchian(con_per)
base_line       = donchian(base_per)

lead_line_1     = math.avg(con_line, base_line)
lead_line_2     = donchian(lagspan_per)

lag_span        = close

// CHOP CANDLE //
src = input(close, title = "Source")

avg         = input.source(ohlc4, "Indicator Average Source")
pi          = math.atan(input.int(1, "Arctan")) * input.int(4, "Arctan Mult")
periods     = input.int(30, "High Low Period")
highestHigh = ta.highest(periods)
lowestLow   = ta.lowest(periods)
span        = input.int(25, "Span") / (highestHigh - lowestLow) * lowestLow
ema34       = ta.ema(src, input.int(34, "EMA"))

x1_ema34    = 0
x2_ema34    = 1
y1_ema34    = 0
y2_ema34    = (ema34[1] - ema34) / avg * span

c_ema34     = math.sqrt((x2_ema34 - x1_ema34) * (x2_ema34 - x1_ema34) + (y2_ema34 - y1_ema34)*(y2_ema34 - y1_ema34))
emaAngle_1  = math.round(180 * math.acos((x2_ema34 - x1_ema34)/c_ema34) / pi)
emaAngle    = y2_ema34 > 0 ? - emaAngle_1 : emaAngle_1

chopZoneColor = emaAngle >= 5 ? #00FF00 :
                     emaAngle < 5 and emaAngle >= 3.57 ? #00FFFF :
                         emaAngle < 3.57 and emaAngle >= 2.14 ? #005EFF :
                             emaAngle < 2.14 and emaAngle >= .71 ? #A4E600 :
                                 emaAngle <= -1 * 5 ? #FF0000 :
                                     emaAngle > -1 * 5 and emaAngle <= -1 * 3.57 ? #FF17FF :
                                         emaAngle > -1 * 3.57 and emaAngle <= -1 * 2.14 ? #BE0AFF :
                                             emaAngle > -1 * 2.14 and emaAngle <= -1 * .71 ? #FF5500 :
                                                 color.yellow
                                                 
// candle
plotcandle(show_candle ? open : na, high, low, close, color = chopZoneColor, wickcolor = chopZoneColor, bordercolor = chopZoneColor)
// ========================================================================== //

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INDICATOR CONDITION =========================================================
buy_signal      = dir == 1 and dir[1] == -1
sell_signal     = dir == -1 and dir[1] == 1
// ========================================================================== //

// INDICATOR PLOT ============================================================== 
plotshape(st_signal and buy_signal ? close - low/100 : na, text = "Long", location = location.absolute, style = shape.labelup, size = size.tiny, color = #00FF00, textcolor = color.white)
plotshape(st_signal and sell_signal ? close + high/100 : na, text = "Short", location = location.absolute, style = shape.labeldown, size = size.tiny, color = #FF0000, textcolor = color.white)

// ICHIMOKU CLOUD //
p1 = plot(ichimoku ? lead_line_1 : na, color = #00FF00, title = 'Leading Span A')
p2 = plot(ichimoku ? lead_line_2 : na, color = #FF0000, title = 'Leading Span B')

kumo_color      = lead_line_1 >= lead_line_2 ? #00FF00 : #FF0000
fill(p1, p2, color = color.new(kumo_color, 90))
// ========================================================================== //

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//add on
ema = input.bool(false, "EMA")

ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)

plot(ema ? ema50 : na, color = color.lime)
plot(ema ? ema100 : na, color = color.white)
plot(ema ? ema200 : na, color = color.red)

Overview

Each part has its own switch and inputs for source, lengths and displacement. Supertrend long and short signals are optional. Parts of the code were not shown, so the exact chop logic is not confirmed.

Details

Published by

hayashi19 on GitHub

Code credit

HayashiHitsuji, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

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
--------------- ATR INDICATOR ---------------boolfalsest_ind
Show supertrend long short signal?booltruest_signal
Use atr highest lowest calculation?booltrueatr_type
ATR Sourcesourcehl2atr_src
ATRint1atr_length
ATR Multfloat1.85atr_mult
--------------- ICHIMOKU INDICATOR ---------------boolfalseichimoku_ind
Show Ichimoku?booltrueichimoku
Conversion Line Lengthint9con_per
Base Line Lengthint26base_per
Leading Span Lengthint52lagspan_per
Displacementint26displacement
Show all 40 settings
SettingTypeDefaultVariable
--------------- CHOP CANDLE INDICATOR ---------------boolfalsechop
Show the candle?booltrueshow_candle
Sourcesourceclosesrc
Indicator Average Sourcesourceohlc4avg
Arctanint1Arctan
Arctan Multint4Arctan Mult
High Low Periodint30periods
Spanint25span
EMAint34EMA
EMAboolfalseema
--------------- ATR INDICATOR ---------------boolfalsest_ind
Show supertrend long short signal?booltruest_signal
Use atr highest lowest calculation?booltrueatr_type
ATR Sourcesourcehl2atr_src
ATRint1atr_length
ATR Multfloat1.85atr_mult
--------------- ICHIMOKU INDICATOR ---------------boolfalseichimoku_ind
Show Ichimoku?booltrueichimoku
Conversion Line Lengthint9con_per
Base Line Lengthint26base_per
Leading Span Lengthint52lagspan_per
Displacementint26displacement
--------------- CHOP CANDLE INDICATOR ---------------boolfalsechop
Show the candle?booltrueshow_candle
Sourcesourceclosesrc
Indicator Average Sourcesourceohlc4avg
Arctanint1Arctan
Arctan Multint4Arctan Mult
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

Chandelier Exit

by everget
948 stars

This indicator plots an ATR-based Chandelier Exit trailing stop on the price chart. It tracks a long stop under recent highs and a short stop above recent lows, then switches direction when price crosses the opposite stop. Buy and sell labels mark those flips.

Indicator v6 Volatility & bandsTrend Repaints
Updated 11 days ago · GPL-3.0 GitHub repository of Chandelier Exit

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
330 stars

Range Filter [Alorse] is a technical indicator overlay for TradingView designed to filter market volatility and identify price trends. It calculates a smoothed range based on historical volatility using a configurable sampling period and multiplier applied to

Indicator v5 TrendVolatility & bands
Updated 2 months ago · None stated GitHub repository of Range Filter [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 2 days ago · MIT GitHub repository of NVDA Trend Ribbon

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

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