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.

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)
| Input | Default | What it does |
|---|---|---|
| Midline | 0 | Pane midline; plotted only, not used in entries or exits |
| roc Length | 100 | Length of the SMA of the Heikin Ashi close, and of the ROC |
| Stop Loss (%) | 2 | Present as an input, but the source never uses it to place a stop |
| Start date | 2015-03-03 (hard-coded) | Not an input; orders are allowed only after this date |
| rocHigh / rocLow lookback | 50 (hard-coded) | Used to build the highest and lowest ROC |
| Percentile window / upper / lower | 10 / 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
- Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
- 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.
- 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.
- 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.
- 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.



