Pine Script v5 · Strategy
Kahlman HullMA - WT Cross Strategy
A Pine Script v5 strategy built on EMA (apL_src, 6), SMA (wt1L, 4) and RSI (src_src, 13). It has 10 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays no commission. 94 settings; defaults include TP1 Profit Percent 10, TP2 Profit Percent 15 and Long Take Profit 1 8.9.
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 Kahlman HullMA - WT Cross Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 13 of 13 trades.
- How did Kahlman HullMA - WT Cross Strategy do on BTCUSDT 1D with default settings?
- +1.01%
- From 26 Jan 2024 to 21 Oct 2026, over 54 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Kahlman HullMA - WT Cross Strategy run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 54 before, 23 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Kahlman HullMA - WT Cross Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 472, 474, 476, 482, 484, 486.
- Does Kahlman HullMA - WT Cross Strategy run in Zeal Terminal?
- Yes
- It compiles in 103 ms and runs 1,000 bars in 304 ms, in the browser.
BTCUSDT · 1D · default settings
- Long Plot
- Short Plot
- Long/Short TP1
- Long/Short TP2
- Long/Short SL
- Long/Short Position Check
- Long Trailing Stop
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.01%
- $1.01
- Buy and hold
- +102.5%
- same period
- Closed trades
- 54
- 25 won · 29 lost
- Profitable
- 46.3%
- of closed trades
- Profit factor
- 1.01
- gross profit ÷ gross loss
- Max drawdown
- 33.27%
- −$48.12
One run with the author's default settings, $100 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.sma(wt1L, 4) ignores the settings line 203
Line 203 hard-codes 4 where line 301 uses “K”. Changing those settings moves one band but not this one.
ta.sma(wt1L, 4)ta.sma(wt1L, smoothK) -
Likely bug
ta.sma(wt1S, 4) ignores the settings line 231
Line 231 hard-codes 4 where line 301 uses “K”. Changing those settings moves one band but not this one.
ta.sma(wt1S, 4)ta.sma(wt1S, smoothK) -
Check
12 settings do nothing
“|| LONG TP SETTINGS ||”, “|| SHORT TP SETTINGS ||”, “|| STOP LOSS SETTINGS ||”, “|| TRAILING STOP SETTINGS ||”, “|| POSITION CHECK SETTINGS ||”, “|| WT CROSS SETTINGS ||”, “|| HULLMA SETTINGS ||”, “|| STOCH RSI SETTINGS ||”, “|| VOLUME SETTINGS ||”, “|| ADX SETTINGS ||”, “|| WUNDERBIT SETTINGS ||”, “|| DATE & DATE RANGE SETTINGS ||” are declared but never read.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
4 settings have no label
In the settings dialog startDate (line 346), endDate (line 347), timeSession (line 350), timeSession2 (line 375) 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.
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 |
|---|---|---|---|
| || LONG TP SETTINGS || | false | bool | unused |
| Long On | true | bool | line 469 |
| TP1 Profit PercentPercentage of balance to be taken for take profit 1-2. | 10 | float · min 0 · max 100 · step 5 | exit LONG |
| TP2 Profit PercentPercentage of balance to be taken for take profit 1-2. | 15 | float · min 0 · max 100 · step 5 | exit LONG1 |
| Long Take Profit 1Long take profit 1 percent setting | 8.9 | float · min 0.1 · step 0.1 | exitTP positionCheckLong |
| Long Take Profit 2Long take profit 2 percent setting. / Close TP2 | 13.6 | float · min 0.1 · step 0.1 | exitTP2 |
| On | true | bool | LSTP2Lines LSTP3Lines exit LONG1 exit LONG line 473 |
| Long Take Profit 3Long take profit 3 percent setting. / Close TP3 | 13.6 | float · min 0.1 · step 0.1 | exitTP3 |
| On | false | bool | LSTP3Lines exit LONG2 exit LONG1 line 475 |
| Long TP1 SourceTP1 up or down control. Close process if selected 'source' is less than TP1 | hc2 | string · options ["hc2", "co2", "hco3", "hlo3", "ho2", "lo2", "open", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high"] | source_long |
| Long TP2 SourceTP2 up or down control. Close process if selected 'source' is less than TP2 | hc2 | string · options ["hc2", "co2", "hco3", "hlo3", "ho2", "lo2", "open", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high"] | source_long2 |
| || SHORT TP SETTINGS || | false | bool | unused |
| Short On | true | bool | line 479 |
| TP1 Profit PercentPercentage of balance to be taken for take profit 1-2. | 50 | float · min 0 · max 100 · step 5 | exit SHORT |
| TP2 Profit PercentPercentage of balance to be taken for take profit 1-2. | 70 | float · min 0 · max 100 · step 5 | exit SHORT1 |
| Short Take Profit 1Short take profit 1 percent setting | 8.2 | float · min 0.1 · step 0.1 | exitTP positionCheckShort |
| Short Take Profit 2Short take profit 2 percent setting. / Close TP3 | 13.4 | float · min 0.1 · step 0.1 | exitTP2 |
| On | true | bool | LSTP2Lines LSTP3Lines exit SHORT1 exit SHORT line 483 |
| Short Take Profit 3Short take profit 3 percent setting. / Close TP3 | 13.9 | float · min 0.1 · step 0.1 | exitTP3 |
| On | false | bool | LSTP3Lines exit SHORT2 exit SHORT1 line 485 |
| Short TP1 SourceTP1 up or down control. Close process if selected 'source' is greater than TP1 | lc2 | string · options ["lc2", "lco3", "hco3", "hc2", "co2", "hlo3", "lo2", "ho2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"] | source_short |
| Short TP2 SourceTP2 up or down control. Close process if selected 'source' is greater than TP2 | lco3 | string · options ["lc2", "lco3", "hco3", "hc2", "co2", "hlo3", "lo2", "ho2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"] | source_short2 |
| || STOP LOSS SETTINGS || | false | bool | unused |
| LongStop loss percent(Red line) | 7.1 | float · min 0.1 · step 0.1 | exitSL |
| Short | 7.9 | float · min 0.1 · step 0.1 | exitSL |
| || TRAILING STOP SETTINGS || | false | bool | unused |
| Long Trailing SL OnTrailing stop loss mode. | true | bool | priceStopL TrailingStopLines |
| Change LineOn: If price is greater than TP1. Off: If price is greater than Long Position Check. | true | bool | trailingStopChangeL1 |
| LongTrailing stop loss percent. Note: Activated if greater than TP1. Otherwise, the stop level is the value on a bottom line.(Yellow dot line) | 3.6 | float · min 0.1 · step 0.1 | priceStopL stopMeasure |
| Short Trailing SL OnTrailing stop loss mode. | false | bool | priceStopS TrailingStopLines2 |
| Change LineOn: If price is greater than TP1. Off: If price is greater than Short Position Check. | true | bool | trailingStopChangeS1 |
| ShortTrailing stop loss percent. Note: Activated if greater than TP1. Otherwise, the stop level is the value on a bottom line.(Yellow dot line) | 3.4 | float · min 0.1 · step 0.1 | stopMeasure priceStopS |
| || POSITION CHECK SETTINGS || | false | bool | unused |
| Long Position Check OnLong Position check mode. Depends on TP1 percentage. It works as a '%X' / 'Senstive Value'. | true | bool | positionCheckLong PositionCheckColors PositionCheckLines |
| SourceLong check senstive up or down control. Close process if selected 'source' is less than Position Check Line(Yellow solid line) | co2 | string · options ["hco3", "lco3", "hc2", "lc2", "co2", "ho2", "lo2", "hlo3", "close", "open", "hl2", "hlc3", "ohlc4", "hlcc4", "low", "high"] | source_CheckLong |
| Senstive | 1.7 | float · min 1 · step 0.01 | positionCheckLong |
| Short Position Check OnShort Position check mode. It works as a '%X' / 'Senstive Value'. | true | bool | positionCheckShort PositionCheckColors PositionCheckLines |
| SourceShort check senstive up or down control. Close process if selected 'source' is greater than Position Check Line(Yellow solid line) | low | string · options ["lco3", "hco3", "lc2", "hc2", "co2", "lo2", "ho2", "hlo3", "close", "open", "hl2", "hlc3", "ohlc4", "hlcc4", "low", "high"] | source_CheckShort |
| Senstive | 1.4 | float · min 1 · step 0.01 | positionCheckShort |
| || WT CROSS SETTINGS || | false | bool | unused |
| Channel Length | 6 | int | esaL rL |
| Average Length | 23 | int | tciL |
| Source | hlc3 | string · options ["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"] | apL_src |
| Channel Length | 8 | int | esaS rS |
| Average Length | 19 | int | tciS |
| Source | hlc3 | string · options ["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"] | apS_src |
| || HULLMA SETTINGS || | false | bool | unused |
| Source | hl2 | string · options ["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"] | hull_src |
| Lookback | 24 | int | p a b |
| Gain | 10000 | int | a b |
| || STOCH RSI SETTINGS || | false | bool | unused |
| Stoch RSIStoch RSI On/Off | true | bool | LStoch SStoch |
| K | 2 | int · min 1 | k |
| D | 3 | int · min 1 | d |
| RSI Length | 13 | int · min 1 | rsi1 |
| Stochastic Length | 13 | int · min 1 | k |
| RSI Source | hl2 | string · options ["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"] | src_src |
| || VOLUME SETTINGS || | false | bool | unused |
| On/Off | true | bool | volEntry |
| Mult. | 0.6 | float · min 0 · step 0.1 | vol |
| Sma volume lenght | 3 | int · min 1 | vol |
| Vwma volume lenght | 3 | int · min 1 | vol |
| Wma volume lenght | 4 | int · min 1 | vol |
| || ADX SETTINGS || | false | bool | unused |
| On | false | bool | ADXEntry |
| ADX Smoothing | 14 | int | adx sig |
| DI Length | 14 | int | plus minus sig |
| Buy Level | 20 | int | ADXEntry |
| || WUNDERBIT SETTINGS || | false | bool | unused |
| || DATE & DATE RANGE SETTINGS || | false | bool | unused |
| Start Date (no label in the script) | timestamp("1 Jan 2020 00:00 +0000") | time | strategyTime line 392 line 394 |
| End Date (no label in the script) | timestamp("1 Jan 9999 03:00 +0000") | time | strategyTime line 392 line 394 |
| Wunderbit Comments | |||
| Long Entry Comment | ENTER-LONG | string | entry LONG |
| Long Exit Comment | EXIT-LONG | string | exit LONG exit LONG1 exit LONG2 close LONG |
| Short Entry Comment | ENTER-SHORT | string | entry SHORT |
| Short Exit Comment | EXIT-SHORT | string | exit SHORT exit SHORT1 exit SHORT2 close SHORT |
| LONG | |||
| Long/Time Range & Weekdays On/OffStart Date and End Date not inclueded | true | bool | entry LONG line 367 line 470 |
| Time Session (no label in the script) | 0000-0000 | session | entry LONG line 470 |
| Monday | true | bool | days |
| Tuesday | true | bool | days |
| Wednesday | true | bool | days |
| Thursday | true | bool | days |
| Friday | true | bool | days |
| Saturday | false | bool | days |
| SundayTrade days? | true | bool | days |
| SHORT | |||
| Short/Time Range & Weekdays On/OffStart Date and End Date not inclueded | false | bool | entry SHORT line 391 line 480 |
| Time Session2 (no label in the script) | 0300-0300 | session | entry SHORT line 480 |
| Monday | true | bool | days2 |
| Tuesday | true | bool | days2 |
| Wednesday | true | bool | days2 |
| Thursday | true | bool | days2 |
| Friday | true | bool | days2 |
| Saturday | true | bool | days2 |
| SundayTrade days? | true | bool | days2 |
What it calculates
- EMAapL_src, Channel Length (6)
esaL · line 198 - EMAmath.abs(apL_src - esaL), Channel Length (6)
rL · line 199 - EMAciL, Average Length (23)
tciL · line 201 - SMAwt1L, 4
wt2L · line 203 - EMAapS_src, Channel Length (8)
esaS · line 226 - EMAmath.abs(apS_src - esaS), Channel Length (8)
rS · line 227 - EMAciS, Average Length (19)
tciS · line 229 - SMAwt1S, 4
wt2S · line 231 - RSIsrc_src, RSI Length (13)
rsi1 · line 300 - SMA / Stochta.stoch(rsi1, rsi1, rsi1, lengthStoch), K (2)
k · line 301 - SMAk, D (3)
d · line 302 - SMA / VWMA / WMAvolume, Sma volume lenght (3)
vol · line 312 - Changehigh
up · line 320 - Changelow
down · line 321 - RMAta.tr, len
truerange · line 324 - RMAmath.abs(plus - minus) / (sum == 0 ? 1 : sum), ADX Smoothing (14)
adx · line 331
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 147 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 | inSession(sessionOnOff ? timeSession:na) | On | 471 |
| Exit LONG stop and limit | strategyTime | On | 472 |
| Exit LONG1 stop and limit | tp2OnOffL | On “On” | 474 |
| Exit LONG2 stop and limit | tp3OnOffL | Off “On” | 476 |
| Close LONG | longConditionExit or longTStop | On | 478 |
| Open SHORT short | inSession2(sessionOnOff2 ? timeSession2:na) | On | 481 |
| Exit SHORT stop and limit | strategyTime | On | 482 |
| Exit SHORT1 stop and limit | tp2OnOffS | On “On” | 484 |
| Exit SHORT2 stop and limit | tp3OnOffS | Off “On” | 486 |
| Close SHORT | shortConditionExit or shortTStop | On | 488 |
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, and the live replay matched history.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- 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 | +1.0% | +102.5% | 54 | 46% | 1.01 | 33.3% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +8.3% | +5.5% | 17 | 41% | 1.30 | 15.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +92.0% | +9.8% | 81 | 54% | 1.50 | 41.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −37.5% | +8.4% | 24 | 17% | 0.32 | 37.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +55.4% | +16.7% | 76 | 53% | 1.28 | 44.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +1.5% | +21.5% | 30 | 47% | 1.03 | 17.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −5.0% | +148.3% | 47 | 51% | 0.96 | 43.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +7.4% | +17.1% | 15 | 47% | 1.25 | 14.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 | 18 | 56% | $22.47 |
| Sideways market | 25 | 44% | −$9.64 |
| Falling market | 11 | 36% | −$11.81 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
41.0%
The 95th percentile of the worst drawdown when the same 54 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 20.0% to 41.0%; the tick is what actually happened, 29.5%. Order luck alone moves it this much.
All 54 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 14 Mar 2024 73,072.40 | 15 Mar 2024 67,884.30 | 1 | −$0.71 |
| long | 14 Mar 2024 73,072.40 | 15 Mar 2024 67,884.30 | 1 | −$6.39 |
| long | 26 Mar 2024 69,880.00 | 2 Apr 2024 64,918.50 | 7 | −$0.66 |
| long | 26 Mar 2024 69,880.00 | 2 Apr 2024 64,918.50 | 7 | −$5.94 |
| short | 3 Apr 2024 65,464.00 | 8 Apr 2024 70,635.60 | 5 | −$3.41 |
| short | 3 Apr 2024 65,464.00 | 8 Apr 2024 70,635.60 | 5 | −$3.41 |
| long | 6 May 2024 64,012.00 | 20 May 2024 69,709.10 | 14 | $0.71 |
| long | 6 May 2024 64,012.00 | 22 May 2024 68,874.50 | 16 | $5.43 |
| short | 5 Jul 2024 57,050.00 | 11 Jul 2024 57,725.80 | 6 | −$1.01 |
| short | 25 Jul 2024 65,376.00 | 3 Aug 2024 60,015.20 | 9 | $3.47 |
| short | 25 Jul 2024 65,376.00 | 4 Aug 2024 60,698.00 | 10 | $3.03 |
| long | 11 Sep 2024 57,636.00 | 19 Sep 2024 62,765.60 | 8 | $0.81 |
| long | 11 Sep 2024 57,636.00 | 26 Sep 2024 65,474.50 | 15 | $11.15 |
| long | 30 Oct 2024 72,736.40 | 3 Nov 2024 67,572.10 | 4 | −$0.73 |
| long | 30 Oct 2024 72,736.40 | 3 Nov 2024 67,572.10 | 4 | −$6.59 |
| long | 7 Nov 2024 75,572.00 | 11 Nov 2024 82,297.90 | 4 | $0.85 |
| long | 7 Nov 2024 75,572.00 | 11 Nov 2024 85,849.80 | 4 | $11.72 |
| short | 19 Dec 2024 100,204.00 | 30 Dec 2024 91,987.30 | 11 | $4.44 |
| short | 19 Dec 2024 100,204.00 | 31 Dec 2024 92,792.10 | 12 | $4.01 |
| long | 15 Jan 2025 96,560.90 | 17 Jan 2025 105,155.00 | 2 | $1.04 |
| long | 15 Jan 2025 96,560.90 | 18 Jan 2025 104,077.00 | 3 | $8.18 |
| long | 3 Mar 2025 94,270.00 | 4 Mar 2025 86,221.20 | 1 | −$1.08 |
| long | 3 Mar 2025 94,270.00 | 4 Mar 2025 86,221.20 | 1 | −$9.68 |
| short | 29 Mar 2025 84,424.40 | 6 Apr 2025 77,501.60 | 8 | $4.72 |
| short | 29 Mar 2025 84,424.40 | 7 Apr 2025 78,430.00 | 9 | $4.09 |
| long | 9 May 2025 103,262.00 | 25 May 2025 107,762.00 | 16 | $5.41 |
| long | 9 Jun 2025 105,734.00 | 22 Jun 2025 98,226.90 | 13 | −$0.92 |
| long | 9 Jun 2025 105,734.00 | 22 Jun 2025 98,226.90 | 13 | −$8.27 |
| long | 25 Jun 2025 106,083.00 | 10 Jul 2025 115,524.00 | 15 | $1.07 |
| long | 25 Jun 2025 106,083.00 | 14 Jul 2025 120,510.00 | 19 | $14.72 |
| long | 8 Aug 2025 117,472.00 | 26 Aug 2025 109,132.00 | 18 | −$0.97 |
| long | 8 Aug 2025 117,472.00 | 26 Aug 2025 109,132.00 | 18 | −$8.69 |
| long | 1 Oct 2025 114,049.00 | 5 Oct 2025 124,199.00 | 4 | $1.12 |
| long | 1 Oct 2025 114,049.00 | 8 Oct 2025 121,333.00 | 7 | $7.27 |
| short | 10 Oct 2025 121,662.00 | 11 Oct 2025 112,774.00 | 1 | $9.85 |
| long | 21 Oct 2025 110,532.00 | 4 Nov 2025 102,684.00 | 14 | −$1.03 |
| long | 21 Oct 2025 110,532.00 | 4 Nov 2025 102,684.00 | 14 | −$9.24 |
| long | 10 Nov 2025 104,723.00 | 14 Nov 2025 97,287.60 | 4 | −$0.95 |
| long | 10 Nov 2025 104,723.00 | 14 Nov 2025 97,287.60 | 4 | −$8.59 |
| long | 25 Nov 2025 88,300.00 | 13 Jan 2026 96,158.70 | 49 | $1.11 |
| long | 25 Nov 2025 88,300.00 | 14 Jan 2026 95,414.00 | 50 | $9.05 |
| short | 24 Feb 2026 64,656.00 | 25 Feb 2026 69,763.80 | 1 | −$5.33 |
| short | 24 Feb 2026 64,656.00 | 25 Feb 2026 69,763.80 | 1 | −$5.33 |
| long | 27 Feb 2026 67,485.20 | 4 Mar 2026 73,491.40 | 5 | $1.11 |
| long | 27 Feb 2026 67,485.20 | 5 Mar 2026 72,666.80 | 6 | $8.59 |
| short | 20 Mar 2026 69,930.00 | 14 Apr 2026 75,454.50 | 25 | −$5.29 |
| short | 20 Mar 2026 69,930.00 | 14 Apr 2026 75,454.50 | 25 | −$5.29 |
| long | 26 May 2026 77,322.00 | 1 Jun 2026 71,832.10 | 6 | −$0.88 |
| long | 26 May 2026 77,322.00 | 1 Jun 2026 71,832.10 | 6 | −$7.89 |
| long | 2 Jul 2026 60,024.00 | 14 Jul 2026 62,334.50 | 12 | $4.41 |
| short | 25 Jul 2026 64,140.00 | 19 Aug 2026 69,207.10 | 25 | −$4.70 |
| short | 25 Jul 2026 64,140.00 | 19 Aug 2026 69,207.10 | 25 | −$4.70 |
| short | 29 Aug 2026 77,845.90 | 21 Sep 2026 83,995.70 | 23 | −$4.33 |
| short | 29 Aug 2026 77,845.90 | 21 Sep 2026 83,995.70 | 23 | −$4.33 |
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 |
|---|---|---|---|---|---|
| Kahlman HullMA - WT Cross Strategy this page | — | v5 strategy | +1.0% | 54 | 33.3% |
| Stoch-RSI 4h-1h-15min by MoonFlag | ema rsi sma rma stoch | v4 strategy | No trades on this market | ||
| DRSI DMA Scalping Strategy No Repaint by allenlk | sma wma ema rsi | v4 strategy | −99.5% | 44 | 137.7% |
| High-Low Channel Multi averages Crypto Swing strategy by exlux99 | sma ema wma rma vwma | v4 strategy | No trades on this market | ||
| Bear & Bull Zone Signal Strategy by Solutions1978 | rsi ema stoch sma vwma | v4 strategy | No trades on this market | ||
| EMA bands + leledc + bollinger bands trend following strategy v2 by readysetliqd | ema sma rsi rma wma | v5 strategy | +7.8% | 38 | 32.0% |
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.
- 42 settings use the untyped input() (line 7, 8, 14, 17, 24, 25, 31, 34, 41, 44, 45, 46, 49, 50, 53, 54, 60, 175, 177, 178, 206, 207, 233, 236, 237, 276, 277, 306, 307, 314, 315, 316, 317, 318, 338, 340, 341, 342, 343, 345, 349, 374). 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 54 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 7: input() → input.bool()
- Line 8: input() → input.bool()
- Line 14: input() → input.bool()
- Line 17: input() → input.bool()
- Line 24: input() → input.bool()
- Line 25: input() → input.bool()
36 more edits
- Line 31: input() → input.bool()
- Line 34: input() → input.bool()
- Line 41: input() → input.bool()
- Line 44: input() → input.bool()
- Line 45: input() → input.bool()
- Line 46: input() → input.bool()
- Line 49: input() → input.bool()
- Line 50: input() → input.bool()
- Line 53: input() → input.bool()
- Line 54: input() → input.bool()
- Line 60: input() → input.bool()
- Line 175: input() → input.bool()
- Line 177: input() → input.int()
- Line 178: input() → input.int()
- Line 206: input() → input.int()
- Line 207: input() → input.int()
- Line 233: input() → input.bool()
- Line 236: input() → input.int()
- Line 237: input() → input.int()
- Line 276: input() → input.bool()
- Line 277: input() → input.bool()
- Line 306: input() → input.bool()
- Line 307: input() → input.bool()
- Line 314: input() → input.bool()
- Line 315: input() → input.bool()
- Line 316: input() → input.int()
- Line 317: input() → input.int()
- Line 318: input() → input.int()
- Line 338: input() → input.bool()
- Line 340: input() → input.string()
- Line 341: input() → input.string()
- Line 342: input() → input.string()
- Line 343: input() → input.string()
- Line 345: input() → input.bool()
- Line 349: input() → input.bool()
- Line 374: input() → input.bool()
⋯//Inputs-_1 = input(false, '|| LONG TP SETTINGS ||')+_1 = input.bool(false, '|| LONG TP SETTINGS ||')-long = input(true, 'Long On')+long = input.bool(true, 'Long On')LongprofitPercent = input.float(10, "TP1 Profit Percent", minval = 0, maxval = 100, step = 5, tooltip="Percentage of balance to be taken for take profit 1-2.")⋯takeprofit2Long = input.float(13.6, "Long Take Profit 2", minval = 0.1, step = 0.1, tooltip="Long take profit 2 percent setting. / Close TP2", inline=tp2L)/100-tp2OnOffL = input(true, 'On', inline=tp2L)+tp2OnOffL = input.bool(true, 'On', inline=tp2L)var tp3L = "tp3L"takeprofit3Long = input.float(13.6, "Long Take Profit 3", minval = 0.1, step = 0.1, tooltip="Long take profit 3 percent setting. / Close TP3", inline=tp3L)/100-tp3OnOffL = input(false, 'On', inline=tp3L)+tp3OnOffL = input.bool(false, 'On', inline=tp3L)src_long = input.string(title='Long TP1 Source', defval="hc2",⋯ tooltip="TP2 up or down control. Close process if selected 'source' is less than TP2")-_2 = input(false, '|| SHORT TP SETTINGS ||')+_2 = input.bool(false, '|| SHORT TP SETTINGS ||')-short = input(true, 'Short On')+short = input.bool(true, 'Short On')ShortprofitPercent = input.float(50, "TP1 Profit Percent", minval = 0, maxval = 100, step = 5, tooltip="Percentage of balance to be taken for take profit 1-2.")⋯takeprofit2Short = input.float(13.4, "Short Take Profit 2", minval = 0.1, step = 0.1, tooltip="Short take profit 2 percent setting. / Close TP3", inline=tp2S)/100-tp2OnOffS = input(true, 'On', inline=tp2S)+tp2OnOffS = input.bool(true, 'On', inline=tp2S)var tp3S = "tp3S"takeprofit3Short = input.float(13.9, "Short Take Profit 3", minval = 0.1, step = 0.1, tooltip="Short take profit 3 percent setting. / Close TP3", inline=tp3S)/100-tp3OnOffS = input(false, 'On', inline=tp3S)+tp3OnOffS = input.bool(false, 'On', inline=tp3S)src_short = input.string(title='Short TP1 Source', defval="lc2",⋯ tooltip="TP2 up or down control. Close process if selected 'source' is greater than TP2")-_3 = input(false, '|| STOP LOSS SETTINGS ||')+_3 = input.bool(false, '|| STOP LOSS SETTINGS ||')stoplossLong = input.float(7.1, "Long", minval = 0.1, step = 0.1, tooltip="Stop loss percent(Red line)")/100stoplossShort = input.float(7.9, "Short", minval = 0.1, step = 0.1)/100-_4 = input(false, '|| TRAILING STOP SETTINGS ||')+_4 = input.bool(false, '|| TRAILING STOP SETTINGS ||')-trailingSLOnOff = input(true, 'Long Trailing SL On', tooltip="Trailing stop loss mode.")+trailingSLOnOff = input.bool(true, 'Long Trailing SL On', tooltip="Trailing stop loss mode.")-trailingStopChangeL = input(true, 'Change Line', tooltip="On: If price is greater than TP1. Off: If price is greater than Long Position Check.")+trailingStopChangeL = input.bool(true, 'Change Line', tooltip="On: If price is greater than TP1. Off: If price is greater than Long Position Check.")trailingPercent = input.float(3.6, "Long", minval = 0.1, step = 0.1, tooltip="Trailing stop loss percent. Note: Activated if greater than TP1. Otherwise, the stop level is the value on a bottom line.(Yellow dot line)")/100-trailingSLOnOff2 = input(false, 'Short Trailing SL On', tooltip="Trailing stop loss mode.")+trailingSLOnOff2 = input.bool(false, 'Short Trailing SL On', tooltip="Trailing stop loss mode.")-trailingStopChangeS = input(true, 'Change Line', tooltip="On: If price is greater than TP1. Off: If price is greater than Short Position Check.")+trailingStopChangeS = input.bool(true, 'Change Line', tooltip="On: If price is greater than TP1. Off: If price is greater than Short Position Check.")trailingPercent2 = input.float(3.4, "Short", minval = 0.1, step = 0.1, tooltip="Trailing stop loss percent. Note: Activated if greater than TP1. Otherwise, the stop level is the value on a bottom line.(Yellow dot line)")/100-_5 = input(false, '|| POSITION CHECK SETTINGS ||')+_5 = input.bool(false, '|| POSITION CHECK SETTINGS ||')-LongpositionCheckOnOff = input(true, 'Long Position Check On',+LongpositionCheckOnOff = input.bool(true, 'Long Position Check On', tooltip="Long Position check mode. Depends on TP1 percentage. It works as a '%X' / 'Senstive Value'.")⋯LongpositionCheck = input.float(1.7, "Senstive", minval = 1, step = 0.01)-ShortpositionCheckOnOff = input(true, 'Short Position Check On',+ShortpositionCheckOnOff = input.bool(true, 'Short Position Check On', tooltip="Short Position check mode. It works as a '%X' / 'Senstive Value'.")⋯// WT Cross Setup-_6 = input(false, '|| WT CROSS SETTINGS ||')+_6 = input.bool(false, '|| WT CROSS SETTINGS ||')var wtlong = "WT LONG"-n1L = input(6, 'Channel Length')+n1L = input.int(6, 'Channel Length')-n2L = input(23, 'Average Length')+n2L = input.int(23, 'Average Length')apL = input.string(title='Source', defval='hlc3', ⋯var wtshort = "WT SHORT"-n1S = input(8, 'Channel Length')+n1S = input.int(8, 'Channel Length')-n2S = input(19, 'Average Length')+n2S = input.int(19, 'Average Length')apS = input.string(title='Source', defval='hlc3', ⋯// Hull Kahlman Setup-_7 = input(false, '|| HULLMA SETTINGS ||')+_7 = input.bool(false, '|| HULLMA SETTINGS ||')hull_source = input.string(title='Source', defval='hl2', options=["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"])-lengthhull = input(24, 'Lookback')+lengthhull = input.int(24, 'Lookback')-gain = input(10000, 'Gain')+gain = input.int(10000, 'Gain')float hull_src = switch hull_source⋯//Stoch RSI Settings-_8 = input(false, '|| STOCH RSI SETTINGS ||')+_8 = input.bool(false, '|| STOCH RSI SETTINGS ||')-rsistochOnOff = input(true, 'Stoch RSI', tooltip="Stoch RSI On/Off")+rsistochOnOff = input.bool(true, 'Stoch RSI', tooltip="Stoch RSI On/Off")smoothK = input.int(2, "K", minval=1)⋯//Vol Setup-_15 = input(false, '|| VOLUME SETTINGS ||')+_15 = input.bool(false, '|| VOLUME SETTINGS ||')-volumeonoff = input(true, 'On/Off')+volumeonoff = input.bool(true, 'On/Off')volume_f = input.float(0.6, title="Mult.", minval = 0, step = 0.1)⋯volEntry = volumeonoff ? volume > vol:volume-_16 = input(false, '|| ADX SETTINGS ||')+_16 = input.bool(false, '|| ADX SETTINGS ||')-adxon = input(false, 'On')+adxon = input.bool(false, 'On')-adxlen = input(14, title="ADX Smoothing")+adxlen = input.int(14, title="ADX Smoothing")-dilen = input(14, title="DI Length")+dilen = input.int(14, title="DI Length")-adxBuyLevel = input(20, title="Buy Level")+adxBuyLevel = input.int(20, title="Buy Level")dirmov(len) =>⋯// Wunderbit Settings-_9 = input(false, '|| WUNDERBIT SETTINGS ||')+_9 = input.bool(false, '|| WUNDERBIT SETTINGS ||')var wunder = "Wunderbit Comments"-longentryComment = input("ENTER-LONG", title = "Long Entry Comment", group=wunder)+longentryComment = input.string("ENTER-LONG", title = "Long Entry Comment", group=wunder)-longexitComment = input("EXIT-LONG", title = "Long Exit Comment", group=wunder)+longexitComment = input.string("EXIT-LONG", title = "Long Exit Comment", group=wunder)-shortentryComment = input("ENTER-SHORT", title = "Short Entry Comment", group=wunder)+shortentryComment = input.string("ENTER-SHORT", title = "Short Entry Comment", group=wunder)-shortexitComment = input("EXIT-SHORT", title = "Short Exit Comment", group=wunder)+shortexitComment = input.string("EXIT-SHORT", title = "Short Exit Comment", group=wunder)// Date Setup-_10 = input(false, '|| DATE & DATE RANGE SETTINGS ||')+_10 = input.bool(false, '|| DATE & DATE RANGE SETTINGS ||')startDate = input.time(timestamp("1 Jan 2020 00:00 +0000"), "Start Date")⋯var rangeL = "LONG"-sessionOnOff = input(true, 'Long/Time Range & Weekdays On/Off', tooltip="Start Date and End Date not inclueded", group=rangeL)+sessionOnOff = input.bool(true, 'Long/Time Range & Weekdays On/Off', tooltip="Start Date and End Date not inclueded", group=rangeL)timeSession = input.session("0000-0000", 'Time Range', group=rangeL)⋯var rangeS = "SHORT"-sessionOnOff2 = input(false, 'Short/Time Range & Weekdays On/Off', tooltip="Start Date and End Date not inclueded", group=rangeS)+sessionOnOff2 = input.bool(false, 'Short/Time Range & Weekdays On/Off', tooltip="Start Date and End Date not inclueded", group=rangeS)timeSession2 = input.session("0300-0300", 'Time Range', group=rangeS)⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 54 before, 23 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// Kahlman HullMA / WT Cross Strategy ©author [pigsq]-//@version=5+//@version=6strategy("Kahlman HullMA / WT Cross Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 103 ms | With a workaround 1,000 bars in 304 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/// WT CROSS @author [LazyBear]// Kahlman HullMA / WT Cross Strategy ©author [pigsq]//@version=5strategy("Kahlman HullMA / WT Cross Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100)//Inputs_1 = input(false, '|| LONG TP SETTINGS ||')long = input(true, 'Long On')LongprofitPercent = input.float(10, "TP1 Profit Percent", minval = 0, maxval = 100, step = 5, tooltip="Percentage of balance to be taken for take profit 1-2.")LongprofitPercent2 = input.float(15, "TP2 Profit Percent", minval = 0, maxval = 100, step = 5, tooltip="Percentage of balance to be taken for take profit 1-2.")takeprofitLong = input.float(8.9, "Long Take Profit 1", minval = 0.1, step = 0.1, tooltip="Long take profit 1 percent setting")/100var tp2L = "tp2L"takeprofit2Long = input.float(13.6, "Long Take Profit 2", minval = 0.1, step = 0.1, tooltip="Long take profit 2 percent setting. / Close TP2", inline=tp2L)/100tp2OnOffL = input(true, 'On', inline=tp2L)var tp3L = "tp3L"takeprofit3Long = input.float(13.6, "Long Take Profit 3", minval = 0.1, step = 0.1, tooltip="Long take profit 3 percent setting. / Close TP3", inline=tp3L)/100tp3OnOffL = input(false, 'On', inline=tp3L)src_long = input.string(title='Long TP1 Source', defval="hc2", options=["hc2", "co2", "hco3", "hlo3", "ho2", "lo2", "open", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high"], tooltip="TP1 up or down control. Close process if selected 'source' is less than TP1")src_long2 = input.string(title='Long TP2 Source', defval="hc2", options=["hc2", "co2", "hco3", "hlo3", "ho2", "lo2", "open", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high"], tooltip="TP2 up or down control. Close process if selected 'source' is less than TP2")_2 = input(false, '|| SHORT TP SETTINGS ||')short = input(true, 'Short On')ShortprofitPercent = input.float(50, "TP1 Profit Percent", minval = 0, maxval = 100, step = 5, tooltip="Percentage of balance to be taken for take profit 1-2.")ShortprofitPercent2 = input.float(70, "TP2 Profit Percent", minval = 0, maxval = 100, step = 5, tooltip="Percentage of balance to be taken for take profit 1-2.")takeprofitShort = input.float(8.2, "Short Take Profit 1", minval = 0.1, step = 0.1, tooltip="Short take profit 1 percent setting")/100var tp2S = "tp2S"takeprofit2Short = input.float(13.4, "Short Take Profit 2", minval = 0.1, step = 0.1, tooltip="Short take profit 2 percent setting. / Close TP3", inline=tp2S)/100tp2OnOffS = input(true, 'On', inline=tp2S)var tp3S = "tp3S"takeprofit3Short = input.float(13.9, "Short Take Profit 3", minval = 0.1, step = 0.1, tooltip="Short take profit 3 percent setting. / Close TP3", inline=tp3S)/100tp3OnOffS = input(false, 'On', inline=tp3S)src_short = input.string(title='Short TP1 Source', defval="lc2", options=["lc2", "lco3", "hco3", "hc2", "co2", "hlo3", "lo2", "ho2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"], tooltip="TP1 up or down control. Close process if selected 'source' is greater than TP1")src_short2 = input.string(title='Short TP2 Source', defval="lco3", options=["lc2", "lco3", "hco3", "hc2", "co2", "hlo3", "lo2", "ho2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"], tooltip="TP2 up or down control. Close process if selected 'source' is greater than TP2")_3 = input(false, '|| STOP LOSS SETTINGS ||')stoplossLong = input.float(7.1, "Long", minval = 0.1, step = 0.1, tooltip="Stop loss percent(Red line)")/100stoplossShort = input.float(7.9, "Short", minval = 0.1, step = 0.1)/100_4 = input(false, '|| TRAILING STOP SETTINGS ||')trailingSLOnOff = input(true, 'Long Trailing SL On', tooltip="Trailing stop loss mode.")trailingStopChangeL = input(true, 'Change Line', tooltip="On: If price is greater than TP1. Off: If price is greater than Long Position Check.")trailingPercent = input.float(3.6, "Long", minval = 0.1, step = 0.1, tooltip="Trailing stop loss percent. Note: Activated if greater than TP1. Otherwise, the stop level is the value on a bottom line.(Yellow dot line)")/100trailingSLOnOff2 = input(false, 'Short Trailing SL On', tooltip="Trailing stop loss mode.")trailingStopChangeS = input(true, 'Change Line', tooltip="On: If price is greater than TP1. Off: If price is greater than Short Position Check.")trailingPercent2 = input.float(3.4, "Short", minval = 0.1, step = 0.1, tooltip="Trailing stop loss percent. Note: Activated if greater than TP1. Otherwise, the stop level is the value on a bottom line.(Yellow dot line)")/100_5 = input(false, '|| POSITION CHECK SETTINGS ||')LongpositionCheckOnOff = input(true, 'Long Position Check On', tooltip="Long Position check mode. Depends on TP1 percentage. It works as a '%X' / 'Senstive Value'.")src_LongpositionCheck = input.string(title='Source', defval="co2", options=["hco3", "lco3", "hc2", "lc2", "co2", "ho2", "lo2", "hlo3", "close", "open", "hl2", "hlc3", "ohlc4", "hlcc4", "low", "high"], tooltip="Long check senstive up or down control. Close process if selected 'source' is less than Position Check Line(Yellow solid line)")LongpositionCheck = input.float(1.7, "Senstive", minval = 1, step = 0.01)ShortpositionCheckOnOff = input(true, 'Short Position Check On', tooltip="Short Position check mode. It works as a '%X' / 'Senstive Value'.")src_ShortpositionCheck = input.string(title='Source', defval="low", options=["lco3", "hco3", "lc2", "hc2", "co2", "lo2", "ho2", "hlo3", "close", "open", "hl2", "hlc3", "ohlc4", "hlcc4", "low", "high"], tooltip="Short check senstive up or down control. Close process if selected 'source' is greater than Position Check Line(Yellow solid line)")ShortpositionCheck = input.float(1.4, "Senstive", minval = 1, step = 0.01)//Long TP1 sourcefloat source_long = switch src_long "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "ho2" => (open + high)/2 "lo2" => (low + open)/2 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "open" => open "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high//Long TP2 sourcefloat source_long2 = switch src_long2 "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "co2" => (open + close)/2 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "ho2" => (high + open)/2 "open" => open "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high//Short TP1 sourcefloat source_short = switch src_short "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "ho2" => (high + open)/2 "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => open//Short TP2 sourcefloat source_short2 = switch src_short2 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "ho2" => (high + open)/2 "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => open//Long position check sourcefloat source_CheckLong = switch src_LongpositionCheck "hco3" => (high + close + open)/3 "lco3" => (low + close + open)/3 "hc2" => (high + close)/2 "lc2" => (low + close)/2 "hlo3" => (open + high + low)/3 "co2" => (open + close)/2 "ho2" => (open + high)/2 "lo2" => (low + open)/2 "close" => close "hl2" => hl2 "hlc3" => hlc3 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => open//Short position check sourcefloat source_CheckShort = switch src_ShortpositionCheck "lco3" => (low + close + open)/3 "hco3" => (high + close + open)/3 "lc2" => (low + close)/2 "hc2" => (high + close)/2 "hlo3" => (open + high + low)/3 "co2" => (open + close)/2 "lo2" => (open + low)/2 "ho2" => (high + open)/2 "close" => close "hl2" => hl2 "hlc3" => hlc3 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "high" => high "open" => open "low" => low// WT Cross Setup_6 = input(false, '|| WT CROSS SETTINGS ||')var wtlong = "WT LONG"n1L = input(6, 'Channel Length')n2L = input(23, 'Average Length')apL = input.string(title='Source', defval='hlc3', options=["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"])float apL_src = switch apL "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => open esaL = ta.ema(apL_src, n1L)rL = ta.ema(math.abs(apL_src - esaL), n1L)ciL = (apL_src - esaL) / (0.015 * rL)tciL = ta.ema(ciL, n2L)wt1L = tciLwt2L = ta.sma(wt1L, 4)// WT SHORTvar wtshort = "WT SHORT"n1S = input(8, 'Channel Length')n2S = input(19, 'Average Length')apS = input.string(title='Source', defval='hlc3', options=["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"])float apS_src = switch apS "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => openesaS = ta.ema(apS_src, n1S)rS = ta.ema(math.abs(apS_src - esaS), n1S)ciS = (apS_src - esaS) / (0.015 * rS)tciS = ta.ema(ciS, n2S)wt1S = tciSwt2S = ta.sma(wt1S, 4)// Hull Kahlman Setup_7 = input(false, '|| HULLMA SETTINGS ||')hull_source = input.string(title='Source', defval='hl2', options=["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"])lengthhull = input(24, 'Lookback')gain = input(10000, 'Gain')float hull_src = switch hull_source "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => openhma(_hull_src, _lengthhull) => ta.wma((2 * ta.wma(_hull_src, _lengthhull / 2)) - ta.wma(_hull_src, _lengthhull), math.round(math.sqrt(_lengthhull)))hma3(_hull_src, _lengthhull) => p = lengthhull / 2 ta.wma(ta.wma(close, p / 3) * 3 - ta.wma(close, p / 2) - ta.wma(close, p), p)kahlman(x, g) => kf = 0.0 dk = x - nz(kf[1], x) smooth = nz(kf[1], x) + dk * math.sqrt(g / 10000 * 2) velo = 0.0 velo := nz(velo[1], 0) + g / 10000 * dk kf := smooth + velo kfa = kahlman(hma(hull_src, lengthhull), gain)b = kahlman(hma3(hull_src, lengthhull), gain)c = b > a ? color.lime : color.redcrossdn = a > b and a[1] < b[1]crossup = b > a and b[1] < a[1]p1hma = plot(a, color=color.new(c, 75), linewidth=1, title='Long Plot')p2hma = plot(b, color=color.new(c, 75), linewidth=1, title='Short Plot')fill(p1hma, p2hma, color=color.new(c, 75), title='Fill')//Stoch RSI Settings_8 = input(false, '|| STOCH RSI SETTINGS ||')rsistochOnOff = input(true, 'Stoch RSI', tooltip="Stoch RSI On/Off")smoothK = input.int(2, "K", minval=1)smoothD = input.int(3, "D", minval=1)lengthRSI = input.int(13, "RSI Length", minval=1)lengthStoch = input.int(13, "Stochastic Length", minval=1)src = input.string(title='RSI Source', defval='hl2', options=["hc2", "hco3", "lc2", "lco3", "co2", "hlo3", "lo2", "close", "hlc3", "hl2", "ohlc4", "hlcc4", "low", "high", "open"])float src_src = switch src "hc2" => (high + close)/2 "hco3" => (high + close + open)/3 "lc2" => (low + close)/2 "lco3" => (low + close + open)/3 "co2" => (open + close)/2 "hlo3" => (open + high + low)/3 "lo2" => (open + low)/2 "close" => close "hlc3" => hlc3 "hl2" => hl2 "ohlc4" => ohlc4 "hlcc4" => hlcc4 "low" => low "high" => high "open" => openrsi1 = ta.rsi(src_src, lengthRSI)k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)d = ta.sma(k, smoothD)LStoch = rsistochOnOff ? k > d:closeSStoch = rsistochOnOff ? k < d:close//Vol Setup_15 = input(false, '|| VOLUME SETTINGS ||')volumeonoff = input(true, 'On/Off')volume_f = input.float(0.6, title="Mult.", minval = 0, step = 0.1)sma_length = input.int(3, title="Sma volume lenght", minval = 1)vwma_length = input.int(3, title="Vwma volume lenght", minval = 1)wma_length = input.int(4, title="Wma volume lenght", minval = 1)vol = ((ta.sma(volume, sma_length) + ta.vwma(volume, vwma_length) + ta.wma(volume, wma_length)) / 3) * volume_fvolEntry = volumeonoff ? volume > vol:volume_16 = input(false, '|| ADX SETTINGS ||')adxon = input(false, 'On')adxlen = input(14, title="ADX Smoothing")dilen = input(14, title="DI Length")adxBuyLevel = input(20, title="Buy Level")dirmov(len) => up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) truerange = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(plusDM, len) / truerange) minus = fixnan(100 * ta.rma(minusDM, len) / truerange) [plus, minus]adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)sig = adx(dilen, adxlen)ADXEntry = if adxon sig > adxBuyLevelelse sig < 100// Wunderbit Settings_9 = input(false, '|| WUNDERBIT SETTINGS ||')var wunder = "Wunderbit Comments"longentryComment = input("ENTER-LONG", title = "Long Entry Comment", group=wunder)longexitComment = input("EXIT-LONG", title = "Long Exit Comment", group=wunder)shortentryComment = input("ENTER-SHORT", title = "Short Entry Comment", group=wunder)shortexitComment = input("EXIT-SHORT", title = "Short Exit Comment", group=wunder)// Date Setup_10 = input(false, '|| DATE & DATE RANGE SETTINGS ||')startDate = input.time(timestamp("1 Jan 2020 00:00 +0000"), "Start Date")endDate = input.time(timestamp("1 Jan 9999 03:00 +0000"), "End Date")var rangeL = "LONG"sessionOnOff = input(true, 'Long/Time Range & Weekdays On/Off', tooltip="Start Date and End Date not inclueded", group=rangeL)timeSession = input.session("0000-0000", 'Time Range', group=rangeL)d_monday = input.bool(title="Monday", defval=true, inline="D1", group=rangeL)d_tuesday = input.bool(title="Tuesday", defval=true, inline="D1", group=rangeL)d_wednesday = input.bool(title="Wednesday", defval=true, inline="D1", group=rangeL)d_thursday = input.bool(title="Thursday", defval=true, inline="D2", group=rangeL)d_friday = input.bool(title="Friday", defval=true, inline="D2", group=rangeL)d_saturday = input.bool(title="Saturday", defval=false, inline="D2", group=rangeL)d_sunday = input.bool(title="Sunday", defval=true, tooltip="Trade days?", inline="D2", group=rangeL)days = d_sunday ? "1" : ""days := days + (d_monday ? "2" : "")days := days + (d_tuesday ? "3" : "")days := days + (d_wednesday ? "4" : "")days := days + (d_thursday ? "5" : "")days := days + (d_friday ? "6" : "")days := days + (d_saturday ? "7" : "")strategyTime = time >= startDate and time <= endDate ? true : falseinSession(session) => if sessionOnOff na(time(timeframe.period, session + ":" + days)) == false and strategyTime else strategyTime // For Shortvar rangeS = "SHORT"sessionOnOff2 = input(false, 'Short/Time Range & Weekdays On/Off', tooltip="Start Date and End Date not inclueded", group=rangeS)timeSession2 = input.session("0300-0300", 'Time Range', group=rangeS)d_monday2 = input.bool(title="Monday", defval=true, inline="D3", group=rangeS)d_tuesday2 = input.bool(title="Tuesday", defval=true, inline="D3", group=rangeS)d_wednesday2 = input.bool(title="Wednesday", defval=true, inline="D3", group=rangeS)d_thursday2 = input.bool(title="Thursday", defval=true, inline="D4", group=rangeS)d_friday2 = input.bool(title="Friday", defval=true, inline="D4", group=rangeS)d_saturday2 = input.bool(title="Saturday", defval=true, inline="D4", group=rangeS)d_sunday2 = input.bool(title="Sunday", defval=true, tooltip="Trade days?", inline="D4", group=rangeS)days2 = d_sunday2 ? "1" : ""days2 := days2 + (d_monday2 ? "2" : "")days2 := days2 + (d_tuesday2 ? "3" : "")days2 := days2 + (d_wednesday2 ? "4" : "")days2 := days2 + (d_thursday2 ? "5" : "")days2 := days2 + (d_friday2 ? "6" : "")days2 := days2 + (d_saturday2 ? "7" : "")inSession2(session2) => if sessionOnOff2 na(time(timeframe.period, session2 + ":" + days2)) == false and time >= startDate and time <= endDate else time >= startDate and time <= endDate ? true : false// SL-TP SetupslongConditionDirection = strategy.position_size >= 0shortConditionDirection = strategy.position_size <= 0// Long Line SetupexitSL = if longConditionDirection strategy.position_avg_price * (1 - stoplossLong)else strategy.position_avg_price * (1 + stoplossShort)exitTP = if longConditionDirection strategy.position_avg_price * (1 + takeprofitLong)else strategy.position_avg_price * (1 - takeprofitShort)exitTP2 = if longConditionDirection strategy.position_avg_price * (1 + takeprofit2Long)else strategy.position_avg_price * (1 - takeprofit2Short)exitTP3 = if longConditionDirection strategy.position_avg_price * (1 + takeprofit3Long)else strategy.position_avg_price * (1 - takeprofit3Short) positionCheckLong = if LongpositionCheckOnOff longConditionDirection ? strategy.position_avg_price * (1 + takeprofitLong/LongpositionCheck):napositionCheckShort = if ShortpositionCheckOnOff shortConditionDirection ? strategy.position_avg_price * (1 - takeprofitShort/ShortpositionCheck):na // Long-Short Condition SetuplongCondition = crossup and ta.crossover(wt1L,wt2L) and LStoch or crossup and ta.crossover(wt1L[1],wt2L[1]) and LStoch or crossup and ta.crossover(wt1L[2],wt2L) and LStochshortCondition = crossdn and ta.crossunder(wt1S,wt2S) and SStoch// Trailing Long Stop SetuptrailingStopChangeL1 = trailingStopChangeL ? high >= exitTP or high[1] >= exitTP: high >= positionCheckLong or high[1] >= positionCheckLongpriceStopL = 0.0priceStopL := if longConditionDirection and trailingStopChangeL1 and trailingSLOnOff stopMeasure = close * (1 - trailingPercent) math.max(stopMeasure, priceStopL[1])else if longConditionDirection exitSL// Trailing Short Stop SetuptrailingStopChangeS1 = trailingStopChangeS ? low <= exitTP or low[1] <= exitTP: low <= positionCheckShort or low[1] <= positionCheckShortpriceStopS = 0.0priceStopS := if shortConditionDirection and trailingStopChangeS1 and trailingSLOnOff2 stopMeasure = close * (1 + trailingPercent2) math.min(stopMeasure, priceStopS[1])else if shortConditionDirection exitSL// Position Check ControlpositionCheckLong2 = high >= positionCheckLong and ta.crossunder(wt1L,wt2L) and source_CheckLong < positionCheckLong or high >= positionCheckLong and ta.crossunder(wt1S,wt2S) and source_CheckLong < positionCheckLong or high >= positionCheckLong and a > b and source_CheckLong < positionCheckLong and wt1L < wt2L and not volEntry or high >= positionCheckLong and a > b and source_CheckLong < positionCheckLong and wt1S < wt2S and not volEntry or high >= positionCheckLong and crossdn and source_CheckLong < positionCheckLongpositionCheckShort2 = low <= positionCheckShort and ta.crossover(wt1S,wt2S) and source_CheckShort > positionCheckShort or low <= positionCheckShort and ta.crossover(wt1L,wt2L) and source_CheckShort > positionCheckShort or low <= positionCheckShort and a < b and source_CheckShort > positionCheckShort and wt1S > wt2S and not volEntry or low <= positionCheckShort and a < b and source_CheckShort > positionCheckShort and wt1L > wt2L and not volEntry or low <= positionCheckShort and crossup and source_CheckShort > positionCheckShort// TP's ControllongTStop = high >= exitTP and source_long <= exitTP or high >= exitTP2 and source_long2 <= exitTP2 or high >= exitTP2 and a > bshortTStop = low <= exitTP and source_short >= exitTP or low <= exitTP2 and source_short2 >= exitTP2 or low <= exitTP2 and a < b// Long-Short Condition CloselongConditionExit = if high <= strategy.position_avg_price or high >= positionCheckLong shortCondition or positionCheckLong2shortConditionExit = if low >= strategy.position_avg_price or low <= positionCheckShort longCondition or positionCheckShort2if strategyTime if longConditionDirection and longCondition and long and volEntry and ADXEntry if inSession(sessionOnOff ? timeSession:na) strategy.entry("LONG", strategy.long, comment=longentryComment) strategy.exit("LONG", stop=priceStopL, qty_percent=tp2OnOffL ? LongprofitPercent:100, limit=exitTP, comment=longexitComment) if tp2OnOffL strategy.exit("LONG1", stop=priceStopL, qty_percent=tp3OnOffL ? LongprofitPercent2:100, limit=exitTP2, comment=longexitComment) if tp3OnOffL strategy.exit("LONG2", stop=priceStopL, qty_percent=100, limit=exitTP3, comment=longexitComment) if longConditionExit or longTStop strategy.close("LONG", comment=longexitComment) if shortConditionDirection and shortCondition and short and volEntry and ADXEntry if inSession2(sessionOnOff2 ? timeSession2:na) strategy.entry("SHORT", strategy.short, comment=shortentryComment) strategy.exit("SHORT", stop=priceStopS, qty_percent=tp2OnOffS ? ShortprofitPercent:100, limit=exitTP, comment=shortexitComment) if tp2OnOffS strategy.exit("SHORT1", stop=priceStopS, qty_percent=tp3OnOffS ? ShortprofitPercent2:100, limit=exitTP2, comment=shortexitComment) if tp3OnOffS strategy.exit("SHORT2", stop=priceStopS, qty_percent=100, limit=exitTP3, comment=shortexitComment) if shortConditionExit or shortTStop strategy.close("SHORT", comment=shortexitComment)// SL-TP LinesLSTP2Lines = longConditionDirection ? tp2OnOffL ? exitTP2:na:shortConditionDirection ? tp2OnOffS ? exitTP2:na:naLSTP3Lines = longConditionDirection ? tp3OnOffL ? tp2OnOffL ? exitTP3:na:na:shortConditionDirection ? tp3OnOffS ? tp2OnOffS ? exitTP3:na:na:naplot(exitTP, title='Long/Short TP1', color=color.lime, style=plot.style_linebr, linewidth=1)plot(LSTP2Lines, title='Long/Short TP2', color=color.lime, style=plot.style_linebr, linewidth=1)plot(LSTP3Lines, title='Long/Short TP3', color=color.lime, style=plot.style_linebr, linewidth=1)// L/S Stop Loss Linesplot(exitSL, title='Long/Short SL', color=color.red, style=plot.style_linebr, linewidth=1)// Position Check LinesPositionCheckColors = LongpositionCheckOnOff and positionCheckLong ? color.yellow : ShortpositionCheckOnOff and positionCheckShort ? color.yellow:naPositionCheckLines = LongpositionCheckOnOff and longConditionDirection ? positionCheckLong : ShortpositionCheckOnOff and shortConditionDirection ? positionCheckShort:naplot(PositionCheckLines, title='Long/Short Position Check', color=PositionCheckColors, style=plot.style_linebr, linewidth=1)// Trailing Stop LinesTrailingStopLines = trailingSLOnOff ? longConditionDirection and trailingStopChangeL1 ? priceStopL:na:naTrailingStopLines2 = trailingSLOnOff2 ? shortConditionDirection and trailingStopChangeS1 ? priceStopS:na:naplot(TrailingStopLines, title='Long Trailing Stop', color=color.yellow, style=plot.style_circles, linewidth=1)plot(TrailingStopLines2, title='Short Trailing Stop', color=color.yellow, style=plot.style_circles, linewidth=1)// Date Range Background Color// bgcolor(sessionOnOff ? inSession(timeSession) ? color.rgb(91, 255, 0, 95):na:na, title="Long Time Range Bg Color")// bgcolor(sessionOnOff2 ? inSession2(timeSession2) ? color.rgb(91, 255, 0, 95):na:na, title="Short Time Range Bg Color")