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
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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Date Range | |||
| From | timestamp("01 Jan 2022 00:00 GMT+2") | time | inDate |
| To | timestamp("01 Jan 2022 23:00 GMT+2") | time | inDate |
| Trading Rules | |||
| IS STRATEGY | false | bool | close rngFiltLong close rngFiltShort close slowRngFiltLong close slowRngFiltShort close fliLong close fliShort line 225 |
| Apply Point Rule | false | bool | exit exitRngFiltLong exit exitRngFiltShort exit exitSlowRngFiltLong exit exitSlowRngFiltShort exit exitFliLong exit exitFliShort line 249 |
| Points (The points that it uses to take profit) | 80 | int | exit 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) | true | bool | Slow Range Filter buy sell closingRuleLong closingRuleShort Trend Line plotshape line 234 |
| use Following line or Slow Range Filter as entry point | false | bool | plotshape line 233 |
| Show Status Window (BETA) | false | bool | line 182 |
| Hide Labels | false | bool | plotshape |
| Exit Rule | Hull | session · options ["Hull", "RangeFilter", "Following/SlowRangeFilter"] | closingRuleLong closingRuleShort |
| Range Filter Colors | |||
| Fast Range Filter Color Up | color.green | color | filtcolor closingRuleLong closingRuleShort entry rngFiltLong entry rngFiltShort plotshape line 227 line 230 |
| Fast Range Filter Color Down | color.red | color | filtcolor closingRuleLong closingRuleShort entry rngFiltLong entry rngFiltShort plotshape line 227 line 230 |
| Slow Range Filter Color Up | color.green | color | filtcolorSlow entry slowRngFiltLong entry slowRngFiltShort plotshape line 243 line 246 |
| Slow Range Filter Color Down | color.red | color | filtcolorSlow entry slowRngFiltLong entry slowRngFiltShort plotshape line 243 line 246 |
| Hull Suite Colors | |||
| Hull Color Up | color.green | color | hullColor line 188 line 196 line 203 line 210 |
| Hull Color Down | color.red | color | hullColor line 190 line 198 line 205 line 212 |
| Following Line Colors | |||
| Follow Line Color Up | color.green | color | Trend Line |
| Follow Line Color Down | color.red | color | Trend Line |
| Range Filter Fast | |||
| Range Filter Fast Source | ohlc4 | source | smrng filt _hull line 125 line 126 line 127 |
| Range Filter Fast Sampling Period | 33 | int · min 1 | smrng |
| Range Filter Fast Multiplier | 2.1 | float · min 0.1 · step 0.1 | smrng |
| Range Filter Slow | |||
| Range Filter Slow Source | ohlc4 | source | smrngSlow filtSlow |
| Range Filter Slow Sampling Period | 48 | int · min 1 | smrngSlow |
| Range Filter Slow Multiplier | 3.4 | float · min 0.1 · step 0.1 | smrngSlow |
| Hull Suite | |||
| Source | close | source | unused |
| Hull Variation | Ehma | session · options ["Hma", "Thma", "Ehma"] | _hull line 125 line 126 line 127 |
| Color Hull according to trend? | true | bool | hullColor |
| Show as a Band? | true | bool | SHULL |
| Line Thickness | 1 | int | MHULL SHULL |
| Band Transparency | 40 | int · step 5 | Band Filler |
| Length(180-200 for floating S/R , 55 for swing entry) | 55 | int | _hull |
| Following Line | |||
| BB Period | 21 | int · min 1 | BBUpper BBLower |
| BB Deviations | 1.00 | float · min 0.1 · step 0.05 | BBUpper BBLower |
| ATR Filter | true | bool | line 151 line 155 line 159 line 161 line 165 line 169 |
| ATR Period | 5 | int · min 1 | TrendLine |
What it calculates
- EMAmath.abs(x - x[1]), t
avrng · line 102 - EMAavrng, wper
smoothrng · line 84 - EMAavrng, wper
smoothrngSlow · 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
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open rngFiltLong long | HULL > HULL[2] | On | 228 |
| Open rngFiltShort short | HULL < HULL[2] | On | 231 |
| Open fliLong long | HULL > HULL[2] | On | 237 |
| Open fliShort short | HULL < HULL[2] | On | 240 |
| Open slowRngFiltLong long | HULL > HULL[2] | On | 244 |
| Open slowRngFiltShort short | HULL < HULL[2] | On | 247 |
| Exit exitRngFiltLong limit | (isPointRule) | On | 250 |
| Exit exitRngFiltShort limit | (isPointRule) | On | 251 |
| Exit exitSlowRngFiltLong limit | (isPointRule) | On | 252 |
| Exit exitSlowRngFiltShort limit | (isPointRule) | On | 253 |
| Exit exitFliLong limit | sell == 1 | On | 254 |
| Exit exitFliShort limit | buy == 1 | On | 255 |
| Close rngFiltLong | closingRuleLong | On | 259 |
| Close rngFiltShort | closingRuleShort | On | 260 |
| Close slowRngFiltLong | closingRuleLong | On | 261 |
| Close slowRngFiltShort | closingRuleShort | On | 262 |
| Close fliLong | closingRuleLong | On | 263 |
| Close fliShort | closingRuleShort | On | 264 |
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.
- 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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Follow The Ranging Hull this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| Trend Following with Bollinger Bands by Robrecht99 | sma stdev ema atr | v5 strategy | +2.5% | 7 | 1.7% |
| [KL] BOLL + MACD Strategy v2 (published) by DojiEmoji | sma stdev ema atr | v4 strategy | −32.1% | 28 | 54.0% |
| [EURUSD60] BB Expansion Strategy by kasaism | sma stdev ema atr | v4 strategy | No trades on this market | ||
| [KL] Bollinger bands + RSI Strategy by DojiEmoji | sma stdev atr ema | v4 strategy | +28.2% | 30 | 14.7% |
| [KL] Bollinger Bands Consolidation Strategy by DojiEmoji | sma stdev atr ema | v4 strategy | +39.1% | 33 | 19.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 verifiedNeither 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 120 ms | Yes 1,000 bars in 155 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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)