Pine Script v4 · Strategy
Heikin Ashi + Price Action Crypto LONG Strategy
A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.1% commission. 1 setting.
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 Heikin Ashi + Price Action Crypto LONG Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 9 of 9 trades.
- How did Heikin Ashi + Price Action Crypto LONG Strategy do on BTCUSDT 1D with default settings?
- −3.35%
- From 26 Jan 2024 to 21 Oct 2026, over 37 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Heikin Ashi + Price Action Crypto LONG 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 Heikin Ashi + Price Action Crypto LONG Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Heikin Ashi + Price Action Crypto LONG Strategy run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 39 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −3.35%
- −$33.48
- Buy and hold
- +102.5%
- same period
- Closed trades
- 37
- 12 won · 25 lost
- Profitable
- 32.4%
- of closed trades
- Profit factor
- 0.97
- gross profit ÷ gross loss
- Max drawdown
- 40.69%
- −$555.37
One run with the author's default settings, $1,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
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
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 15, 17. The upgraded version below moves each call inside an if block.
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 security → request.security, heikinashi → ticker.heikinashi.
- 2 strategy calls use the when = argument (line 15, 17). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 37 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 9: security → request.security
- Line 9: heikinashi → ticker.heikinashi
- Line 10: security → request.security
- Line 10: heikinashi → ticker.heikinashi
- Line 11: security → request.security
4 more edits
- Line 11: heikinashi → ticker.heikinashi
- Line 12: security → request.security
- Line 12: heikinashi → ticker.heikinashi
- Line 15: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © SoftKill21-//@version=4+//@version=5strategy(title="random", shorttitle="random", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯// === BASE FUNCTIONS ===-haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : close+haClose = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) : close-haOpen = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : open+haOpen = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open) : open-haHigh = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : high+haHigh = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high) : high-haLow = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : low+haLow = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low) : lowlong = haClose > haHigh[1] and haClose > haOpen and haHigh[1] > haHigh[2] //and close > high[3]short = haClose < haOpen and haClose < haLow[1]-strategy.entry("long",1,when=long)+strategy.entry("long",strategy.long,when=long)//strategy.entry("short",0,when=short)⋯Same 37 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.bool()
- Line 15: when = long → if block
- Line 17: when = short → if block
⋯strategy(title="random", shorttitle="random", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )-UseHAcandles = input(true, title="Use Heikin Ashi Candles in Algo Calculations")+UseHAcandles = input.bool(true, title="Use Heikin Ashi Candles in Algo Calculations")//⋯short = haClose < haOpen and haClose < haLow[1]-strategy.entry("long",strategy.long,when=long)+if long+ strategy.entry("long",strategy.long)//strategy.entry("short",0,when=short)-strategy.close("long",when=short)+if short+ strategy.close("long")//strategy.close_all()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: 37 before, 46 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.
⋯// © SoftKill21-//@version=5+//@version=6strategy(title="random", shorttitle="random", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯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 |
|---|---|---|---|
| Use Heikin Ashi Candles in Algo Calculations | true | bool | haClose haOpen haHigh haLow |
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | longhaClose > haHigh[1] and haClose > haOpen and haHigh[1] > haHigh[2] | On | 15 |
| Close long | shorthaClose < haOpen and haClose < haLow[1] | On | 17 |
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 data4 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 | −3.3% | +102.5% | 37 | 32% | 0.97 | 40.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −12.4% | +5.5% | 37 | 32% | 0.59 | 15.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +39.4% | +9.8% | 33 | 24% | 1.24 | 41.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −8.5% | +8.4% | 32 | 25% | 0.79 | 11.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −11.0% | +16.7% | 39 | 44% | 0.94 | 55.7% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.4% | +21.5% | 26 | 42% | 1.01 | 20.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +45.2% | +148.3% | 37 | 46% | 1.45 | 24.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.2% | +17.1% | 37 | 38% | 1.01 | 14.0% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 13 | 23% | −$374.12 |
| Sideways market | 17 | 41% | $424.12 |
| Falling market | 7 | 29% | −$83.49 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
50.1%
The 95th percentile of the worst drawdown when the same 37 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 26.1% to 50.1%; the tick is what actually happened, 39.1%. Order luck alone moves it this much.
All 37 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 9 Feb 2024 45,288.70 | 20 Mar 2024 61,937.40 | 40 | $364.88 |
| long | 26 Mar 2024 69,880.00 | 3 Apr 2024 65,464.00 | 8 | −$88.81 |
| long | 9 Apr 2024 71,620.00 | 13 Apr 2024 67,116.50 | 4 | −$82.63 |
| long | 23 Apr 2024 66,819.30 | 2 May 2024 58,365.00 | 9 | −$153.08 |
| long | 5 May 2024 63,892.00 | 9 May 2024 61,193.00 | 4 | −$45.94 |
| long | 21 May 2024 71,446.60 | 24 May 2024 67,969.70 | 3 | −$50.28 |
| long | 4 Jun 2024 68,809.90 | 12 Jun 2024 67,314.20 | 8 | −$22.37 |
| long | 15 Jul 2024 60,797.90 | 31 Jul 2024 66,188.00 | 16 | $79.72 |
| long | 14 Sep 2024 60,498.00 | 17 Sep 2024 58,214.00 | 3 | −$39.73 |
| long | 20 Sep 2024 62,948.00 | 1 Oct 2024 63,327.60 | 11 | $3.87 |
| long | 29 Oct 2024 69,962.20 | 4 Nov 2024 68,776.00 | 6 | −$18.27 |
| long | 7 Nov 2024 75,572.00 | 26 Nov 2024 93,010.00 | 19 | $216.27 |
| long | 16 Dec 2024 104,464.00 | 19 Dec 2024 100,204.00 | 3 | −$49.68 |
| long | 7 Jan 2025 102,236.00 | 9 Jan 2025 95,060.60 | 2 | −$80.25 |
| long | 16 Jan 2025 100,497.00 | 27 Jan 2025 102,620.00 | 11 | $19.72 |
| long | 21 Feb 2025 98,305.00 | 25 Feb 2025 91,552.90 | 4 | −$74.31 |
| long | 25 Mar 2025 87,498.20 | 29 Mar 2025 84,424.40 | 4 | −$36.28 |
| long | 13 Apr 2025 85,276.90 | 5 May 2025 94,277.60 | 22 | $97.43 |
| long | 9 May 2025 103,262.00 | 31 May 2025 103,985.00 | 22 | $5.20 |
| long | 10 Jun 2025 110,263.00 | 13 Jun 2025 105,672.00 | 3 | −$45.53 |
| long | 26 Jun 2025 107,341.00 | 2 Jul 2025 105,681.00 | 6 | −$17.43 |
| long | 11 Jul 2025 116,010.00 | 2 Aug 2025 113,298.00 | 22 | −$24.89 |
| long | 8 Aug 2025 117,472.00 | 19 Aug 2025 116,227.00 | 11 | −$12.04 |
| long | 3 Sep 2025 111,240.00 | 23 Sep 2025 112,651.00 | 20 | $10.08 |
| long | 30 Sep 2025 114,312.00 | 11 Oct 2025 112,774.00 | 11 | −$14.74 |
| long | 21 Oct 2025 110,532.00 | 30 Oct 2025 110,021.00 | 9 | −$6.22 |
| long | 28 Nov 2025 91,333.90 | 2 Dec 2025 86,286.00 | 4 | −$53.42 |
| long | 4 Dec 2025 93,429.90 | 6 Dec 2025 89,330.00 | 2 | −$40.36 |
| long | 30 Dec 2025 87,237.10 | 19 Jan 2026 93,673.10 | 20 | $60.23 |
| long | 15 Feb 2026 69,822.90 | 24 Feb 2026 64,656.00 | 9 | −$68.35 |
| long | 11 Mar 2026 69,948.60 | 20 Mar 2026 69,930.00 | 9 | −$1.89 |
| long | 6 Apr 2026 69,034.20 | 20 Apr 2026 73,801.80 | 14 | $55.61 |
| long | 23 Apr 2026 78,178.20 | 17 May 2026 78,148.10 | 24 | −$2.11 |
| long | 15 Jun 2026 65,746.40 | 18 Jun 2026 64,509.40 | 3 | −$18.37 |
| long | 22 Jul 2026 66,556.10 | 11 Aug 2026 63,970.00 | 20 | −$35.31 |
| long | 20 Aug 2026 69,334.80 | 9 Sep 2026 78,455.80 | 20 | $107.40 |
| long | 19 Sep 2026 80,883.90 | 29 Sep 2026 83,500.00 | 10 | $28.41 |
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 12 ms | With a workaround 1,000 bars in 39 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 15) so the engine trades the way the script says. 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. 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/// © SoftKill21//@version=4strategy(title="random", shorttitle="random", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )UseHAcandles = input(true, title="Use Heikin Ashi Candles in Algo Calculations")//// === /INPUTS ===// === BASE FUNCTIONS ===haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : closehaOpen = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : openhaHigh = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : highhaLow = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : lowlong = haClose > haHigh[1] and haClose > haOpen and haHigh[1] > haHigh[2] //and close > high[3]short = haClose < haOpen and haClose < haLow[1]strategy.entry("long",1,when=long)//strategy.entry("short",0,when=short)strategy.close("long",when=short)//strategy.close_all()