Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Follow The Ranging Hull

A Pine Script v5 strategy built on EMA (x - x[1], t), SMA or Stdev (close, 21) and ATR (5). It has 18 order rules, 6 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade is one contract and pays no commission. 35 settings; defaults include Points (The points that it uses to take profit) 80, Exit Rule Hull and Range Filter Fast Source ohlc4.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Follow The Ranging Hull repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Follow The Ranging Hull do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does Follow The Ranging Hull run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L138:C76: 'plot' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download.
Does Follow The Ranging Hull use a stop loss?
No
Its exits set a profit target but no stop.
Does Follow The Ranging Hull run in Zeal Terminal?
Yes
It compiles in 120 ms and runs 1,000 bars in 155 ms, in the browser.

BTCUSDT · 1D · default settings

  • Fast Range Filter
  • MHULL
  • SHULL
  • Trend Line
  • Shape
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$50,000$101,264Equity from $50,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. The live re-run is not offered here: the script requests BTCUSDT 1, BTCUSDT 5, BTCUSDT 15, BTCUSDT 3, which this page cannot load in your browser.

Needs BTCUSDT 1 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BTCUSDT 5 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BTCUSDT 15 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BTCUSDT 3 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.

Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $50,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Likely bug

    ta.atr(8) ignores the settings line 216

    Line 216 hard-codes 8 where line 152 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(8)ta.atr(ATRperiod)
  • Likely bug

    ta.atr(8) ignores the settings line 217

    Line 217 hard-codes 8 where line 152 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(8)ta.atr(ATRperiod)
  • Likely bug

    ta.atr(8) ignores the settings line 218

    Line 218 hard-codes 8 where line 152 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(8)ta.atr(ATRperiod)
  • Likely bug

    ta.atr(8) ignores the settings line 219

    Line 219 hard-codes 8 where line 152 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(8)ta.atr(ATRperiod)
  • Likely bug

    ta.atr(8) ignores the settings line 220

    Line 220 hard-codes 8 where line 152 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(8)ta.atr(ATRperiod)
  • Likely bug

    ta.atr(8) ignores the settings line 221

    Line 221 hard-codes 8 where line 152 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(8)ta.atr(ATRperiod)
  • Check

    1 setting does nothing

    “Source” is declared but never read.

  • Check

    No stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 228, 231, 237, 240, 244, 247, 254, 255, 259, 260, 261, 262, 263, 264. The upgraded version below moves each call inside an if block.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Date Range
