Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

TrianglePoint strategy

A Pine Script v4 strategy built on Highest (close, 9), Lowest (close, 9) and EMA (close, 13). It has 4 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is 3 contracts and pays no commission. 5 settings; defaults include Number of Bars 9, fast EMA 13 and slow EMA 65.

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 TrianglePoint strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did TrianglePoint strategy do on BTCUSDT 1D with default settings?
+45.40%
From 26 Jan 2024 to 21 Oct 2026, over 11 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can TrianglePoint strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does TrianglePoint strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does TrianglePoint strategy run in Zeal Terminal?
Yes
It compiles in 17 ms and runs 1,000 bars in 48 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • 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 (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$56,251$20,253Equity from $10,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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 57, 59) so the engine trades the way the script says.
Net profit
+45.40%
$4,540.47
Buy and hold
+102.5%
same period
Closed trades
11
2 won · 8 lost
Profitable
18.2%
of closed trades
Profit factor
1.03
gross profit ÷ gross loss
Max drawdown
101.92%
−$115,657.00

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long 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

    ema(close, 200) ignores the settings line 40

    Line 40 hard-codes 200 where line 38 uses “fast EMA”. Changing those settings moves one band but not this one.

    ema(close, 200)ema(close, fastEMA)
  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 57, 59, 66, 70. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 42

    transp = on line 42, 43, 44. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 57

    long = on line 57, 59. v5 writes it as direction = strategy.long or strategy.short.

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 highest → ta.highest, lowest → ta.lowest, ema → ta.ema, crossunder → ta.crossunder.
  • 4 strategy calls use the when = argument (line 57, 59, 66, 70). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 11 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 33: highest → ta.highest
  • Line 34: lowest → ta.lowest
  • Line 38: ema → ta.ema
  • Line 39: ema → ta.ema
  • Line 40: ema → ta.ema
6 more edits
  • Line 42: transp = 0 → color.new(color.green, 0)
  • Line 43: transp = 0 → color.new(color.orange, 0)
  • Line 44: transp = 0 → color.new(color.purple, 0)
  • Line 57: long = true → direction = strategy.long
  • Line 59: long = true → direction = strategy.long
  • Line 66: crossunder → ta.crossunder
⋯// © mohanee-//@version=4+//@version=5strategy(title="TrianglePoint strategy", overlay=true,pyramiding=2, default_qty_value=3, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯//showAllTriangles = input(true, title="show All Triangles")-HH = highest(close,numPeriods)+HH = ta.highest(close,numPeriods)-LL = lowest(close,numPeriods)+LL = ta.lowest(close,numPeriods)tringlePoint =  low > LL and high < HH⋯//LL = lowest(low,numPeriods)  //close[1],numPeriods-fastEMAval= ema(close, fastEMA)+fastEMAval= ta.ema(close, fastEMA)-slowEMAval= ema(close, slowEMA)+slowEMAval= ta.ema(close, slowEMA)-two100EMAval= ema(close, 200)+two100EMAval= ta.ema(close, 200)//plot emas-plot(fastEMAval, color = color.green, linewidth = 1, transp=0)+plot(fastEMAval, color = color.new(color.green, 0), linewidth = 1)-plot(slowEMAval, color = color.orange, linewidth = 1, transp=0)+plot(slowEMAval, color = color.new(color.orange, 0), linewidth = 1)-plot(two100EMAval, color = color.purple, linewidth = 2, transp=0)+plot(two100EMAval, color = color.new(color.purple, 0), linewidth = 2)longCondition=fastEMAval>two100EMAval and tringlePoint //and close>two100EMAval⋯//Entry-strategy.entry(id="TBT LE", comment="TBT LE" , long=true, stop=close[0]+0.10 ,when= longCondition and strategy.position_size<1 )   +strategy.entry(id="TBT LE", comment="TBT LE" , direction = strategy.long, stop=close[0]+0.10 ,when= longCondition and strategy.position_size<1 )   //Add-strategy.entry(id="TBT LE", comment="Add" , long=true,  when= longCondition and strategy.position_size>=1 and close<strategy.position_avg_price)   +strategy.entry(id="TBT LE", comment="Add" , direction = strategy.long,  when= longCondition and strategy.position_size>=1 and close<strategy.position_avg_price)   //barcolor(strategy.position_size>=1 ? color.blue : na)⋯//Exit-strategy.close(id="TBT LE", comment="TBT Exit",   when=crossunder(fastEMAval,slowEMAval))+strategy.close(id="TBT LE", comment="TBT Exit",   when=ta.crossunder(fastEMAval,slowEMAval))//stoploss⋯

