NEWCard payments are live · from $18/month, USDT also acceptedSee plans
COINPRED / STRATEGY LIBRARY

BTC Heikin Ashi ROC Percentile: Smoothed HA-close ROC uses 75/25 percentile kill lines; crossing the lower line opens a long and closes a short, the upper line the reverse

jensenvilhelm's open-source momentum script (MPL 2.0): "Heikin Ashi ROC Percentile Strategy". It uses a Heikin Ashi close (ohlc4), a 100-period ROC of that close's 100 SMA, then 75/25 percentile kill lines from a 10-bar window of 50-bar ROC highs and lows. Crossing the lower line opens a long and closes a short; the upper line does the reverse. The stop-loss input is never used in orders. The author's chart is BITSTAMP:BTCUSD daily. Rules follow the source; this page invents no backtest figures.

Illustrated guidesPine Script®Included with monthly & annual plans
← All strategies
jensenvilhelm · 1.0 · 2026-12-02 · Trend following
BTC Heikin Ashi ROC Percentile: Smoothed HA-close ROC uses 75/25 percentile kill lines; crossing the lower line opens a long and closes a short, the upper line the reverse

The idea

This is jensenvilhelm's open-source script, published as "Heikin Ashi ROC Percentile Strategy". It does not overlay on the price chart (overlay=false). Instead it plots a smoothed rate of change in a separate pane and uses percentile kill lines to flip direction. A cross of the lower line opens a long and closes a short; a cross of the upper line opens a short and closes a long. The same crosses drive both sides.

The author's published chart is BITSTAMP:BTCUSD on the daily timeframe, so this page lists it as a BTC strategy. The script does not hard-code a symbol. There is an input named "Stop Loss (%)" with a default of 2, but no entry or exit call uses it. The start date is hard-coded in the source; it is not an input.

jensenvilhelm's Heikin Ashi ROC percentile strategy on the BITSTAMP:BTCUSD daily chart
Author chart: BITSTAMP:BTCUSD, daily, from the script's publication page. The image shows the ROC, its highs and lows, and the kill lines. It is only a visual example, not a performance record.

How the lines are built

  • The Heikin Ashi close, haClose, is the usual ohlc4 average of open, high, low, and close. The script also computes a Heikin Ashi open, haOpen, but that open never feeds the ROC. Only haClose is used later.
  • haClose is first smoothed with an SMA of rocLength (default 100). The script then takes ta.roc of that SMA with the same length, and that series is roc.
  • rocHigh is the highest roc over the last 50 bars, and rocLow is the lowest over those 50 bars. Those two lookbacks are hard-coded.
  • The upper kill line is ta.percentile_linear_interpolation(rocHigh, 10, 75), the 75th percentile of the last 10 values of that 50-bar ROC high. The lower kill line is the 25th percentile of rocLow. These are not percentiles of the raw roc series itself.
  • A midline (default 0) is also plotted. The plot title for roc in the source is "RSI"; that is only a label, and the calculation is still ROC.
  • The start date is hard-coded as timestamp("2015 03 03"). Orders are allowed only when time >= startDate.

Entry rules

  • The script trades both sides, and a signal on one side also flattens the other.
  • A long is opened when roc crosses above the lower kill line (ta.crossover(roc, lowerKillLine)) and the start date has been reached.
  • A short is opened when roc crosses below the upper kill line (ta.crossunder(roc, upperKillLine)) and the start date has been reached.
  • The source runs the tests in this order: enter long, close long, enter short, close short. On a cross under the upper line, an open long is closed before the short is entered. On a cross over the lower line, the long entry is submitted first (if a short is open, the tester will usually reverse it) and then the short is closed.

Exits and position size

  • The long exit is the same condition as the short entry: roc crossing under the upper kill line. The short exit is the same as the long entry: roc crossing over the lower kill line. The default path is a flip between the two lines, not a separate exit rule.
  • The "Stop Loss (%)" input, default 2, never appears in strategy.entry, strategy.close, or strategy.exit, so it does not place a stop.
  • The strategy() call does not set default_qty_type, initial capital, or commission, so those follow TradingView tester defaults, or whatever you set in the tester.
  • The script does not hard-code order size or margin. Check the tester's size and fees when you change symbol or timeframe.

Inputs (defaults in the source)

InputDefaultWhat it does
Midline0Pane midline; plotted only, not used in entries or exits
roc Length100Length of the SMA of the Heikin Ashi close, and of the ROC
Stop Loss (%)2Present as an input, but the source never uses it to place a stop
Start date2015-03-03 (hard-coded)Not an input; orders are allowed only after this date
rocHigh / rocLow lookback50 (hard-coded)Used to build the highest and lowest ROC
Percentile window / upper / lower10 / 75 / 25 (hard-coded)Percentiles of the high and low ROC series that become the kill lines

Caveats

  • This is a reversing rule set: the same cross that exits one side also opens the other. In chop, it can flip back and forth.
  • The stop-loss input is not wired into any order. Seeing a 2% default in the inputs does not mean a 2% stop is in effect.
  • The kill lines are not 75th and 25th percentiles of raw ROC. They are percentiles of a 10-bar window of 50-bar highs and lows. Read those lines from the source when you compare them with the chart.
  • haOpen is calculated and then unused. The ROC uses ohlc4 as the Heikin Ashi close. It is not a full Heikin Ashi open-and-close system.
  • The start date is hard-coded to 3 March 2015. The author showed daily BTC; the 100 and 50 lengths may not fit a much shorter timeframe.

Install it on TradingView

  1. Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
  2. Open the symbol and timeframe you want in TradingView, open the Pine Editor, paste the source, and add it to the chart. The strategy will appear in a separate pane.
  3. Start with the defaults so you can see the crosses and reversals, then change the ROC length. If you want a stop, you have to add one yourself; the existing stop input does nothing.
  4. The source does not set order size or commission; those follow the tester defaults or the values you set there. Live order routing has to be set separately.
  5. Crypto trades around the clock. The tester's timezone and session settings may differ from your venue by several hours.

About backtest figures

Source, license, and version

  • Source: https://www.tradingview.com/script/h1pOrB3i-Heikin-Ashi-ROC-Percentile-Strategy/
  • Author: jensenvilhelm (header © jensenvilhelm)
  • License: Mozilla Public License 2.0. Redistribution must keep the original copyright and license notices; if you modify the source file, the modified file must remain under MPL 2.0. Coinpred ships the unmodified source.
  • Version: 1.0 in the publication record and pine-facade. scriptAccess is open_no_auth.

Source, license and version

Licensed under MPL 2.0 per the source header, © jensenvilhelm. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified source.

View original source ↗

Check the script license and your TradingView account features. Historical results do not guarantee future performance.

More strategies

All strategies →