Exciting Update: Version 1.0.6 is now available, introducing Direct Pine Script Mode, Pine Logs Runtime Bridge, Zero-Repaint Linting, Source Maps, Intrabar MFE/MAE Stats, and expanded Pine v5/v6 Transpiler Parity. Read more
Version: 1.0.6

Chart Transforms & Fundamentals

BacktestX lets you transform raw OHLC candles into alternative chart styles like Heikin Ashi via ticker.* constructors in Direct Pine Mode or ctx.ticker.heikinashi() in JavaScript, alongside built-in fundamental/economic request mocks.

Heikin Ashi Transformation

In JavaScript, ctx.ticker.heikinashi(barsArray) converts an OHLC array into smoothed Heikin Ashi bars. In Direct Pine Mode (v1.0.6), pass ticker.heikinashi(syminfo.tickerid) directly to request.security():

JavaScript & Direct Pine Mode
// JavaScript Mode: transform standard bars to Heikin Ashi
const haBars = ctx.ticker.heikinashi(ctx.bars);
const haSma = ctx.ta.sma(haBars.map(b => b.close), 20);
ctx.plot(haSma, { color: '#2962ff' });

// Direct Pine Mode (v1.0.6)
haClose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
plot(ta.sma(haClose, 20), title="HA SMA 20", color=color.blue)

Ticker Builders & Chart-Type Constructors (v1.0.6)

The pine-transpiler runtime wires ticker.* namespaces cleanly for Pine scripts targeting non-standard chart series or custom ticker identifiers (see MTF Ticker Modifiers):

  • ticker.standard(sym) & ticker.new(prefix, ticker, session, adjustment): Standardizes or builds ticker IDs.
  • ticker.heikinashi(sym): Builds a Heikin Ashi ticker identifier backed by ctx.ticker.heikinashi.
  • ticker.renko(...), ticker.kagi(...), and ticker.pointfigure(...): Chart-type constructor helpers for Renko, Kagi, and Point & Figure expressions.

Fundamental & Economic Mock Data

If you run a complex Pine Script that relies on external fundamental earnings reports or macroeconomic data (like US GDP), the engine provides mock generators so code compiles and backtests without errors:

  • ctx.request.financial(symbol, metric, period): Returns a static array of mock fundamental values.
  • ctx.request.economic(country, metric): Returns a static array of mock macroeconomic series.
  • For higher-timeframe OHLC/indicator series, pair with request.security() & request.timeframe_data().