Clean v5

VerifiedDownload the v5 script

Same 11 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 27: input() → input.int()
  • Line 28: input() → input.int()
  • Line 29: input() → input.int()
  • Line 30: input() → input.int()
  • Line 31: input() → input.bool()
  • Line 57: when = longCondition and strategy.position_size<1 → if block
3 more edits
  • Line 59: when = longCondition and strategy.position_size>=1 and close<strategy.position_avg_price → if block
  • Line 66: when = ta.crossunder(fastEMAval,slowEMAval) → if block
  • Line 70: when = close < stopLossVal → if block
⋯    -numPeriods=input(9,title="Number of Bars")+numPeriods=input.int(9,title="Number of Bars")-fastEMA = input(13, title="fast EMA", minval=1)+fastEMA = input.int(13, title="fast EMA", minval=1)-slowEMA = input(65, title="slow EMA", minval=1)+slowEMA = input.int(65, title="slow EMA", minval=1)-stopLoss = input(title="Stop Loss%", defval=5, minval=1)+stopLoss = input.int(title="Stop Loss%", defval=5, minval=1)-changeBarColor = input(true, title="chage bar color")+changeBarColor = input.bool(true, title="chage bar color")//showAllTriangles = input(true, title="show All Triangles")⋯//Entry-strategy.entry(id="TBT LE", comment="TBT LE" , direction = strategy.long, stop=close[0]+0.10 ,when= longCondition and strategy.position_size<1 )   +if longCondition and strategy.position_size<1+    strategy.entry(id="TBT LE", comment="TBT LE" , direction = strategy.long, stop=close[0]+0.10  )   //Add-strategy.entry(id="TBT LE", comment="Add" , direction = strategy.long,  when= longCondition and strategy.position_size>=1 and close<strategy.position_avg_price)   +if longCondition and strategy.position_size>=1 and close<strategy.position_avg_price+    strategy.entry(id="TBT LE", comment="Add" , direction = strategy.long)   //barcolor(strategy.position_size>=1 ? color.blue : na)⋯//Exit-strategy.close(id="TBT LE", comment="TBT Exit",   when=ta.crossunder(fastEMAval,slowEMAval))+if ta.crossunder(fastEMAval,slowEMAval)+    strategy.close(id="TBT LE", comment="TBT Exit")//stoploss⋯//stopLossVal= close> (strategy.position_avg_price * (1+(stopLoss*0.01) )) ? lowest(close,numPeriods) : (strategy.position_avg_price * (1-(stopLoss*0.01) ))-strategy.close(id="TBT LE", comment="SL Exit",   when= close < stopLossVal)+if close < stopLossVal+    strategy.close(id="TBT LE", comment="SL Exit")

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: 11 before, 0 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.

⋯// © mohanee-//@version=5+//@version=6strategy(title="TrianglePoint strategy", overlay=true,pyramiding=2, default_qty_value=3, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯

Settings

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

SettingDefaultType and rangeFeeds
Number of Bars9intHH_index LL_index HH LL
fast EMA13int · min 1fastEMAval
slow EMA65int · min 1slowEMAval
Stop Loss%5int · min 1takeProfitVal stopLossVal
chage bar colortrueboolbarcolor

