Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Heiken Ashi & Super Trend

A Pine Script v5 strategy with no technical-analysis calculation. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade commits 100% of equity and pays 0.02% commission. 9 settings; defaults include ATR Length 10, Factor 3.0 and TP [%] 1.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 Heiken Ashi & Super Trend repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
How did Heiken Ashi & Super Trend do on BTCUSDT 1D with default settings?
+3.42%
From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Heiken Ashi & Super Trend run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L62:C0: a 'bool' cannot be 'na' in Pine Script v6 — declare it as true or false. The v6 version is shown for reference and is not offered as a download.
Does Heiken Ashi & Super Trend use a stop loss?
No
Its exits set a profit target but no stop.
Does Heiken Ashi & Super Trend run in Zeal Terminal?
Yes
It compiles in 34 ms and runs 1,000 bars in 127 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Up Trend
  • Down Trend
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$10,343$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. 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. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView. The live re-run is not offered here: the script requests heikinashi:SYMBOL D, heikinashi:BINANCE:BTCUSDT D, which this page cannot load in your browser.
Net profit
+3.42%
$342.50
Buy and hold
+102.5%
same period
Closed trades
17
16 won · 1 lost
Profitable
94.1%
of closed trades
Profit factor
1.24
gross profit ÷ gross loss
Max drawdown
15.60%
−$1,772.28

One run with the author's default settings, $10,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 stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    Uses an argument v6 removed

    when = on line 89, 91. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
ATR Length10intatr direction supertrend
Factor3.0float · step 0.01upperBand lowerBand direction supertrend
TP [%]1.1float · step 0.1exit TP_L exit TP_S
BACKTEST
start year2000int · min 1997 · max 3000testPeriodStart
start month01int · min 1 · max 12testPeriodStart
start day01int · min 1 · max 31testPeriodStart
stop year3333int · min 1980 · max 3333testPeriodStop
stop month12int · min 1 · max 12testPeriodStop
stop day31int · min 1 · max 31testPeriodStop

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

openopenprice datahighhighprice datalowlowprice dataclosecloseprice dataatrPeriodATR Lengthsetting · 10factorFactorsetting · 3.0testStartYearstart yearsetting · 2000testStartMonthstart monthsetting · 01testStartDaystart daysetting · 01testStopYearstop yearsetting · 3333testStopMonthstop monthsetting · 12testStopDaystop daysetting · 31timetimeprice dataheikinashi_openheikinashi_openvalueheikinashi_highheikinashi_highvalueheikinashi_lowheikinashi_lowvalueheikinashi_closeheikinashi_closevaluesumxsumxvaluealphaalphavaluesumsumvaluetrueRangetrueRangevaluesrcsrcvalueatratrvalueupperBandupperBandvaluelowerBandlowerBandvalueprevLowerBandprevLowerBandvalueprevUpperBandprevUpperBandvaluedirection, supertrenddirection · supertrend2 valuessuperTrendsuperTrendvalueprevSuperTrendprevSuperTrendvaluelongCondlongCondvalueshortCondshortCondvalueCondIni_longCondIni_longvalueCondIni_shortCondIni_shortvalueopen_longConditionopen_longConditionvalueopen_shortConditionopen_shortConditionvaluetestPeriodStarttestPeriodStartvaluetestPeriodStoptestPeriodStopvaluetestPeriodtestPeriodvaluelong, shortlong · short2 conditionslongConditionlongConditionconditionshortConditionshortConditionconditionheikinashi_colorColourheikinashi_colorentry:LOpen Lstrategy.entryentry:SOpen Sstrategy.entryexit:TP_Lexit TP_Lstrategy.exitexit:TP_Sexit TP_Sstrategy.exitplot:54plotplotplot:55Up Trendplotplot:56Down Trendplotfill:57Fillfill × 2fill:58Fillfill × 2

Order rules

OrderFires whenBy defaultLine
Open L longtestPeriodOn89
Open S shorttestPeriodOn91
Exit TP_L limitevery barOn93
Exit TP_S limitevery barOn94

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.

