Pine Script v4 · Strategy
Ehlers Bandpass Filter
A Pine Script v4 strategy built on Crossover (trigger, signal) and Crossunder (trigger, signal). It has 4 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 is one contract and pays no commission. 11 settings; defaults include Capital Settings Initial, Manual Position Size 100.3 and Leverage 1.
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 Ehlers Bandpass Filter repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 18 of 18 trades.
- How did Ehlers Bandpass Filter do on BTCUSDT 1D with default settings?
- −13.10%
- From 26 Jan 2024 to 21 Oct 2026, over 58 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Ehlers Bandpass Filter be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does Ehlers Bandpass Filter use a stop loss?
- Yes
- strategy.exit sets a stop on line 63, 74.
- Does Ehlers Bandpass Filter run in Zeal Terminal?
- Yes
- It compiles in 25 ms and runs 1,000 bars in 70 ms, in the browser.
BTCUSDT · 1D · default settings
- Signal
- Trigger
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −13.10%
- −$13,102.40
- Buy and hold
- +102.5%
- same period
- Closed trades
- 58
- 23 won · 34 lost
- Profitable
- 39.7%
- of closed trades
- Profit factor
- 0.75
- gross profit ÷ gross loss
- Max drawdown
- 20.81%
- −$22,534.20
One run with the author's default settings, $100,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.
-
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.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames floor → math.floor, security → request.security, asin → math.asin, cos → math.cos, sqrt → math.sqrt, sin → math.sin, abs → math.abs, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
DiffersTrades differ: 58 before, 78 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 8: input(type = input.string) → input.string()
- Line 9: input(type = input.float) → input.float()
- Line 10: input(type = input.float) → input.float()
- Line 12: floor → math.floor
- Line 13: floor → math.floor
22 more edits
- Line 19: input(type = input.float) → input.float()
- Line 20: input(type = input.float) → input.float()
- Line 28: input(type = input.source) → input.source()
- Line 29: input(type = input.resolution) → input.timeframe()
- Line 30: input(type = input.bool) → input.bool()
- Line 31: security → request.security
- Line 32: input(type = input.integer) → input.int()
- Line 33: input(type = input.float) → input.float()
- Line 34: asin → math.asin
- Line 37: cos → math.cos
- Line 38: cos → math.cos
- Line 39: sqrt → math.sqrt
- Line 40: cos → math.cos
- Line 40: sin → math.sin
- Line 40: cos → math.cos
- Line 41: cos → math.cos
- Line 41: sin → math.sin
- Line 41: cos → math.cos
- Line 48: abs → math.abs
- Line 48: abs → math.abs
- Line 58: crossover → ta.crossover
- Line 59: crossunder → ta.crossunder
⋯// © greenmask9, @cheatcountry-//@version=4+//@version=5strategy(title= "Ehlers Bandpass Filter", shorttitle = "Bandpass Filter", overlay=false)⋯//Capital Management-capitaltype = input(defval="Initial", title="Capital Settings", options=["Initial", "Growing","Manual"], type=input.string)+capitaltype = input.string(defval="Initial", title="Capital Settings", options=["Initial", "Growing","Manual"])-manualcapital = input(title="Manual Position Size", defval=100.3, type=input.float)+manualcapital = input.float(title="Manual Position Size", defval=100.3)-leverage = input(title="Leverage", defval=1, type=input.float)+leverage = input.float(title="Leverage", defval=1)capitalsystem(capitaltype) =>- v1 = floor(strategy.initial_capital/close) * leverage+ v1 = math.floor(strategy.initial_capital/close) * leverage- v2 = floor((strategy.initial_capital + strategy.netprofit)/close) * leverage+ v2 = math.floor((strategy.initial_capital + strategy.netprofit)/close) * leverage v3 = manualcapital⋯percentages = input(title="Percentage stop 🎯", defval=true)-targetpercentage = input(title="Profit (%)", type=input.float, minval=0.0, step=0.1, defval=1.3) * 0.01+targetpercentage = input.float(title="Profit (%)", minval=0.0, step=0.1, defval=1.3) * 0.01-stoppercentage = input(title="Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=0.6) * 0.01+stoppercentage = input.float(title="Stop Loss (%)", minval=0.0, step=0.1, defval=0.6) * 0.01longtp = strategy.position_avg_price * (1 + targetpercentage)⋯// Ehlers Bandpass Filter script may be freely distributed under the MIT license.-inp = input(title="Source", type=input.source, defval=close)+inp = input.source(title="Source", defval=close)-res = input(title="Resolution", type=input.resolution, defval="")+res = input.timeframe(title="Resolution", defval="")-rep = input(title="Allow Repainting?", type=input.bool, defval=false)+rep = input.bool(title="Allow Repainting?", defval=false)-src = security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]+src = request.security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]-length = input(title="Length", type=input.integer, defval=20, minval=1)+length = input.int(title="Length", defval=20, minval=1)-bw = input(title="Bandwidth", type=input.float, defval=0.3, minval=0.01, step = 0.01)+bw = input.float(title="Bandwidth", defval=0.3, minval=0.01, step = 0.01)-pi = 2 * asin(1)+pi = 2 * math.asin(1)twoPiPrd1 = 0.25 * bw * 2 * pi / lengthtwoPiPrd2 = 1.5 * bw * 2 * pi / length-beta = cos(2 * pi / length)+beta = math.cos(2 * pi / length)-gamma = 1.0 / cos(2 * pi * bw / length)+gamma = 1.0 / math.cos(2 * pi * bw / length)-alpha1 = gamma - sqrt((gamma * gamma) - 1)+alpha1 = gamma - math.sqrt((gamma * gamma) - 1)-alpha2 = (cos(twoPiPrd1) + sin(twoPiPrd1) - 1) / cos(twoPiPrd1)+alpha2 = (math.cos(twoPiPrd1) + math.sin(twoPiPrd1) - 1) / math.cos(twoPiPrd1)-alpha3 = (cos(twoPiPrd2) + sin(twoPiPrd2) - 1) / cos(twoPiPrd2)+alpha3 = (math.cos(twoPiPrd2) + math.sin(twoPiPrd2) - 1) / math.cos(twoPiPrd2)hp = 0.0⋯peak := 0.991 * nz(peak[1])-peak := abs(bp) > peak ? abs(bp) : peak+peak := math.abs(bp) > peak ? math.abs(bp) : peaksignal = peak != 0 ? bp / peak : 0⋯//Things-buy = crossover(trigger, signal)+buy = ta.crossover(trigger, signal)-sell = crossunder(trigger, signal)+sell = ta.crossunder(trigger, signal)if (buy)⋯Clean v5
VerifiedSame 78 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 18: input() → input.bool()
⋯//Targets, Stops-percentages = input(title="Percentage stop 🎯", defval=true)+percentages = input.bool(title="Percentage stop 🎯", defval=true)targetpercentage = input.float(title="Profit (%)", minval=0.0, step=0.1, defval=1.3) * 0.01⋯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: 78 before, 47 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.
⋯// © greenmask9, @cheatcountry-//@version=5+//@version=6strategy(title= "Ehlers Bandpass Filter", shorttitle = "Bandpass Filter", overlay=false)⋯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 |
|---|---|---|---|
| Capital Settings | Initial | string · options ["Initial", "Growing","Manual"] | ordersize line 15 |
| Manual Position Size | 100.3 | float | v3 |
| Leverage | 1 | float | v1 v2 |
| Percentage stop 🎯 | true | bool | exit Buy exit Short line 62 line 73 |
| Profit (%) | 1.3 | float · min 0.0 · step 0.1 | longtp shorttp |
| Stop Loss (%) | 0.6 | float · min 0.0 · step 0.1 | longStopPrice shortStopPrice |
| Source | close | source | src |
| Resolution | | timeframe (written input.resolution) | src |
| Allow Repainting? | false | bool | src |
| Length | 20 | int (written input.integer) · min 1 | twoPiPrd1 twoPiPrd2 beta gamma |
| Bandwidth | 0.3 | float · min 0.01 · step 0.01 | twoPiPrd1 twoPiPrd2 gamma |
What it calculates
- Crossover (
crossover,ta.crossoverin v5)trigger, signalbuy · line 58 - Crossunder (
crossunder,ta.crossunderin v5)trigger, signalsell · line 59
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Buy long | (buy) | On | 61 |
| Exit Buy stop and limit | (percentages) | On | 63 |
| Open Short short | (sell) | On | 72 |
| Exit Short stop and limit | (percentages) | On | 74 |
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 data1 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 | −13.1% | +102.5% | 58 | 40% | 0.75 | 20.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −3.4% | +5.5% | 75 | 32% | 0.86 | 6.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +5.0% | +9.8% | 74 | 38% | 1.05 | 39.5% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −15.9% | +8.4% | 73 | 25% | 0.57 | 15.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −7.6% | +16.7% | 82 | 49% | 0.94 | 34.7% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −7.7% | +21.5% | 81 | 33% | 0.85 | 16.5% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +5.1% | +148.3% | 80 | 46% | 1.08 | 12.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −10.8% | +17.1% | 75 | 28% | 0.71 | 13.8% | 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 | 44% | −$3,889.89 |
| Sideways market | 19 | 32% | −$7,518.38 |
| Falling market | 21 | 43% | −$1,694.12 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
26.8%
The 95th percentile of the worst drawdown when the same 58 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 15.2% to 26.8%; the tick is what actually happened, 20.0%. Order luck alone moves it this much.
All 58 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 30 Jan 2024 43,302.70 | 31 Jan 2024 42,941.10 | 1 | $723.22 |
| long | 31 Jan 2024 42,941.10 | 31 Jan 2024 42,941.10 | 0 | $0.00 |
| short | 19 Feb 2024 52,137.70 | 20 Feb 2024 51,459.90 | 1 | $677.79 |
| long | 25 Feb 2024 51,568.20 | 26 Feb 2024 51,258.80 | 1 | −$309.41 |
| short | 6 Mar 2024 63,724.00 | 7 Mar 2024 66,074.00 | 1 | −$2,350.03 |
| long | 17 Mar 2024 65,300.60 | 18 Mar 2024 68,393.50 | 1 | $3,092.83 |
| short | 2 Apr 2024 69,649.80 | 3 Apr 2024 65,464.00 | 1 | $4,185.82 |
| long | 8 Apr 2024 69,360.40 | 9 Apr 2024 71,620.00 | 1 | $2,259.62 |
| short | 17 May 2024 65,235.20 | 18 May 2024 67,024.00 | 1 | −$1,788.79 |
| long | 2 Jun 2024 67,766.80 | 3 Jun 2024 68,647.80 | 1 | $880.97 |
| short | 12 Jun 2024 67,314.20 | 13 Jun 2024 68,264.00 | 1 | −$949.75 |
| long | 18 Jun 2024 66,504.30 | 19 Jun 2024 65,175.30 | 1 | −$1,329.01 |
| short | 6 Jul 2024 56,628.80 | 7 Jul 2024 58,230.10 | 1 | −$1,601.34 |
| long | 9 Jul 2024 56,714.60 | 10 Jul 2024 58,050.00 | 1 | $1,335.39 |
| short | 20 Jul 2024 66,660.00 | 21 Jul 2024 67,140.00 | 1 | −$479.96 |
| long | 1 Aug 2024 64,628.00 | 2 Aug 2024 65,468.20 | 1 | $840.17 |
| short | 17 Aug 2024 58,874.60 | 18 Aug 2024 59,492.00 | 1 | −$617.40 |
| long | 3 Sep 2024 59,132.10 | 4 Sep 2024 57,487.70 | 1 | −$1,644.38 |
| short | 17 Sep 2024 58,214.00 | 18 Sep 2024 60,314.00 | 1 | −$2,100.00 |
| long | 5 Oct 2024 62,086.00 | 6 Oct 2024 62,893.10 | 1 | $807.12 |
| short | 17 Oct 2024 67,620.00 | 18 Oct 2024 68,025.70 | 1 | −$405.72 |
| long | 30 Oct 2024 72,736.40 | 31 Oct 2024 72,300.00 | 1 | −$436.42 |
| short | 6 Nov 2024 69,372.00 | 7 Nov 2024 75,572.00 | 1 | −$6,199.98 |
| long | 30 Nov 2024 97,460.00 | 1 Dec 2024 96,408.00 | 1 | −$1,052.01 |
| short | 11 Dec 2024 96,593.00 | 12 Dec 2024 101,125.00 | 1 | −$4,532.00 |
| short | 21 Dec 2024 97,805.40 | 22 Dec 2024 96,534.00 | 1 | $1,271.48 |
| long | 23 Dec 2024 95,186.30 | 24 Dec 2024 94,615.20 | 1 | −$571.12 |
| short | 9 Jan 2025 95,060.60 | 10 Jan 2025 92,552.50 | 1 | $2,508.12 |
| long | 3 Feb 2025 97,700.60 | 4 Feb 2025 101,329.00 | 1 | $3,627.92 |
| short | 18 Feb 2025 95,780.00 | 19 Feb 2025 96,354.70 | 1 | −$574.69 |
| long | 26 Feb 2025 88,680.40 | 27 Feb 2025 84,250.10 | 1 | −$4,430.30 |
| short | 12 Mar 2025 82,933.00 | 13 Mar 2025 83,680.10 | 1 | −$747.13 |
| long | 17 Mar 2025 82,574.50 | 18 Mar 2025 84,010.00 | 1 | $1,435.50 |
| short | 26 Mar 2025 87,392.90 | 27 Mar 2025 86,256.80 | 1 | $1,136.11 |
| long | 6 Apr 2025 83,538.00 | 7 Apr 2025 78,430.00 | 1 | −$5,107.99 |
| short | 17 Apr 2025 84,030.40 | 18 Apr 2025 84,947.90 | 1 | −$917.54 |
| short | 19 Nov 2025 92,960.80 | 20 Nov 2025 91,555.00 | 1 | $1,405.87 |
| long | 23 Nov 2025 84,739.80 | 24 Nov 2025 86,830.00 | 1 | $2,090.25 |
| short | 4 Dec 2025 93,429.90 | 5 Dec 2025 92,078.10 | 1 | $1,351.89 |
| long | 17 Dec 2025 87,863.40 | 18 Dec 2025 86,243.20 | 1 | −$1,620.20 |
| short | 27 Dec 2025 87,369.60 | 28 Dec 2025 87,893.80 | 1 | −$524.22 |
| long | 26 Jan 2026 86,670.40 | 27 Jan 2026 88,347.10 | 1 | $1,676.72 |
| short | 19 Feb 2026 66,461.00 | 20 Feb 2026 67,003.70 | 1 | −$542.73 |
| long | 2 Mar 2026 65,776.50 | 3 Mar 2026 68,830.10 | 1 | $3,053.58 |
| short | 8 Mar 2026 67,262.90 | 9 Mar 2026 65,971.20 | 1 | $1,291.71 |
| long | 27 Mar 2026 68,820.30 | 28 Mar 2026 66,407.30 | 1 | −$2,413.03 |
| short | 8 Apr 2026 71,924.20 | 9 Apr 2026 70,989.20 | 1 | $935.02 |
| long | 20 May 2026 76,834.40 | 21 May 2026 77,833.20 | 1 | $998.85 |
| short | 19 Jun 2026 62,958.00 | 20 Jun 2026 63,543.90 | 1 | −$585.89 |
| long | 29 Jun 2026 59,577.00 | 30 Jun 2026 59,219.50 | 1 | −$357.47 |
| short | 9 Jul 2026 62,290.00 | 10 Jul 2026 63,230.00 | 1 | −$940.00 |
| long | 21 Jul 2026 65,255.50 | 22 Jul 2026 66,556.10 | 1 | $1,300.64 |
| short | 28 Jul 2026 63,755.90 | 29 Jul 2026 64,138.40 | 1 | −$382.54 |
| long | 6 Aug 2026 64,665.20 | 7 Aug 2026 64,277.20 | 1 | −$388.00 |
| short | 14 Aug 2026 63,490.90 | 17 Aug 2026 63,871.80 | 3 | −$380.95 |
| long | 6 Sep 2026 79,831.80 | 7 Sep 2026 79,352.80 | 1 | −$479.00 |
| short | 18 Sep 2026 76,417.00 | 19 Sep 2026 80,883.90 | 1 | −$4,466.85 |
| long | 5 Oct 2026 86,530.00 | 6 Oct 2026 85,766.90 | 1 | −$763.13 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 25 ms | Yes 1,000 bars in 70 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. PineTS runs Pine Script v5 and v6 only.
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/// © greenmask9, @cheatcountry//@version=4strategy(title= "Ehlers Bandpass Filter", shorttitle = "Bandpass Filter", overlay=false)//commission_type=strategy.commission.percent, commission_value=.5////Capital Managementcapitaltype = input(defval="Initial", title="Capital Settings", options=["Initial", "Growing","Manual"], type=input.string)manualcapital = input(title="Manual Position Size", defval=100.3, type=input.float)leverage = input(title="Leverage", defval=1, type=input.float)capitalsystem(capitaltype) => v1 = floor(strategy.initial_capital/close) * leverage v2 = floor((strategy.initial_capital + strategy.netprofit)/close) * leverage v3 = manualcapital capitaltype== "Initial"? v1 : capitaltype == "Growing" ? v2 : v3ordersize=capitalsystem(capitaltype)//Targets, Stopspercentages = input(title="Percentage stop 🎯", defval=true)targetpercentage = input(title="Profit (%)", type=input.float, minval=0.0, step=0.1, defval=1.3) * 0.01stoppercentage = input(title="Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=0.6) * 0.01longtp = strategy.position_avg_price * (1 + targetpercentage)shorttp = strategy.position_avg_price * (1 - targetpercentage)longStopPrice = strategy.position_avg_price * (1 - stoppercentage)shortStopPrice = strategy.position_avg_price * (1 + stoppercentage)//Cheatcountry's part// Copyright (c) 2019-present, Franklin Moormann (cheatcountry)// Ehlers Bandpass Filter script may be freely distributed under the MIT license.inp = input(title="Source", type=input.source, defval=close)res = input(title="Resolution", type=input.resolution, defval="")rep = input(title="Allow Repainting?", type=input.bool, defval=false)src = security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]length = input(title="Length", type=input.integer, defval=20, minval=1)bw = input(title="Bandwidth", type=input.float, defval=0.3, minval=0.01, step = 0.01)pi = 2 * asin(1)twoPiPrd1 = 0.25 * bw * 2 * pi / lengthtwoPiPrd2 = 1.5 * bw * 2 * pi / lengthbeta = cos(2 * pi / length)gamma = 1.0 / cos(2 * pi * bw / length)alpha1 = gamma - sqrt((gamma * gamma) - 1)alpha2 = (cos(twoPiPrd1) + sin(twoPiPrd1) - 1) / cos(twoPiPrd1)alpha3 = (cos(twoPiPrd2) + sin(twoPiPrd2) - 1) / cos(twoPiPrd2)hp = 0.0hp := ((1 + (alpha2 / 2)) * (src - nz(src[1]))) + ((1 - alpha2) * nz(hp[1]))bp = 0.0bp := bar_index > 2 ? (0.5 * (1 - alpha1) * (hp - nz(hp[2]))) + (beta * (1 + alpha1) * nz(bp[1])) - (alpha1 * nz(bp[2])) : 0peak = 0.0peak := 0.991 * nz(peak[1])peak := abs(bp) > peak ? abs(bp) : peaksignal = peak != 0 ? bp / peak : 0trigger = 0.0trigger := ((1 + (alpha3 / 2)) * (signal - nz(signal[1]))) + ((1 - alpha3) * nz(trigger[1]))sig = trigger > nz(trigger[1]) ? 1 : trigger < nz(trigger[1]) ? -1 : 0sigColor = sig > 0 ? color.green : sig < 0 ? color.red : color.blackplot(signal, title="Signal", color=sigColor, linewidth=2)plot(trigger, title="Trigger", color=color.black, linewidth=1)//End Cheatcountry's part//Thingsbuy = crossover(trigger, signal)sell = crossunder(trigger, signal)if (buy) strategy.entry("Buy", strategy.long, ordersize)if (percentages) strategy.exit( "Buy", from_entry="Buy", stop=longStopPrice, limit= longtp)// if (target and stop)// strategy.exit( "Set Value tp/sl", from_entry="Buy", profit=targetticks, loss=stopnumberticks)// if (target and not stop)// strategy.exit( "Set Value tp/sl", from_entry="Buy", profit=targetticks)// if (stop and not target)// strategy.exit( "Set Value tp/sl", from_entry="Buy", loss=stopnumberticks)//strategy.close("Buy", buyend)if (sell) strategy.entry("Short", strategy.short, ordersize)if (percentages) strategy.exit( "Short", from_entry="Short", stop=shortStopPrice, limit = shorttp)//plot(series=(strategy.position_size > 0) ? longStopPrice : na,// color=color.red, style=plot.style_linebr,// linewidth=2, title="Long Stop Loss")//plot(series=(strategy.position_size < 0) ? shortStopPrice : na,// color=color.red, style=plot.style_linebr,// linewidth=2, title="Short Stop Loss")//plot(series=(strategy.position_size > 0) ? longtp : na,// color=color.lime, style=plot.style_linebr,// linewidth=2, title="Long Stop Loss")//plot(series=(strategy.position_size < 0) ? shorttp : na,// color=color.lime, style=plot.style_linebr,// linewidth=2, title="Short Stop Loss")