What it calculates

  • Highest (highest, ta.highest in v5)close, Number of Bars (9)HH · line 33
  • Lowest (lowest, ta.lowest in v5)close, Number of Bars (9)LL · line 34
  • EMA (ema, ta.ema in v5)close, fast EMA (13)fastEMAval · line 38
  • EMA (ema, ta.ema in v5)close, slow EMA (65)slowEMAval · line 39
  • EMA (ema, ta.ema in v5)close, 200two100EMAval · line 40

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 datanumPeriodsNumber of Barssetting · 9fastEMAfast EMAsetting · 13slowEMAslow EMAsetting · 65highhighprice datalowlowprice datastopLossStop Loss%setting · 5HHHighest→ HHLLLowest→ LLfastEMAvalEMA→ fastEMAvalslowEMAvalEMA→ slowEMAvaltwo100EMAvalEMA→ two100EMAvaltHHtHHvalueHH_index, LL_indexHH_index · LL_index2 valuestLLtLLvaluetakeProfitVal, stopLossValtakeProfitVal · stopLos…2 valuestringlePointtringlePointconditionlongConditionlongConditionconditionentry:TBT LEOpen TBT LEstrategy.entryclose:TBT LEClose TBT LEstrategy.closeplot:42plotplotplot:43plotplotplot:44plotplotbarcolor:64barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Open TBT LE longlongCondition and strategy.position_size<1On57
Open TBT LE longlongCondition and strategy.position_size>=1 and close<strategy.position_avg_priceOn59
Close TBT LEcrossunder(fastEMAval,slowEMAval)On66
Close TBT LEclose < stopLossValOn70

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+45.4%+102.5%1118%1.03101.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1,077.0%+5.5%944%10.85131.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−19.5%+9.8%1118%0.6940.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+42.5%+8.4%7100%—3.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−1.1%+16.7%1625%0.712.4%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.9%+21.5%1225%2.190.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+1.6%+148.3%1323%1.126.8%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+3.6%+17.1%9100%—2.0%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 market0—$0.00
Sideways market1118%$4,540.47
Falling market0—$0.00

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

How bad could the drawdown be?

89.3%

The 95th percentile of the worst drawdown when the same 11 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 61.8% to 89.3%; the tick is what actually happened, 75.2%. Order luck alone moves it this much.

0%103%
All 11 trades
SideEntryExitBarsP&L
long6 Oct 2024 62,058.1023 Feb 2025 96,551.00140$103,479.00
long3 Mar 2025 94,270.104 Mar 2025 86,221.201−$24,146.80
long4 Mar 2025 86,221.204 Mar 2025 86,221.200$0.00
long6 Mar 2025 90,606.1010 Mar 2025 80,734.504−$29,614.90
long7 Mar 2025 89,931.9010 Mar 2025 80,734.503−$27,592.20
long5 May 2025 94,277.7030 Aug 2025 108,377.00117$42,299.00
long3 Sep 2025 111,240.0027 Sep 2025 109,643.0024−$4,789.95
long5 Sep 2025 110,731.0027 Sep 2025 109,643.0022−$3,262.23
long28 Sep 2025 109,636.0017 Oct 2025 108,194.0019−$4,325.04
long21 Oct 2025 110,532.005 Nov 2025 101,497.0015−$27,104.90
long22 Oct 2025 108,298.005 Nov 2025 101,497.0014−$20,401.30

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
TrianglePoint strategy this page—v4 strategy+45.4%11101.9%
CC Trend strategy 2- Downtrend Short by CheatCode1ema highest lowestv5 strategyNo trades on this market
Lagged Donchian Channel + EMA by Mysteriownema highest lowestv4 strategy−12.3%412.3%
Backtest Custom HiLo Strategy by luyikaibrema highest lowestv4 strategyNo trades on this market
CM_SlingShotSystem+_CassicEMA+Willams21EMA13 htc1977 edition by Arivadisema highest lowestv5 strategyNo trades on this market
EMA Mean Reversion Strategy by jordanfrayema highest lowestv5 strategy+4.7%2308.9%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 17 msWith a workaround 1,000 bars in 48 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 57, 59) so the engine trades the way the script says.

