Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Etlers Instantenous Trendline

A Pine Script v4 strategy built on Crossover (trigger, itrend) and Crossunder (trigger, itrend). 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. 9 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 Etlers Instantenous Trendline repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 23 of 23 trades.
How did Etlers Instantenous Trendline do on BTCUSDT 1D with default settings?
+13.21%
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 Etlers Instantenous Trendline 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 Etlers Instantenous Trendline use a stop loss?
Yes
strategy.exit sets a stop on line 47, 58.
Does Etlers Instantenous Trendline run in Zeal Terminal?
Yes
It compiles in 26 ms and runs 1,000 bars in 63 ms, in the browser.

BTCUSDT · 1D · default settings

  • Trigger
  • ITrend
  • Long Stop Loss
  • Short Stop Loss
  • Long Stop Loss
  • Short Stop Loss
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (9)
50,000100,000AprJulOct2025AprJulOct2026AprJulOct$113,211$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
+13.21%
$13,211.60
Buy and hold
+102.5%
same period
Closed trades
58
31 won · 25 lost
Profitable
53.4%
of closed trades
Profit factor
1.38
gross profit ÷ gross loss
Max drawdown
15.99%
−$18,205.30

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, pow → math.pow, crossover → ta.crossover, crossunder → ta.crossunder.

v4 → v5

Differs

Trades differ: 58 before, 75 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
12 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: security → request.security
  • Line 31: input(type = input.float) → input.float()
  • Line 33: pow → math.pow
  • Line 33: pow → math.pow
  • Line 34: pow → math.pow
  • Line 34: pow → math.pow
  • Line 42: crossover → ta.crossover
  • Line 43: crossunder → ta.crossunder
⋯// © greenmask9, @cheatcountry-//@version=4+//@version=5strategy(title= "Etlers Instantenous Trendline", shorttitle = "Instantenous Trendline", overlay=true)⋯//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) * 0.01+targetpercentage = input.float(title="Profit (%)", minval=0.0, step=0.1, defval=1) * 0.01-stoppercentage = input(title="Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=1) * 0.01+stoppercentage = input.float(title="Stop Loss (%)", minval=0.0, step=0.1, defval=1) * 0.01longtp  = strategy.position_avg_price * (1 + targetpercentage)⋯// Ehlers Instantaneous Trendline V2 [CC] script may be freely distributed under the MIT license.-inp = input(title="Source", type=input.source, defval=hl2)+inp = input.source(title="Source", defval=hl2)-res = input(title="Resolution", type=input.resolution, defval="")+res = input.timeframe(title="Resolution", defval="")-src = security(syminfo.tickerid, res, inp[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]+src = request.security(syminfo.tickerid, res, inp[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]-alpha = input(title="Alpha", type=input.float, defval=0.07, minval=0.01, step = 0.01)+alpha = input.float(title="Alpha", defval=0.07, minval=0.01, step = 0.01)itrend = 0.0-itrend := bar_index < 7 ? (src + (2 * nz(src[1])) + nz(src[2])) / 4 : ((alpha - (pow(alpha, 2) / 4)) * src) + (0.5 * pow(alpha, 2) * nz(src[1])) - +itrend := bar_index < 7 ? (src + (2 * nz(src[1])) + nz(src[2])) / 4 : ((alpha - (math.pow(alpha, 2) / 4)) * src) + (0.5 * math.pow(alpha, 2) * nz(src[1])) - -         ((alpha - (0.75 * pow(alpha, 2))) * nz(src[2])) + (2 * (1 - alpha) * nz(itrend[1])) - (pow(1 - alpha, 2) * nz(itrend[2]))+         ((alpha - (0.75 * math.pow(alpha, 2))) * nz(src[2])) + (2 * (1 - alpha) * nz(itrend[1])) - (math.pow(1 - alpha, 2) * nz(itrend[2]))trigger = (2 * itrend) - nz(itrend[2])⋯//Things-buy = crossover(trigger, itrend)+buy = ta.crossover(trigger, itrend)-sell = crossunder(trigger, itrend)+sell = ta.crossunder(trigger, itrend)if (buy)⋯

Clean v5

Verified

Same 75 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) * 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: 75 before, 58 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= "Etlers Instantenous Trendline", shorttitle = "Instantenous Trendline", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Capital SettingsInitialstring · options ["Initial", "Growing","Manual"]ordersize line 15
Manual Position Size100.3floatv3
Leverage1floatv1 v2
Percentage stop 🎯trueboolexit Buy exit Short line 46 line 57
Profit (%)1float · min 0.0 · step 0.1longtp shorttp
Stop Loss (%)1float · min 0.0 · step 0.1longStopPrice shortStopPrice
Sourcehl2sourcesrc
Resolutiontimeframe (written input.resolution)src
Alpha0.07float · min 0.01 · step 0.01itrend

