Pine Script v5 · Strategy
Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN]
A Pine Script v5 strategy built on ATR (6), EMA (src, 1) and Crossover (ema, xATRTrailingStop). It has 9 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade commits 1.0% of equity and pays 0.075 commission. 35 settings; defaults include Key Vaule. \'This changes the sensitivity\' 2, ATR Period 6 and Length 80.
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 Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN] repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
- How did Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN] do on BTCUSDT 1D with default settings?
- −30.72%
- From 26 Jan 2024 to 21 Oct 2026, over 10 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- What alerts does Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN] have?
- 8
- UT Long; UT Short; Red; Green; and more.
- Does Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN] run in Pine Script v6?
- No
- The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L132: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 Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN] use a stop loss?
- No
- Its exits set a profit target but no stop.
BTCUSDT · 1D · default settings
- MHULL
- SHULL
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −30.72%
- −$153.60
- Buy and hold
- +102.5%
- same period
- Closed trades
- 10
- 4 won · 6 lost
- Profitable
- 40.0%
- of closed trades
- Profit factor
- 0.50
- gross profit ÷ gross loss
- Max drawdown
- 63.47%
- −$317.37
One run with the author's default settings, $500 starting capital, commission as the script sets it. A short position was still open at the last bar. 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.ema(src, 1) ignores the settings line 27
Line 27 hard-codes 1 where line 61 uses “FastLength”. Changing those settings moves one band but not this one.
ta.ema(src, 1)ta.ema(src, BBBB) -
Check
2 settings do nothing
“░░░░░░░░░░░░░░░░░░░░░░░░░”, “░░░░░░░░░░░░░░░░░░░░░░░░░” are declared but never read.
-
Check
No stop loss
strategy.exit is used without a stop, loss or trailing stop.
-
Note
3 settings have no label
In the settings dialog AAA (line 66), startPeriodTime (line 152), endPeriodTime (line 154) show an empty name. The labels on this page come from the variable names.
-
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 211, 212, 213. 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 |
|---|---|---|---|
| Key Vaule. \'This changes the sensitivity\' | 2 | int | nLoss |
| ATR Period | 6 | int | xATR |
| Signals from Heikin Ashi Candles | false | bool | src |
| ░░░░░░░░░░░░░░░░░░░░░░░░░ | false | bool | unused |
| Length | 80 | int | CCC CCCC DDDD DDDDD mAAAAA |
| FastLength | 27 | int | fastMA BBBBBB mAAAAA |
| SlowLength | 50 | int | slowMA BBBBBB mAAAAA |
| AAA (no label in the script) | 0.5 | float | DDD EEEEE |
| ░░░░░░░░░░░░░░░░░░░░░░░░░ | false | bool | unused |
| Source | close | source | _hull |
| Hull Variation | Hma | string · options ['Hma', 'Thma', 'Ehma'] | _hull line 122 |
| Length(180-200 for floating S/R , 55 for swing entry) | 55 | int | _hull |
| Length multiplier (Used to view higher timeframes with straight band) | 1.0 | float | _hull |
| Show Hull MA from X timeframe? (good for scalping) | false | bool | HULL |
| Higher timeframe | 240 | timeframe | HULL |
| Color Hull according to trend? | true | bool | hullColor barcolor |
| Color candles based on Hull\'s Trend? | false | bool | barcolor |
| Show as a Band? | true | bool | SHULL |
| Line Thickness | 1 | int | MHULL SHULL |
| Band Transparency | 40 | int · step 5 | Band Filler |
| Date Range | |||
| Start | true | bool | start |
| Start Period Time (no label in the script) | timestamp('1 Jan 2019') | time | start |
| End | true | bool | end |
| End Period Time (no label in the script) | timestamp('31 Dec 2030') | time | end |
| Trade Direction | |||
| Trade Direction | Long and Short | string · options ['Long and Short', 'Long Only', 'Short Only'] | entry Long entry Short line 200 line 203 |
| Take Profit | |||
| Take Profit 1 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP1 |
| % Of Position | 100 | int · min 0 | exit TP1 |
| Take Profit 2 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP2 |
| % Of Position | 100 | int · min 0 | exit TP2 |
| Take Profit 3 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP3 |
| % Of Position | 100 | int · min 0 | exit TP3 |
| Take Profit 4 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP4 |
| Stop Loss | |||
| Stop Loss (%) | 15 | float · min 0.01 | slLongClose slShortClose |
| Leverage | |||
| Leverage | 1 | float · step .5 | contracts |
| ProfitView Alert Syntax | |||
| Alert Syntax Prefix | PV-AccountNameHere_Strategy-Name-Here | string | alertSyntaxBase |
What it calculates
- ATRATR Period (6)
xATR · line 16 - EMAsrc, 1
ema · line 27 - Crossoverema, xATRTrailingStop
above · line 28 - CrossoverxATRTrailingStop, ema
below · line 29 - EMABBB, FastLength (27)
fastMA · line 61 - EMABBB, SlowLength (50)
slowMA · line 62 - LowestBBBBBB, Length (80)
CCC · line 72 - HighestBBBBBB, Length (80)
CCCC · line 73 - LowestDDD, Length (80)
DDDD · line 76 - HighestDDD, Length (80)
DDDDD · line 77
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 94 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 Long long | longCondition and tradeDirection != 'Short Only' and isInLongPosition == false | On | 201 |
| Open Short short | shortCondition and tradeDirection != 'Long Only' and isInShortPosition == false | On | 204 |
| Exit TP1 limit | calcPeriod | On | 207 |
| Exit TP2 limit | calcPeriod | On | 208 |
| Exit TP3 limit | calcPeriod | On | 209 |
| Exit TP4 limit | calcPeriod | On | 210 |
| Close Long | slLongCloseclose < strategy.position_avg_price * (1 - stoplossPercent) | On | 211 |
| Close Short | slShortCloseclose > strategy.position_avg_price * (1 + stoplossPercent) | On | 212 |
| Close | closeLongCondition or closeShortCondition | On | 213 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| UT Long | alertcondition | UT Long | 38 |
| UT Short | alertcondition | UT Short | 39 |
| (no title) | alert | Red | 84 |
| (no title) | alert | Green | 86 |
| Hull trending up. | alertcondition | Hull trending up. | 134 |
| Hull trending down. | alertcondition | Hull trending down. | 135 |
| (no title) | alert | alertSyntaxBase + 'side:long' | 202 |
| (no title) | alert | alertSyntaxBase + 'side:short' | 205 |
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- ClearHigher-timeframe data2 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 timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −30.7% | +102.5% | 10 | 40% | 0.50 | 63.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +22.5% | +5.5% | 13 | 54% | 1.69 | 18.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −29.5% | +9.8% | 10 | 40% | 0.55 | 65.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −13.8% | +8.4% | 12 | 42% | 0.77 | 40.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −28.3% | +16.7% | 17 | 29% | 0.75 | 61.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +37.2% | +21.5% | 10 | 40% | 1.71 | 26.4% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −42.9% | +148.3% | 13 | 38% | 0.42 | 74.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +31.0% | +17.1% | 11 | 45% | 3.42 | 15.2% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 3 | 0% | −$142.75 |
| Sideways market | 3 | 67% | −$0.79 |
| Falling market | 4 | 50% | −$9.81 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
58.8%
The 95th percentile of the worst drawdown when the same 10 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 33.7% to 58.8%; the tick is what actually happened, 61.3%. Order luck alone moves it this much.
All 10 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 14 Jun 2024 66,773.00 | 11 Nov 2024 80,370.00 | 150 | −$102.64 |
| long | 18 Jan 2025 104,077.00 | 27 Feb 2025 84,250.10 | 40 | −$76.24 |
| short | 8 Apr 2025 79,163.20 | 23 Apr 2025 93,443.00 | 15 | −$58.45 |
| short | 2 Jun 2025 105,643.00 | 16 Jul 2025 117,758.00 | 44 | −$30.54 |
| long | 16 Jul 2025 117,758.00 | 14 Nov 2025 99,692.00 | 121 | −$35.97 |
| long | 9 Dec 2025 90,634.40 | 24 Jan 2026 89,600.30 | 46 | −$2.53 |
| short | 24 Jan 2026 89,600.30 | 5 Mar 2026 72,666.80 | 40 | $36.36 |
| long | 5 Mar 2026 72,666.80 | 18 May 2026 77,457.70 | 74 | $14.81 |
| short | 18 May 2026 77,457.70 | 5 Jul 2026 63,144.00 | 48 | $44.94 |
| long | 5 Jul 2026 63,144.00 | 16 Sep 2026 75,644.50 | 73 | $56.91 |
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 |
|---|---|---|---|---|---|
| Strategy Myth-Busting #1 - UT Bot+STC+Hull [MYN] this page | — | v5 strategy | −30.7% | 10 | 63.5% |
| Richard's Strategy by Deepak8369 | highest lowest atr ema | v4 strategy | +34.6% | 70 | 26.3% |
| Classic Long Term Trend Following System by Robrecht99 | ema highest lowest atr | v5 strategy | +2.9% | 5 | 1.1% |
| Strategy for UT Bot Alerts indicator by StrategiesForEveryone | ema atr highest lowest | v5 strategy | −4.5% | 42 | 15.7% |
| Simple and Profitable Scalping Strategy (ForexSignals TV) by kevinmck100 | ema atr highest lowest | v5 strategy | No trades on this market | ||
| ATR + STC + MA by Romedius | ema lowest highest atr | v5 strategy | −1.2% | 15 | 3.3% |
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.
- 3 strategy calls use the when = argument (line 211, 212, 213). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 17 settings use the untyped input() (line 13, 14, 15, 56, 57, 58, 59, 66, 97, 99, 101, 102, 103, 105, 106, 107, 108). 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.
Same 10 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 13: input() → input.int()
- Line 14: input() → input.int()
- Line 15: input() → input.bool()
- Line 56: input() → input.bool()
- Line 57: input() → input.int()
- Line 58: input() → input.int()
14 more edits
- Line 59: input() → input.int()
- Line 66: input() → input.float()
- Line 97: input() → input.bool()
- Line 99: input() → input.source()
- Line 101: input() → input.int()
- Line 102: input() → input.float()
- Line 103: input() → input.bool()
- Line 105: input() → input.bool()
- Line 106: input() → input.bool()
- Line 107: input() → input.bool()
- Line 108: input() → input.int()
- Line 211: when = slLongClose → if block
- Line 212: when = slShortClose → if block
- Line 213: when = closeLongCondition or closeShortCondition → if block
⋯// Inputs-a = input(2, title='Key Vaule. \'This changes the sensitivity\'')+a = input.int(2, title='Key Vaule. \'This changes the sensitivity\'')-c = input(6, title='ATR Period')+c = input.int(6, title='ATR Period')-h = input(false, title='Signals from Heikin Ashi Candles')+h = input.bool(false, title='Signals from Heikin Ashi Candles')xATR = ta.atr(c)⋯//indicator(title='[SHK] Schaff Trend Cycle (STC)', shorttitle='STC', overlay=false)-STCDivider = input(false, '░░░░░░░░░░░░░░░░░░░░░░░░░')+STCDivider = input.bool(false, '░░░░░░░░░░░░░░░░░░░░░░░░░')-EEEEEE = input(80, 'Length')+EEEEEE = input.int(80, 'Length')-BBBB = input(27, 'FastLength')+BBBB = input.int(27, 'FastLength')-BBBBB = input(50, 'SlowLength')+BBBBB = input.int(50, 'SlowLength')AAAA(BBB, BBBB, BBBBB) =>⋯AAAAA(EEEEEE, BBBB, BBBBB) =>- AAA = input(0.5)+ AAA = input.float(0.5) var CCCCC = 0.0⋯//study("Hull Suite by InSilico", overlay=true)-HullDivider = input(false, '░░░░░░░░░░░░░░░░░░░░░░░░░')+HullDivider = input.bool(false, '░░░░░░░░░░░░░░░░░░░░░░░░░')//INPUT-srcHull = input(close, title='Source')+srcHull = input.source(close, title='Source')modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma', 'Ehma'])-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)')-lengthMult = input(1.0, title='Length multiplier (Used to view higher timeframes with straight band)')+lengthMult = input.float(1.0, title='Length multiplier (Used to view higher timeframes with straight band)')-useHtf = input(false, title='Show Hull MA from X timeframe? (good for scalping)')+useHtf = input.bool(false, title='Show Hull MA from X timeframe? (good for scalping)')htf = input.timeframe('240', title='Higher timeframe')-switchColor = input(true, 'Color Hull according to trend?')+switchColor = input.bool(true, 'Color Hull according to trend?')-candleCol = input(false, title='Color candles based on Hull\'s Trend?')+candleCol = input.bool(false, title='Color candles based on Hull\'s Trend?')-visualSwitch = input(true, title='Show as a Band?')+visualSwitch = input.bool(true, title='Show as a Band?')-thicknesSwitch = input(1, title='Line Thickness')+thicknesSwitch = input.int(1, title='Line Thickness')transpSwitch = input.int(40, title='Band Transparency', step=5)⋯ strategy.exit('TP4', profit=per(tp4))- strategy.close('Long', qty_percent=100, comment='SL Long', when=slLongClose)+ if slLongClose+ strategy.close('Long', qty_percent=100, comment='SL Long')- strategy.close('Short', qty_percent=100, comment='SL Short', when=slShortClose)+ if slShortClose+ strategy.close('Short', qty_percent=100, comment='SL Short')- strategy.close_all(when=closeLongCondition or closeShortCondition, comment='Close Postion')+ if closeLongCondition or closeShortCondition+ strategy.close_all(comment='Close Postion')Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L132: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.
⋯// © myn-//@version=5+//@version=6strategy('Strategy Myth-Busting #1 - UT Bot+STC+Hull+ [MYN]', max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=500, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.075)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 98 ms | With a workaround 1,000 bars in 160 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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/// © myn//@version=5strategy('Strategy Myth-Busting #1 - UT Bot+STC+Hull+ [MYN]', max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=500, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.075)///////////////////////////////////////* Put your strategy logic below */////////////////////////////////////////2oVDibie_bk/// UT Bot Alerts by QuantNomad - https://www.tradingview.com/script/n8ss8BID-UT-Bot-Alerts/// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//study(title="UT Bot Alerts", overlay = true)// Inputsa = input(2, title='Key Vaule. \'This changes the sensitivity\'')c = input(6, title='ATR Period')h = input(false, title='Signals from Heikin Ashi Candles')xATR = ta.atr(c)nLoss = a * xATRsrc = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : closexATRTrailingStop = 0.0iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLossiff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2pos = 0iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blueema = ta.ema(src, 1)above = ta.crossover(ema, xATRTrailingStop)below = ta.crossover(xATRTrailingStop, ema)buy = src > xATRTrailingStop and abovesell = src < xATRTrailingStop and belowbarbuy = src > xATRTrailingStopbarsell = src < xATRTrailingStop//plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)//plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)barcolor(barbuy ? color.green : na)barcolor(barsell ? color.red : na)alertcondition(buy, 'UT Long', 'UT Long')alertcondition(sell, 'UT Short', 'UT Short')/////////////////////////////////////////////////======[ Position Check (long/short) ]======/////////////////////////////////////////////////last_longCondition = float(na)last_shortCondition = float(na)last_longCondition := buy ? time : nz(last_longCondition[1])last_shortCondition := sell ? time : nz(last_shortCondition[1])in_longCondition = last_longCondition > last_shortConditionin_shortCondition = last_shortCondition > last_longConditionUTBotBuyZone = in_longConditionUTBotSellZone = in_shortCondition/// STC Indicator - A Better MACD [SHK] By shayankm - https://www.tradingview.com/script/WhRRThMI-STC-Indicator-A-Better-MACD-SHK/// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//[SHK] STC colored indicator//https://www.tradingview.com/u/shayankm///indicator(title='[SHK] Schaff Trend Cycle (STC)', shorttitle='STC', overlay=false)STCDivider = input(false, '░░░░░░░░░░░░░░░░░░░░░░░░░')EEEEEE = input(80, 'Length')BBBB = input(27, 'FastLength')BBBBB = input(50, 'SlowLength')AAAA(BBB, BBBB, BBBBB) => fastMA = ta.ema(BBB, BBBB) slowMA = ta.ema(BBB, BBBBB) AAAA = fastMA - slowMA AAAAAAAAA(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]) EEEEEmAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)if mAAAAA[3] <= mAAAAA[2] and mAAAAA[2] > mAAAAA[1] and mAAAAA > 75 alert('Red', alert.freq_once_per_bar)if mAAAAA[3] >= mAAAAA[2] and mAAAAA[2] < mAAAAA[1] and mAAAAA < 25 alert('Green', alert.freq_once_per_bar)//plot(mAAAAA, color=mColor, title='STC', linewidth=2)//ul = plot(25, color=color.new(color.white, 0 ))//ll = plot(75, color=color.new(color.purple, 0))//fill(ul, ll, color=color.new(color.gray, 96))STCGreenAndBelow25AndRising = mAAAAA > mAAAAA[1] and mAAAAA < 25STCRedAndAndAbove75AndFalling = mAAAAA < mAAAAA[1] and mAAAAA > 75/// Hull Suite by InSilico// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//Basic Hull Ma Pack tinkered by InSilico - https://www.tradingview.com/script/hg92pFwS-Hull-Suite///study("Hull Suite by InSilico", overlay=true)HullDivider = input(false, '░░░░░░░░░░░░░░░░░░░░░░░░░')//INPUTsrcHull = input(close, title='Source')modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma', 'Ehma'])length = input(55, title='Length(180-200 for floating S/R , 55 for swing entry)')lengthMult = input(1.0, title='Length multiplier (Used to view higher timeframes with straight band)')useHtf = input(false, title='Show Hull MA from X timeframe? (good for scalping)')htf = input.timeframe('240', title='Higher timeframe')switchColor = input(true, 'Color Hull according to trend?')candleCol = input(false, title='Color candles based on Hull\'s Trend?')visualSwitch = input(true, title='Show as a Band?')thicknesSwitch = input(1, title='Line Thickness')transpSwitch = input.int(40, title='Band Transparency', step=5)//FUNCTIONS//HMAHMA(_src, _length) => ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length), math.round(math.sqrt(_length)))//EHMA EHMA(_src, _length) => ta.ema(2 * ta.ema(_src, _length / 2) - ta.ema(_src, _length), math.round(math.sqrt(_length)))//THMA THMA(_src, _length) => ta.wma(ta.wma(_src, _length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length)//SWITCHMode(modeSwitch, src, len) => modeSwitch == 'Hma' ? HMA(src, len) : modeSwitch == 'Ehma' ? EHMA(src, len) : modeSwitch == 'Thma' ? THMA(src, len / 2) : na//OUT_hull = Mode(modeSwitch, srcHull, int(length * lengthMult))HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hullMHULL = HULL[0]SHULL = HULL[2]//COLORhullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800//PLOT///< FrameFi1 = plot(MHULL, title='MHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)Fi2 = plot(visualSwitch ? SHULL : na, title='SHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)alertcondition(ta.crossover(MHULL, SHULL), title='Hull trending up.', message='Hull trending up.')alertcondition(ta.crossover(SHULL, MHULL), title='Hull trending down.', message='Hull trending down.')///< Ending Fillerfill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=transpSwitch)///BARCOLORbarcolor(color=candleCol ? switchColor ? hullColor : na : na)HullGreen = hullColor == #00ff00HullRed = hullColor == #ff0000////////////////////////////////////////* Put your strategy rules below *///////////////////////////////////////longCondition = STCGreenAndBelow25AndRising and HullGreen and UTBotBuyZoneshortCondition = STCRedAndAndAbove75AndFalling and HullRed and UTBotSellZone//define as 0 if do not want to usecloseLongCondition = 0closeShortCondition = 0//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░useStartPeriodTime = input.bool(true, 'Start', group='Date Range', inline='Start Period')startPeriodTime = input.time(timestamp('1 Jan 2019'), '', group='Date Range', inline='Start Period')useEndPeriodTime = input.bool(true, 'End', group='Date Range', inline='End Period')endPeriodTime = input.time(timestamp('31 Dec 2030'), '', group='Date Range', inline='End Period')start = useStartPeriodTime ? startPeriodTime >= time : falseend = useEndPeriodTime ? endPeriodTime <= time : falsecalcPeriod = not start and not end// Trade Direction // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tradeDirection = input.string('Long and Short', title='Trade Direction', options=['Long and Short', 'Long Only', 'Short Only'], group='Trade Direction')// Percent as Points// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░per(pcnt) => strategy.position_size != 0 ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)// Take profit 1// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp1 = input.float(title='Take Profit 1 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 1')q1 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 1')// Take profit 2// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp2 = input.float(title='Take Profit 2 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 2')q2 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 2')// Take profit 3// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp3 = input.float(title='Take Profit 3 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 3')q3 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 3')// Take profit 4// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp4 = input.float(title='Take Profit 4 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit')/// Stop Loss// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░stoplossPercent = input.float(title='Stop Loss (%)', defval=15, minval=0.01, group='Stop Loss') * 0.01slLongClose = close < strategy.position_avg_price * (1 - stoplossPercent)slShortClose = close > strategy.position_avg_price * (1 + stoplossPercent)/// Leverage// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░leverage = input.float(1, 'Leverage', step=.5, group='Leverage')contracts = math.min(math.max(.000001, strategy.equity / close * leverage), 1000000000)/// Trade State Management// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░isInLongPosition = strategy.position_size > 0isInShortPosition = strategy.position_size < 0/// ProfitView Alert Syntax String Generation// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░alertSyntaxPrefix = input.string(defval='PV-AccountNameHere_Strategy-Name-Here', title='Alert Syntax Prefix', group='ProfitView Alert Syntax')alertSyntaxBase = alertSyntaxPrefix + '\n#' + str.tostring(open) + ',' + str.tostring(high) + ',' + str.tostring(low) + ',' + str.tostring(close) + ',' + str.tostring(volume) + ','/// Trade Execution// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░if calcPeriod if longCondition and tradeDirection != 'Short Only' and isInLongPosition == false strategy.entry('Long', strategy.long, qty=contracts) alert(message=alertSyntaxBase + 'side:long', freq=alert.freq_once_per_bar_close) if shortCondition and tradeDirection != 'Long Only' and isInShortPosition == false strategy.entry('Short', strategy.short, qty=contracts) alert(message=alertSyntaxBase + 'side:short', freq=alert.freq_once_per_bar_close) //Inspired by Multiple %% profit exits example By adolgo https://www.tradingview.com/script/kHhCik9f-Multiple-profit-exits-example/ strategy.exit('TP1', qty_percent=q1, profit=per(tp1)) strategy.exit('TP2', qty_percent=q2, profit=per(tp2)) strategy.exit('TP3', qty_percent=q3, profit=per(tp3)) strategy.exit('TP4', profit=per(tp4)) strategy.close('Long', qty_percent=100, comment='SL Long', when=slLongClose) strategy.close('Short', qty_percent=100, comment='SL Short', when=slShortClose) strategy.close_all(when=closeLongCondition or closeShortCondition, comment='Close Postion')