Fromtimestamp("01 Jan 2022 00:00 GMT+2")timeinDate
Totimestamp("01 Jan 2022 23:00 GMT+2")timeinDate
Trading Rules
IS STRATEGYfalseboolclose rngFiltLong close rngFiltShort close slowRngFiltLong close slowRngFiltShort close fliLong close fliShort line 225
Apply Point Rulefalseboolexit exitRngFiltLong exit exitRngFiltShort exit exitSlowRngFiltLong exit exitSlowRngFiltShort exit exitFliLong exit exitFliShort line 249
Points (The points that it uses to take profit)80intexit exitRngFiltLong exit exitRngFiltShort exit exitSlowRngFiltLong exit exitSlowRngFiltShort exit exitFliLong exit exitFliShort
Following, Entry, Exit Rules
Use ATR for the Following Line (if false, it will use the slow range filter)trueboolSlow Range Filter buy sell closingRuleLong closingRuleShort Trend Line plotshape line 234
use Following line or Slow Range Filter as entry pointfalseboolplotshape line 233
Show Status Window (BETA)falseboolline 182
Hide Labelsfalseboolplotshape
Exit RuleHullsession · options ["Hull", "RangeFilter", "Following/SlowRangeFilter"]closingRuleLong closingRuleShort
Range Filter Colors
Fast Range Filter Color Upcolor.greencolorfiltcolor closingRuleLong closingRuleShort entry rngFiltLong entry rngFiltShort plotshape line 227 line 230
Fast Range Filter Color Downcolor.redcolorfiltcolor closingRuleLong closingRuleShort entry rngFiltLong entry rngFiltShort plotshape line 227 line 230
Slow Range Filter Color Upcolor.greencolorfiltcolorSlow entry slowRngFiltLong entry slowRngFiltShort plotshape line 243 line 246
Slow Range Filter Color Downcolor.redcolorfiltcolorSlow entry slowRngFiltLong entry slowRngFiltShort plotshape line 243 line 246
Hull Suite Colors
Hull Color Upcolor.greencolorhullColor line 188 line 196 line 203 line 210
Hull Color Downcolor.redcolorhullColor line 190 line 198 line 205 line 212
Following Line Colors
Follow Line Color Upcolor.greencolorTrend Line
Follow Line Color Downcolor.redcolorTrend Line
Range Filter Fast
Range Filter Fast Sourceohlc4sourcesmrng filt _hull line 125 line 126 line 127
Range Filter Fast Sampling Period33int · min 1smrng
Range Filter Fast Multiplier2.1float · min 0.1 · step 0.1smrng
Range Filter Slow
Range Filter Slow Sourceohlc4sourcesmrngSlow filtSlow
Range Filter Slow Sampling Period48int · min 1smrngSlow
Range Filter Slow Multiplier3.4float · min 0.1 · step 0.1smrngSlow
Hull Suite
Sourceclosesourceunused
Hull VariationEhmasession · options ["Hma", "Thma", "Ehma"]_hull line 125 line 126 line 127
Color Hull according to trend?trueboolhullColor
Show as a Band?trueboolSHULL
Line Thickness1intMHULL SHULL
Band Transparency40int · step 5Band Filler
Length(180-200 for floating S/R , 55 for swing entry)55int_hull
Following Line
BB Period21int · min 1BBUpper BBLower
BB Deviations1.00float · min 0.1 · step 0.05BBUpper BBLower
ATR Filtertrueboolline 151 line 155 line 159 line 161 line 165 line 169
ATR Period5int · min 1TrendLine

What it calculates

  • EMAmath.abs(x - x[1]), tavrng · line 102
  • EMAavrng, wpersmoothrng · line 84
  • EMAavrng, wpersmoothrngSlow · line 103
  • SMA / Stdevclose, BB Period (21)BBUpper · line 144
  • SMA / Stdevclose, BB Period (21)BBLower · line 145
  • ATRATR Period (5)TrendLine · line 152

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

The script has 71 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open rngFiltLong longHULL > HULL[2]On228
Open rngFiltShort shortHULL < HULL[2]On231
Open fliLong longHULL > HULL[2]On237
Open fliShort shortHULL < HULL[2]On240
Open slowRngFiltLong longHULL > HULL[2]On244
Open slowRngFiltShort shortHULL < HULL[2]On247
Exit exitRngFiltLong limit(isPointRule)On250
Exit exitRngFiltShort limit(isPointRule)On251
Exit exitSlowRngFiltLong limit(isPointRule)On252
Exit exitSlowRngFiltShort limit(isPointRule)On253
Exit exitFliLong limitsell == 1On254
Exit exitFliShort limitbuy == 1On255
Close rngFiltLongclosingRuleLongOn259
Close rngFiltShortclosingRuleShortOn260
Close slowRngFiltLongclosingRuleLongOn261
Close slowRngFiltShortclosingRuleShortOn262
Close fliLongclosingRuleLongOn263
Close fliShortclosingRuleShortOn264

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data4 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingprocess_orders_on_close = true: orders fill at the signal bar's close.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

Not run on other markets: the script requests BTCUSDT 1, BTCUSDT 5, BTCUSDT 15, BTCUSDT 3, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Follow The Ranging Hull this page—v5 strategy0.0%00.0%
Trend Following with Bollinger Bands by Robrecht99sma stdev ema atrv5 strategy+2.5%71.7%
[KL] BOLL + MACD Strategy v2 (published) by DojiEmojisma stdev ema atrv4 strategy−32.1%2854.0%
[EURUSD60] BB Expansion Strategy by kasaismsma stdev ema atrv4 strategyNo trades on this market
[KL] Bollinger bands + RSI Strategy by DojiEmojisma stdev atr emav4 strategy+28.2%3014.7%
[KL] Bollinger Bands Consolidation Strategy by DojiEmojisma stdev atr emav4 strategy+39.1%3319.6%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 14 strategy calls use the when = argument (line 228, 231, 237, 240, 244, 247, 254, 255, 259, 260, 261, 262, 263, 264). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 7 settings use the untyped input() (line 53, 57, 63, 65, 66, 67, 68). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 53: input() → input.source()
  • Line 57: input() → input.source()
  • Line 63: input() → input.source()
  • Line 65: input() → input.int()
  • Line 66: input() → input.bool()
  • Line 67: input() → input.bool()