What it calculates

  • Crossover (crossover, ta.crossover in v5)trigger, itrendbuy · line 42
  • Crossunder (crossunder, ta.crossunder in v5)trigger, itrendsell · line 43

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.

closecloseprice dataleverageLeveragesetting · 1manualcapitalManual Position Sizesetting · 100.3capitaltypeCapital Settingssetting · InitialtargetpercentageProfit (%)setting · 1stoppercentageStop Loss (%)setting · 1hl2hl2price dataresResolutionsetting · alphaAlphasetting · 0.07buyCrossover→ buysellCrossunder→ sellv1, v2v1 · v22 valuesv3v3valueordersizeordersizevaluelongtp, shorttplongtp · shorttp2 valueslongStopPrice, shortStopPricelongStopPrice · shortSt…2 valuessrcsrcvalueitrenditrendvaluetriggertriggervaluesigsigvalueitColorColouritColorentry:BuyOpen Buystrategy.entryexit:Buyexit Buystrategy.exitentry:ShortOpen Shortstrategy.entryexit:Shortexit Shortstrategy.exitplot:38Triggerplotplot:39ITrendplotplot:59Long Stop Lossplotplot:62Short Stop Lossplotplot:65Long Stop Lossplotplot:68Short Stop Lossplot

Order rules

OrderFires whenBy defaultLine
Open Buy long(buy)On45
Exit Buy stop and limit(percentages)On47
Open Short short(sell)On56
Exit Short stop and limit(percentages)On58

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.

23/23trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+13.2%+102.5%5853%1.3816.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.7%+5.5%7855%1.244.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−14.3%+9.8%8739%0.8738.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+18.6%+8.4%10057%1.505.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−59.1%+16.7%8339%0.6267.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+25.5%+21.5%7461%1.904.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.3%+148.3%8346%1.0024.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.8%+17.1%8048%0.938.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 barsTradesWonP&L
Rising market1872%$17,149.10
Sideways market1856%$3,489.49
Falling market2236%−$7,427.01

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

13.4%

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, 6.3% to 13.4%; the tick is what actually happened, 13.9%. Order luck alone moves it this much.