“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/// © mohanee//@version=4strategy(title="TrianglePoint strategy", overlay=true,pyramiding=2, default_qty_value=3, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)// variables  BEGIN//find the index of highest high  of n periods index_HH(pds) =>    tHH =0.00    HH_index=1    for i=1 to pds        if high[i]>tHH            tHH:=high[i]            HH_index:=i              HH_index//find the index of lowest low  of n periods index_LL(pds) =>    tLL = low[0]    LL_index=1    for i=1 to pds        if low[i]<tLL            tLL:=low[i]            LL_index:=i              LL_index    numPeriods=input(9,title="Number of Bars")fastEMA = input(13, title="fast EMA", minval=1)slowEMA = input(65, title="slow EMA", minval=1)stopLoss = input(title="Stop Loss%", defval=5, minval=1)changeBarColor = input(true, title="chage bar color")//showAllTriangles = input(true, title="show All Triangles")HH = highest(close,numPeriods)LL = lowest(close,numPeriods)tringlePoint =  low > LL and high < HH//HH = highest(high,numPeriods)   ///close[1],numPeriod//LL = lowest(low,numPeriods)  //close[1],numPeriodsfastEMAval= ema(close, fastEMA)slowEMAval= ema(close, slowEMA)two100EMAval= ema(close, 200)//plot emasplot(fastEMAval, color = color.green, linewidth = 1, transp=0)plot(slowEMAval, color = color.orange, linewidth = 1, transp=0)plot(two100EMAval, color = color.purple, linewidth = 2, transp=0)longCondition=fastEMAval>two100EMAval and tringlePoint //and close>two100EMAval// On the last price bar, make a new trend lineHH_index=index_HH(numPeriods)LL_index=index_LL(numPeriods)if (longCondition and strategy.position_size<1 )  //and barstate.islast    line.new(x1=bar_index[LL_index ], y1=low[LL_index],         x2=bar_index, y2=close, color=color.red, width=2)    line.new(x1=bar_index[HH_index], y1=high[HH_index],         x2=bar_index, y2=close, color=color.green, width=2)     line.new(x1=bar_index[HH_index], y1=high[HH_index],         x2=bar_index[LL_index], y2=low[LL_index], color=color.blue, width=2)           //Entrystrategy.entry(id="TBT LE", comment="TBT LE" , long=true, stop=close[0]+0.10 ,when= longCondition and strategy.position_size<1 )   //Addstrategy.entry(id="TBT LE", comment="Add" , long=true,  when= longCondition and strategy.position_size>=1 and close<strategy.position_avg_price)   //barcolor(strategy.position_size>=1 ? color.blue : na)//Take profittakeProfitVal=   strategy.position_size>=1 ?  (strategy.position_avg_price * (1+(stopLoss*0.01) )) : 0.00//strategy.close(id="TBT LE", comment="Profit Exit",  qty=strategy.position_size/2,  when=close>=takeProfitVal and close<open and close<fastEMAval)   //crossunder(close,fastEMAval)barcolor(strategy.position_size>=1  and changeBarColor==true ? (close>takeProfitVal? color.purple : color.blue): na)//Exitstrategy.close(id="TBT LE", comment="TBT Exit",   when=crossunder(fastEMAval,slowEMAval))//stoplossstopLossVal=   strategy.position_size>=1 ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00//stopLossVal= close> (strategy.position_avg_price * (1+(stopLoss*0.01) )) ? lowest(close,numPeriods) : (strategy.position_avg_price * (1-(stopLoss*0.01) ))strategy.close(id="TBT LE", comment="SL Exit",   when= close < stopLossVal)