15 more edits
  • Line 68: input() → input.int()
  • Line 228: when = HULL > HULL[2] → if block
  • Line 231: when = HULL < HULL[2] → if block
  • Line 237: when = HULL > HULL[2] → if block
  • Line 240: when = HULL < HULL[2] → if block
  • Line 244: when = HULL > HULL[2] → if block
  • Line 247: when = HULL < HULL[2] → if block
  • Line 254: when = sell == 1 → if block
  • Line 255: when = buy == 1 → if block
  • Line 259: when = closingRuleLong → if block
  • Line 260: when = closingRuleShort → if block
  • Line 261: when = closingRuleLong → if block
  • Line 262: when = closingRuleShort → if block
  • Line 263: when = closingRuleLong → if block
  • Line 264: when = closingRuleShort → if block
⋯// Fast Inputs-src = input(defval=ohlc4, title="Range Filter Fast Source", group="Range Filter Fast")+src = input.source(defval=ohlc4, title="Range Filter Fast Source", group="Range Filter Fast")per = input.int(defval=33, minval=1, title="Range Filter Fast Sampling Period", group="Range Filter Fast")⋯// Slow Inputs-srcSlow = input(defval=ohlc4, title="Range Filter Slow Source", group="Range Filter Slow")+srcSlow = input.source(defval=ohlc4, title="Range Filter Slow Source", group="Range Filter Slow")perSlow = input.int(defval=48, minval=1, title="Range Filter Slow Sampling Period", group="Range Filter Slow")⋯///////////////////////-srcHull = input(close, title="Source", group="Hull Suite")+srcHull = input.source(close, title="Source", group="Hull Suite")modeSwitch = input.session("Ehma", title="Hull Variation", options=["Hma", "Thma", "Ehma"], group="Hull Suite")-length = input(55, title="Length(180-200 for floating S/R , 55 for swing entry)")+length = input.int(55, title="Length(180-200 for floating S/R , 55 for swing entry)")-switchColor = input(true, "Color Hull according to trend?", group="Hull Suite")+switchColor = input.bool(true, "Color Hull according to trend?", group="Hull Suite")-visualSwitch  = input(true, title="Show as a Band?", group="Hull Suite")+visualSwitch  = input.bool(true, title="Show as a Band?", group="Hull Suite")-thicknesSwitch = input(1, title="Line Thickness", group="Hull Suite")+thicknesSwitch = input.int(1, title="Line Thickness", group="Hull Suite")transpSwitch = input.int(40, title="Band Transparency",step=5, group="Hull Suite")⋯    if(filtcolor[1] == rngFilterColorDown and filtcolor == rngFilterColorUp)-        strategy.entry("rngFiltLong", strategy.long, when = HULL > HULL[2])+        if HULL > HULL[2]+            strategy.entry("rngFiltLong", strategy.long)    // RANGE FILTER ENTRY SHORT WITH HULL    if(filtcolor[1] == rngFilterColorUp and filtcolor == rngFilterColorDown)-        strategy.entry("rngFiltShort", strategy.short, when = HULL < HULL[2])+        if HULL < HULL[2]+            strategy.entry("rngFiltShort", strategy.short)    // FOLLOW LINE OR SLOW RANGE FILTER ENTRY, IF ENABLED    ⋯            if(buy == 1)-                strategy.entry("fliLong", strategy.long, when = HULL > HULL[2])+                if HULL > HULL[2]+                    strategy.entry("fliLong", strategy.long)            // FOLLOWING LINE ENTRY SHORT WITH HULL            if(sell == 1)-                strategy.entry("fliShort", strategy.short, when = HULL < HULL[2])+                if HULL < HULL[2]+                    strategy.entry("fliShort", strategy.short)        else⋯            if(filtcolorSlow[1] == rngFilterColorDownSlow and filtcolorSlow == rngFilterColorUpSlow)-                strategy.entry("slowRngFiltLong", strategy.long, when = HULL > HULL[2])+                if HULL > HULL[2]+                    strategy.entry("slowRngFiltLong", strategy.long)            // SLOW RANGE FILTER ENTRY SHORT WITH HULL            if(filtcolorSlow[1] == rngFilterColorUpSlow and filtcolorSlow == rngFilterColorDownSlow)-                strategy.entry("slowRngFiltShort", strategy.short, when = HULL < HULL[2])+                if HULL < HULL[2]+                    strategy.entry("slowRngFiltShort", strategy.short)        ⋯        strategy.exit('exitSlowRngFiltShort', 'slowRngFiltShort', profit=pointRulePoints)-        strategy.exit('exitFliLong', 'fliLong', profit=pointRulePoints, when = sell == 1)+        if sell == 1+            strategy.exit('exitFliLong', 'fliLong', profit=pointRulePoints)-        strategy.exit('exitFliShort', 'fliShort', profit=pointRulePoints , when = buy == 1)+        if buy == 1+            strategy.exit('exitFliShort', 'fliShort', profit=pointRulePoints )    closingRuleLong = exitRule == "Hull" ? HULL > HULL[2] : exitRule == "RangeFilter" ? (filtcolor[2] == rngFilterColorUp and filtcolor == rngFilterColorDown) : exitRule == "Following/SlowRangeFilter" ? followLineUseATR == false? (sell == 1): (filtcolor[2] == rngFilterColorUp and filtcolor == rngFilterColorDown): na⋯                        -    strategy.close("rngFiltLong", when = closingRuleLong)+    if closingRuleLong+        strategy.close("rngFiltLong")-    strategy.close("rngFiltShort", when = closingRuleShort)+    if closingRuleShort+        strategy.close("rngFiltShort")-    strategy.close("slowRngFiltLong", when = closingRuleLong)+    if closingRuleLong+        strategy.close("slowRngFiltLong")-    strategy.close("slowRngFiltShort",  when = closingRuleShort)+    if closingRuleShort+        strategy.close("slowRngFiltShort")-    strategy.close("fliLong", when = closingRuleLong)+    if closingRuleLong+        strategy.close("fliLong")-    strategy.close("fliShort", when = closingRuleShort)+    if closingRuleShort+        strategy.close("fliShort")

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L138:C76: 'plot' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// Follow Line Indicator by Dreadblitz https://www.tradingview.com/u/Dreadblitz/-//@version=5+//@version=6strategy("Follow The Ranging Hull", overlay=true, initial_capital = 50000, process_orders_on_close = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 120 msYes 1,000 bars in 155 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © flygalaxies// Strategy based on the Follow Line Indicator by Dreadblitz, Hull Suite by InSilico and Range Filter Buy and Sell 5 min by guikroth// Designed for the purpose of back testing// Strategy://  - When the Range Filter Color Changes, And the HULL Suite is in that direction, Enter In that direction//  - e.g Range Filter Changes color from red to green, and Hull Suite is in Green. Enter Long//  - e.g Range Filter Changes color from green to red, and Hull Suite is in red. Enter Short////  - When the Following Line Color Changes, And the HULL Suite is in that direction, Enter In that direction//  - e.g Following Line Changes color from red to green, and Hull Suite is in Green. Enter Long//  - e.g Following Line Changes color from green to red, and Hull Suite is in red. Enter Short//// Credits:// Hull Suite by InSilico  https://www.tradingview.com/u/InSilico/// Range Filter Buy and Sell 5 min https://www.tradingview.com/u/guikroth/// Follow Line Indicator by Dreadblitz https://www.tradingview.com/u/Dreadblitz///@version=5strategy("Follow The Ranging Hull", overlay=true, initial_capital = 50000, process_orders_on_close = true)/////////////////////////// STRATEGY SETTINGS //////////////////////////fromDate = input.time(title="From", defval=timestamp("01 Jan 2022 00:00 GMT+2"), inline="1", group="Date Range")toDate = input.time(title="To", defval=timestamp("01 Jan 2022 23:00 GMT+2"), inline="1", group="Date Range")inDate = time >= fromDate and time <= toDateisStrategy = input.bool(title="IS STRATEGY", defval = false, group="Trading Rules")isPointRule = input.bool(title="Apply Point Rule", defval = false, group="Trading Rules")pointRulePoints = input.int(title="Points (The points that it uses to take profit)", defval = 80, group="Trading Rules")////////////////////////////////////// FOLLOWING, ENTRY, EXIT RULES /////////////////////////////////////followLineUseATR = input.bool(title="Use ATR for the Following Line (if false, it will use the slow range filter)", defval = true, group="Following, Entry, Exit Rules")followRngFilterEntry = input.bool(title="use Following line or Slow Range Filter as entry point", defval = false, group="Following, Entry, Exit Rules")showStatusWindow = input.bool(title="Show Status Window (BETA)", defval = false, group="Following, Entry, Exit Rules")hl            = input.bool(defval = false, title = "Hide Labels", group = "Following, Entry, Exit Rules")exitRule = input.session("Hull", title="Exit Rule", options=["Hull", "RangeFilter", "Following/SlowRangeFilter"], group="Following, Entry, Exit Rules")////////////////////// COLOR INPUTS /////////////////////rngFilterColorUp = input.color(title="Fast Range Filter Color Up", defval = color.green, group="Range Filter Colors")rngFilterColorDown = input.color(title="Fast Range Filter Color Down", defval = color.red, group="Range Filter Colors")rngFilterColorUpSlow = input.color(title="Slow Range Filter Color Up", defval = color.green, group="Range Filter Colors")rngFilterColorDownSlow = input.color(title="Slow Range Filter Color Down", defval = color.red, group="Range Filter Colors")hullColorUp = input.color(title="Hull Color Up", defval = color.green, group="Hull Suite Colors")hullColorDown = input.color(title="Hull Color Down", defval = color.red, group="Hull Suite Colors")fliColorUp = input.color(title="Follow Line Color Up", defval = color.green, group="Following Line Colors")fliColorDown = input.color(title="Follow Line Color Down", defval = color.red, group="Following Line Colors")    ///////////////////////////// Range Filter INPUTS ////////////////////////////// Fast Inputssrc = input(defval=ohlc4, title="Range Filter Fast Source", group="Range Filter Fast")per = input.int(defval=33, minval=1, title="Range Filter Fast Sampling Period", group="Range Filter Fast")mult = input.float(defval=2.1, minval=0.1, title="Range Filter Fast Multiplier", group="Range Filter Fast", step=0.1)// Slow InputssrcSlow = input(defval=ohlc4, title="Range Filter Slow Source", group="Range Filter Slow")perSlow = input.int(defval=48, minval=1, title="Range Filter Slow Sampling Period", group="Range Filter Slow")multSlow = input.float(defval=3.4, minval=0.1, title="Range Filter Slow Multiplier", group="Range Filter Slow", step=0.1)/////////////////////////// Hull Suite INPUTS //////////////////////////srcHull = input(close, title="Source", group="Hull Suite")modeSwitch = input.session("Ehma", title="Hull Variation", options=["Hma", "Thma", "Ehma"], group="Hull Suite")length = input(55, title="Length(180-200 for floating S/R , 55 for swing entry)")switchColor = input(true, "Color Hull according to trend?", group="Hull Suite")visualSwitch  = input(true, title="Show as a Band?", group="Hull Suite")thicknesSwitch = input(1, title="Line Thickness", group="Hull Suite")transpSwitch = input.int(40, title="Band Transparency",step=5, group="Hull Suite")//////////////////////////// FOLLOW LINE INPUTS ///////////////////////////BBperiod      = input.int(defval = 21, title = "BB Period", minval = 1, group = "Following Line ")BBdeviations  = input.float(defval = 1.00, title = "BB Deviations", minval = 0.1, step=0.05, group = "Following Line ")UseATRfilter  = input.bool(defval = true, title = "ATR Filter", group = "Following Line ")ATRperiod     = input.int(defval = 5, title = "ATR Period", minval = 1, group = "Following Line ")//////////////////////////// Range Filter Logic ///////////////////////////// Fastsmoothrng(x, t, m) =>    wper = t * 2 - 1    avrng = ta.ema(math.abs(x - x[1]), t)    smoothrng = ta.ema(avrng, wper) * m    smoothrngsmrng = smoothrng(src, per, mult)rngfilt(x, r) =>    rngfilt = x    rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :        x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r    rngfiltfilt = rngfilt(src, smrng)upward = 0.0upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])downward = 0.0downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])filtcolor = upward > 0 ? rngFilterColorUp : downward > 0 ? rngFilterColorDown : color.orangefiltplot = plot(filt, color=filtcolor, linewidth=3, title="Fast Range Filter ")// SlowsmoothrngSlow(x, t, m) =>    wper = t * 2 - 1    avrng = ta.ema(math.abs(x - x[1]), t)    smoothrngSlow = ta.ema(avrng, wper) * m    smoothrngSlowsmrngSlow = smoothrngSlow(srcSlow, perSlow, multSlow)rngfiltSlow(x, r) =>    rngfilt = x    rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :        x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r    rngfiltfiltSlow = rngfiltSlow(srcSlow, smrngSlow)upwardSlow = 0.0upwardSlow := filtSlow > filtSlow[1] ? nz(upwardSlow[1]) + 1 : filtSlow < filtSlow[1] ? 0 : nz(upwardSlow[1])downwardSlow = 0.0downwardSlow := filtSlow < filtSlow[1] ? nz(downwardSlow[1]) + 1 : filtSlow > filtSlow[1] ? 0 : nz(downwardSlow[1])filtcolorSlow = upwardSlow > 0 ? rngFilterColorUpSlow : downwardSlow > 0 ? rngFilterColorDownSlow : color.orangefiltplotSlow = plot(followLineUseATR == false ? filtSlow : na, color=filtcolorSlow, linewidth=3, title="Slow Range Filter")////////////////////////// Hull Suite Logic /////////////////////////HMA(_srcHull, _length) =>  ta.wma(2 * ta.wma(_srcHull, _length / 2) - ta.wma(_srcHull, _length), math.round(math.sqrt(_length)))EHMA(_srcHull, _length) =>  ta.ema(2 * ta.ema(_srcHull, _length / 2) - ta.ema(_srcHull, _length), math.round(math.sqrt(_length)))THMA(_srcHull, _length) =>  ta.wma(ta.wma(_srcHull,_length / 3) * 3 - ta.wma(_srcHull, _length / 2) - ta.wma(_srcHull, _length), _length)Mode(modeSwitch, src, len) =>      modeSwitch == "Hma"  ? HMA(src, len) :       modeSwitch == "Ehma" ? EHMA(src, len) :       modeSwitch == "Thma" ? THMA(src, len/2) : na_hull = Mode(modeSwitch, src, int(length))HULL =  _hullMHULL = HULL[0]SHULL = HULL[2]// HIGHER TIMEFRAME HULLHULL1 =  request.security(syminfo.ticker, "1", _hull)HULL5 =  request.security(syminfo.ticker, "5", _hull)HULL15 =  request.security(syminfo.ticker, "15", _hull)HULL3 =  request.security(syminfo.ticker, "3", _hull)hullColor = switchColor ? (HULL > HULL[2] ? hullColorUp : hullColorDown) : #ff9800Fi1 = plot(MHULL, title="MHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)Fi2 = plot(visualSwitch ? SHULL : na, title="SHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)fill(Fi1, Fi2, title="Band Filler", color=hullColor, transp=transpSwitch)/////////////////////////// Follow Line Logic //////////////////////////BBUpper=ta.sma (close,BBperiod)+ta.stdev(close, BBperiod)*BBdeviationsBBLower=ta.sma (close,BBperiod)-ta.stdev(close, BBperiod)*BBdeviationsTrendLine = 0.0iTrend = 0.0buy = 0.0sell = 0.0BBSignal = close>BBUpper? 1 : close<BBLower? -1 : 0if BBSignal == 1 and UseATRfilter == 1    TrendLine:=low-ta.atr(ATRperiod)    if TrendLine<TrendLine[1]         TrendLine:=TrendLine[1]if BBSignal == -1 and UseATRfilter == 1    TrendLine:=high+ta.atr(ATRperiod)    if TrendLine>TrendLine[1]        TrendLine:=TrendLine[1]if BBSignal == 0 and UseATRfilter == 1    TrendLine:=TrendLine[1]if BBSignal == 1 and UseATRfilter == 0    TrendLine:=low    if TrendLine<TrendLine[1]         TrendLine:=TrendLine[1]if BBSignal == -1 and UseATRfilter == 0    TrendLine:=high    if TrendLine>TrendLine[1]        TrendLine:=TrendLine[1]if BBSignal == 0 and UseATRfilter == 0    TrendLine:=TrendLine[1]iTrend:=iTrend[1]if TrendLine>TrendLine[1]     iTrend:=1if TrendLine<TrendLine[1]     iTrend:=-1buy:= iTrend[1]==-1 and iTrend==1 and followLineUseATR == true ? 1 : na sell:= iTrend[1]==1 and iTrend==-1 and followLineUseATR == true ? 1 : na plot(followLineUseATR == true ? TrendLine : na, color=iTrend > 0? fliColorUp : fliColorDown ,style=plot.style_line,linewidth=2,transp=0,title="Trend Line") ///////////////////////////// STATUS WINDOW LOGIC ////////////////////////////if(showStatusWindow == true )    var table statuswindow = table.new(position.top_right, 100, 100, border_width=2)        txt1 = "🡇            Hull 1 min             🡇"    table.cell(statuswindow, 1, 0, text=txt1, bgcolor=color.new(#000000, 50), text_color=color.white, text_size=size.small)    if(HULL1 > HULL1[2])        table.cell(statuswindow, 1, 1, text='', bgcolor=hullColorUp, text_color=color.white, text_size=size.small)     else        table.cell(statuswindow, 1, 1, text='', bgcolor=hullColorDown, text_color=color.white, text_size=size.small)            txt3 = "🡇            Hull 3 min             🡇"    table.cell(statuswindow, 2, 0, text=txt3, bgcolor=color.new(#000000, 50), text_color=color.white, text_size=size.small)    if(HULL3 > HULL3[2])        table.cell(statuswindow, 2, 1, text='', bgcolor=hullColorUp, text_color=color.white, text_size=size.small)     else        table.cell(statuswindow, 2, 1, text='', bgcolor=hullColorDown, text_color=color.white, text_size=size.small)            txt5 = "🡇            Hull 5 min             🡇"    table.cell(statuswindow, 3, 0, text=txt5, bgcolor=color.new(#000000, 50), text_color=color.white, text_size=size.small)    if(HULL5 > HULL5[2])        table.cell(statuswindow, 3, 1, text='', bgcolor=hullColorUp, text_color=color.white, text_size=size.small)     else        table.cell(statuswindow, 3, 1, text='', bgcolor=hullColorDown, text_color=color.white, text_size=size.small)        txt15 = "🡇            Hull 15 min             🡇"    table.cell(statuswindow, 4, 0, text=txt15, bgcolor=color.new(#000000, 50), text_color=color.white, text_size=size.small)    if(HULL15 > HULL15[2])        table.cell(statuswindow, 4, 1, text='', bgcolor=hullColorUp, text_color=color.white, text_size=size.small)     else        table.cell(statuswindow, 4, 1, text='', bgcolor=hullColorDown, text_color=color.white, text_size=size.small)////////////////////////////////////////////// ALERTS & LABELS BASED ON ENTRY POINT /////////////////////////////////////////////plotshape((filtcolor[1] == rngFilterColorDown and filtcolor == rngFilterColorUp )and hl == false and HULL > HULL[2] ? TrendLine-ta.atr(8) :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)plotshape((filtcolor[1] == rngFilterColorUp and filtcolor == rngFilterColorDown) and hl == false and HULL < HULL[2] ?TrendLine+ta.atr(8):na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)plotshape(followRngFilterEntry == true and followLineUseATR == true and buy == 1 and hl == false and HULL > HULL[2] ? TrendLine-ta.atr(8) :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)plotshape(followRngFilterEntry == true and followLineUseATR == true and sell == 1 and hl == false and  HULL < HULL[2] ? TrendLine+ta.atr(8):na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)plotshape(followRngFilterEntry == true and followLineUseATR == false and (filtcolorSlow[1] == rngFilterColorDownSlow and filtcolorSlow == rngFilterColorUpSlow) and hl == false and HULL > HULL[2] ? TrendLine-ta.atr(8) :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)plotshape(followRngFilterEntry == true and followLineUseATR == false and (filtcolorSlow[1] == rngFilterColorUpSlow and filtcolorSlow == rngFilterColorDownSlow) and hl == false and  HULL < HULL[2] ?TrendLine+ta.atr(8):na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)//////////////////////////////////// STRATEGY ENTRY POINT LOGIC ///////////////////////////////////if(inDate and isStrategy)    // RANGE FILTER ENTRY LONG WITH HULL    if(filtcolor[1] == rngFilterColorDown and filtcolor == rngFilterColorUp)        strategy.entry("rngFiltLong", strategy.long, when = HULL > HULL[2])    // RANGE FILTER ENTRY SHORT WITH HULL    if(filtcolor[1] == rngFilterColorUp and filtcolor == rngFilterColorDown)        strategy.entry("rngFiltShort", strategy.short, when = HULL < HULL[2])    // FOLLOW LINE OR SLOW RANGE FILTER ENTRY, IF ENABLED        if(followRngFilterEntry == true)        if(followLineUseATR == true)            // FOLLOWING LINE  ENTRY SHORT WITH HULL            if(buy == 1)                strategy.entry("fliLong", strategy.long, when = HULL > HULL[2])            // FOLLOWING LINE ENTRY SHORT WITH HULL            if(sell == 1)                strategy.entry("fliShort", strategy.short, when = HULL < HULL[2])        else            // SLOW RANGE FILTER ENTRY WITH HULL            if(filtcolorSlow[1] == rngFilterColorDownSlow and filtcolorSlow == rngFilterColorUpSlow)                strategy.entry("slowRngFiltLong", strategy.long, when = HULL > HULL[2])            // SLOW RANGE FILTER ENTRY SHORT WITH HULL            if(filtcolorSlow[1] == rngFilterColorUpSlow and filtcolorSlow == rngFilterColorDownSlow)                strategy.entry("slowRngFiltShort", strategy.short, when = HULL < HULL[2])            if(isPointRule)        strategy.exit('exitRngFiltLong', 'rngFiltLong', profit=pointRulePoints)        strategy.exit('exitRngFiltShort', 'rngFiltShort', profit=pointRulePoints)        strategy.exit('exitSlowRngFiltLong', 'slowRngFiltLong', profit=pointRulePoints)        strategy.exit('exitSlowRngFiltShort', 'slowRngFiltShort', profit=pointRulePoints)        strategy.exit('exitFliLong', 'fliLong', profit=pointRulePoints, when = sell == 1)        strategy.exit('exitFliShort', 'fliShort', profit=pointRulePoints , when = buy == 1)    closingRuleLong = exitRule == "Hull" ? HULL > HULL[2] : exitRule == "RangeFilter" ? (filtcolor[2] == rngFilterColorUp and filtcolor == rngFilterColorDown) : exitRule == "Following/SlowRangeFilter" ? followLineUseATR == false? (sell == 1): (filtcolor[2] == rngFilterColorUp and filtcolor == rngFilterColorDown): na    closingRuleShort = exitRule == "Hull" ? HULL > HULL[2] : exitRule == "RangeFilter" ? (filtcolor[1] == rngFilterColorDown and filtcolor == rngFilterColorUp) : exitRule == "Following/SlowRangeFilter" ? followLineUseATR == true ? (buy == 1) : (filtcolor[2] == rngFilterColorDown and filtcolor == rngFilterColorUp) : na                            strategy.close("rngFiltLong", when = closingRuleLong)    strategy.close("rngFiltShort", when = closingRuleShort)    strategy.close("slowRngFiltLong", when = closingRuleLong)    strategy.close("slowRngFiltShort",  when = closingRuleShort)    strategy.close("fliLong", when = closingRuleLong)    strategy.close("fliShort", when = closingRuleShort)