5/5trades 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 data4 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+3.4%+102.5%1794%1.2415.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−5.9%+5.5%1471%0.6411.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−2.0%+9.8%1694%0.8930.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−2.2%+8.4%1479%0.8310.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.8%+16.7%2095%0.9625.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+6.2%+21.5%1493%1.829.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+13.5%+148.3%12100%—3.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−6.1%+17.1%1979%0.7112.7%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): heikinashi:SYMBOL D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), heikinashi:BINANCE:BTCUSDT D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), fetched from Binance's public market data for each market.

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market3100%$326.37
Sideways market1292%−$198.54
Falling market2100%$214.67

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

How bad could the drawdown be?

12.7%

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

0%15%
All 17 trades
SideEntryExitBarsP&L
long11 Feb 2024 47,751.1011 Feb 2024 48,269.600$104.53
short2 May 2024 58,365.002 May 2024 57,697.600$111.50
long22 May 2024 70,148.304 Jun 2024 70,934.3013$110.33
short24 Jun 2024 63,210.0024 Jun 2024 62,503.100$111.35
long20 Jul 2024 66,660.0020 Jul 2024 67,363.900$106.00
short5 Aug 2024 58,161.005 Aug 2024 57,493.300$116.82
long21 Sep 2024 63,201.1022 Sep 2024 63,893.501$112.49
short26 Feb 2025 88,680.4026 Feb 2025 87,673.300$118.03
long24 Apr 2025 93,691.1025 Apr 2025 94,718.901$115.08
short26 Aug 2025 110,112.0026 Aug 2025 108,864.000$120.38
long3 Oct 2025 120,529.003 Oct 2025 121,834.000$115.93
short12 Oct 2025 110,644.0016 Oct 2025 109,404.004$121.55
long15 Jan 2026 96,951.8030 Jan 2026 84,650.2015−$1,445.88
short30 Jan 2026 84,650.2030 Jan 2026 83,667.900$111.15
long18 Apr 2026 77,072.0022 Apr 2026 77,898.704$103.52
short29 May 2026 73,617.5029 May 2026 72,798.600$108.67
long20 Aug 2026 69,334.8020 Aug 2026 70,046.800$101.03

Similar scripts

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

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.

  • 2 strategy calls use the when = argument (line 89, 91). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 1 setting uses the untyped input() (line 51). 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.

Clean v5

VerifiedDownload the v5 script

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

  • Line 51: input() → input.int()
  • Line 89: when = testPeriod → if block
  • Line 91: when = testPeriod → if block
⋯///////////////////////////////////////////////////-atrPeriod = input(10, "ATR Length")+atrPeriod = input.int(10, "ATR Length")factor = input.float(3.0, "Factor", step = 0.01)⋯if longCond-    strategy.entry("L", strategy.long, when=testPeriod)+    if testPeriod+        strategy.entry("L", strategy.long)if shortCond-    strategy.entry("S", strategy.short, when=testPeriod)+    if testPeriod+        strategy.entry("S", strategy.short)    ⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L62:C0: a 'bool' cannot be 'na' in Pine Script v6 — declare it as true or false. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © RingsCherrY-//@version=5+//@version=6strategy("Heiken Ashi & Super Trend", overlay=true,  pyramiding=1,initial_capital = 10000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.02)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 34 msWith a workaround 1,000 bars in 127 msNot measured
PineTSNot testedNot testedNot 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. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView.