0%16%
All 58 trades
SideEntryExitBarsP&L
short21 Mar 2024 67,840.5022 Mar 2024 65,501.301$2,339.23
long28 Mar 2024 69,470.0029 Mar 2024 70,780.601$1,310.61
short5 Apr 2024 68,487.806 Apr 2024 67,802.901$684.88
long10 Apr 2024 69,146.0011 Apr 2024 70,631.101$1,485.08
short15 Apr 2024 65,661.9016 Apr 2024 63,420.001$2,241.86
long26 Apr 2024 64,498.3027 Apr 2024 63,770.001−$728.33
short27 Apr 2024 63,770.0027 Apr 2024 63,770.000$0.00
long8 May 2024 62,312.109 May 2024 61,193.001−$1,119.04
short10 May 2024 63,074.0011 May 2024 60,800.001$2,274.01
long17 May 2024 65,235.2018 May 2024 67,024.001$1,788.79
short14 Jun 2024 66,773.0015 Jun 2024 66,044.001$729.02
long17 Jul 2024 65,044.0018 Jul 2024 64,088.001−$956.01
short4 Aug 2024 60,698.005 Aug 2024 58,161.001$2,536.99
long24 Aug 2024 64,037.2025 Aug 2024 64,677.601$640.38
short30 Aug 2024 59,359.0031 Aug 2024 58,765.401$593.59
long15 Sep 2024 59,993.0016 Sep 2024 59,132.001−$861.02
short4 Oct 2024 60,752.705 Oct 2024 62,086.001−$1,333.28
long9 Oct 2024 62,160.5010 Oct 2024 60,636.001−$1,524.49
short11 Oct 2024 60,326.4012 Oct 2024 62,540.001−$2,213.59
long15 Oct 2024 66,084.0016 Oct 2024 67,074.101$990.14
short6 Nov 2024 69,372.007 Nov 2024 75,572.001−$6,199.98
long8 Nov 2024 75,857.909 Nov 2024 76,616.501$758.58
short22 Dec 2024 97,292.0023 Dec 2024 95,186.301$2,105.72
long6 Jan 2025 98,363.607 Jan 2025 102,236.001$3,871.99
short11 Jan 2025 94,726.1012 Jan 2025 93,778.801$947.27
long23 Mar 2025 83,840.6024 Mar 2025 86,082.501$2,241.91
short1 Apr 2025 82,550.002 Apr 2025 85,158.401−$2,608.35
long5 Apr 2025 83,889.906 Apr 2025 83,538.001−$351.88
short6 Apr 2025 83,538.006 Apr 2025 83,051.000$487.02
long14 Apr 2025 83,760.0015 Apr 2025 84,597.601$837.60
long6 Dec 2025 89,330.007 Dec 2025 88,436.701−$893.31
short9 Dec 2025 90,634.4010 Dec 2025 92,678.801−$2,044.46
long11 Dec 2025 92,015.4012 Dec 2025 91,095.201−$920.16
short16 Dec 2025 86,432.1017 Dec 2025 87,863.401−$1,431.35
long24 Dec 2025 87,486.0025 Dec 2025 88,360.901$874.86
short26 Dec 2025 87,225.3029 Dec 2025 88,097.503−$872.26
long31 Dec 2025 88,485.501 Jan 2026 87,600.601−$884.86
short23 Jan 2026 89,559.7025 Jan 2026 88,664.102$895.60
long5 Mar 2026 72,666.806 Mar 2026 70,891.001−$1,775.75
short11 Mar 2026 69,948.6012 Mar 2026 70,191.901−$243.22
long12 Mar 2026 70,191.9012 Mar 2026 70,648.100$456.27
short24 Mar 2026 70,906.4025 Mar 2026 71,615.501−$709.07
long27 Mar 2026 68,820.3028 Mar 2026 66,407.301−$2,413.03
short29 Mar 2026 66,377.0030 Mar 2026 67,040.801−$663.78
long8 Apr 2026 71,924.209 Apr 2026 71,069.901−$854.29
short18 May 2026 77,457.7019 May 2026 76,683.101$774.58
long18 Jun 2026 64,509.4019 Jun 2026 62,958.001−$1,551.39
short20 Jun 2026 63,543.9021 Jun 2026 64,298.001−$754.11
long6 Jul 2026 63,650.007 Jul 2026 64,286.501$636.51
short31 Jul 2026 64,780.001 Aug 2026 62,887.901$1,892.15
long2 Aug 2026 62,823.703 Aug 2026 63,570.001$746.36
short3 Aug 2026 63,570.003 Aug 2026 63,570.000$0.00
long7 Aug 2026 64,323.608 Aug 2026 64,966.801$643.24
short14 Aug 2026 63,490.9016 Aug 2026 62,855.902$634.91
long21 Aug 2026 73,027.0022 Aug 2026 78,338.001$5,311.01
short13 Sep 2026 77,278.7014 Sep 2026 76,505.901$772.79
long21 Sep 2026 81,178.0022 Sep 2026 86,620.001$5,442.00
short10 Oct 2026 82,635.6011 Oct 2026 83,461.901−$826.36

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 26 msYes 1,000 bars in 63 msNot measured
PineTSNo 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= "Etlers Instantenous Trendline", shorttitle = "Instantenous Trendline", overlay=true)//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) * 0.01stoppercentage = input(title="Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=1) * 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 Instantaneous Trendline V2 [CC] script may be freely distributed under the MIT license.inp = input(title="Source", type=input.source, defval=hl2)res = input(title="Resolution", type=input.resolution, defval="")src = security(syminfo.tickerid, res, inp[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]alpha = input(title="Alpha", type=input.float, defval=0.07, minval=0.01, step = 0.01)itrend = 0.0itrend := bar_index < 7 ? (src + (2 * nz(src[1])) + nz(src[2])) / 4 : ((alpha - (pow(alpha, 2) / 4)) * src) + (0.5 * pow(alpha, 2) * nz(src[1])) -          ((alpha - (0.75 * pow(alpha, 2))) * nz(src[2])) + (2 * (1 - alpha) * nz(itrend[1])) - (pow(1 - alpha, 2) * nz(itrend[2]))trigger = (2 * itrend) - nz(itrend[2])sig = trigger > itrend ? 1 : trigger < itrend ? -1 : 0itColor = sig > 0 ? color.green : sig < 0 ? color.red : color.blackplot(trigger, title="Trigger", color=itColor, linewidth=2)plot(itrend, title="ITrend", color=color.black, linewidth=1)//End Cheatcountry's part//Thingsbuy = crossover(trigger, itrend)sell = crossunder(trigger, itrend)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")