“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/// © RingsCherrY//@version=5strategy("Heiken Ashi & Super Trend", overlay=true,  pyramiding=1,initial_capital = 10000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.02)///////////////////////////////////////////////////////////////////////Function//////////////////////////////////////////////////////////////////////////heikinashi_open = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)heikinashi_high = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)heikinashi_low  = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)heikinashi_close= request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)heikinashi_color = heikinashi_open < heikinashi_close ? #53b987 : #eb4d5c// plotbar(heikinashi_open, heikinashi_high, heikinashi_low, heikinashi_close, color=heikinashi_color)x_sma(x, y) =>    sumx = 0.0    for i = 0 to y - 1        sumx := sumx + x[i] / y    sumxx_rma(src, length) =>    alpha = 1/length    sum = 0.0    sum := na(sum[1]) ? x_sma(src, length) : alpha * src + (1 - alpha) * nz(sum[1])x_atr(length) =>    trueRange = na(heikinashi_high[1])? heikinashi_high-heikinashi_low : math.max(math.max(heikinashi_high - heikinashi_low, math.abs(heikinashi_high - heikinashi_close[1])), math.abs(heikinashi_low - heikinashi_close[1]))    //true range can be also calculated with ta.tr(true)    x_rma(trueRange, length)x_supertrend(factor, atrPeriod) =>    src = (heikinashi_high+heikinashi_low)/2    atr = x_atr(atrPeriod)    upperBand = src + factor * atr    lowerBand = src - factor * atr    prevLowerBand = nz(lowerBand[1])    prevUpperBand = nz(upperBand[1])    lowerBand := lowerBand > prevLowerBand or heikinashi_close[1] < prevLowerBand ? lowerBand : prevLowerBand    upperBand := upperBand < prevUpperBand or heikinashi_close[1] > prevUpperBand ? upperBand : prevUpperBand    int direction = na    float superTrend = na    prevSuperTrend = superTrend[1]    if na(atr[1])        direction := 1    else if prevSuperTrend == prevUpperBand        direction := heikinashi_close > upperBand ? -1 : 1    else        direction := heikinashi_close < lowerBand ? 1 : -1    superTrend := direction == -1 ? lowerBand : upperBand    [superTrend, direction]    ///////////////////////////////////////////////////////////////////////Indicators////////////////////////////////////////////////////////////////////////atrPeriod = input(10, "ATR Length")factor = input.float(3.0, "Factor", step = 0.01)[supertrend, direction] = x_supertrend(factor, atrPeriod)bodyMiddle = plot((heikinashi_open + heikinashi_close) / 2, display=display.none)upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)///////////////////////////////////////////////////////////////////////Strategy//////////////////////////////////////////////////////////////////////////var bool longCond                    = na, var bool shortCond                   = na, longCond := nz(longCond[1]), shortCond := nz(shortCond[1])var int CondIni_long                 = 0, var int CondIni_short                 = 0, CondIni_long := nz(CondIni_long[1]), CondIni_short := nz(CondIni_short[1])var float open_longCondition         = na, var float open_shortCondition   = nalong  = ta.change(direction) < 0short = ta.change(direction) > 0longCond        :=                                                              longshortCond       :=                                                              shortCondIni_long    :=                                                              longCond[1] ? 1 : shortCond[1] ? -1 : nz(CondIni_long[1])CondIni_short   :=                                                              longCond[1] ? 1 : shortCond[1] ? -1 : nz(CondIni_short[1])longCondition   =                                                               (longCond[1] and nz(CondIni_long[1]) == -1)shortCondition  =                                                               (shortCond[1] and nz(CondIni_short[1]) == 1)open_longCondition             :=                                          long ? close[1] :                                                      nz(open_longCondition[1])open_shortCondition            :=                                          short ? close[1] :                                                     nz(open_shortCondition[1])//TPtp                    = input.float(1.1  , "TP [%]",                      step = 0.1) //BACKTESTING inputs --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------testStartYear       =                   input.int(2000,                             title="start year",                                         minval = 1997, maxval = 3000,                                                   group= "BACKTEST") testStartMonth      =                   input.int(01,                               title="start month",                                        minval = 1, maxval = 12,                                                        group= "BACKTEST")testStartDay        =                   input.int(01,                               title="start day",                                          minval = 1, maxval = 31,                                                        group= "BACKTEST")testPeriodStart     =                   timestamp(testStartYear,testStartMonth,testStartDay,0,0)testStopYear        =                   input.int(3333,                             title="stop year",                                          minval=1980, maxval = 3333,                                                     group= "BACKTEST")testStopMonth       =                   input.int(12,                               title="stop month",                                         minval=1, maxval=12,                                                            group= "BACKTEST")testStopDay         =                   input.int(31,                               title="stop day",                                           minval=1, maxval=31,                                                            group= "BACKTEST")testPeriodStop      =                   timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)testPeriod          =                   time >= testPeriodStart and time <= testPeriodStop ? true : false// Backtest  ==================================================================================================================================================================================================================================================================================================================================if longCond    strategy.entry("L", strategy.long, when=testPeriod)if shortCond    strategy.entry("S", strategy.short, when=testPeriod)    strategy.exit("TP_L", "L", profit =((open_longCondition   *       (1+(tp/100))) - open_longCondition)/syminfo.mintick)strategy.exit("TP_S", "S", profit =((open_shortCondition  *       (1+(tp/100))) - open_shortCondition)/syminfo.mintick)