Backtest Adapter
Feb 10, 2023

The Backtest Adapter tool enables interactive backtesting for external indicators by bridging signal streams directly into the TradingView Strategy Tester framework without requiring manual code conversion.
Usage
The Usage section describes how the script can be used, focusing on the connection between indicator outputs and strategy execution.
To use the adapter, the user must have both the Backtest Adapter and a compatible indicator—such as the "Machine Learning: Lorentzian Classification" script—active on the same chart. The primary workflow involves linking the output of the indicator to the input of the adapter:
- Open the Backtest Adapter settings menu.
- Locate the Source setting and select the signal stream from the target indicator (e.g., "Lorentzian Classification: Backtest Stream").
- Once linked, the TradingView Strategy Tester will automatically calculate performance metrics, drawdowns, and trade history based on the indicator's logic.
This setup allows for rapid iteration of indicator parameters while viewing real-time strategy performance metrics.
Details
The Backtest Adapter functions as a bridge between an "indicator" (study) and a "strategy." It interprets specific integer values from a source indicator to trigger strategy orders. The script is programmed to recognize the following signal mapping:
- 1: Triggers a Long Entry.
- 2: Triggers a Long Exit (or reversal to Short if configured).
- -1: Triggers a Short Entry.
- -2: Triggers a Short Exit (or reversal to Long if configured).
By utilizing the input.source variable, the adapter can read these values directly from the plot outputs of other scripts on the chart. This modular approach allows users to maintain the visual clarity of an indicator while gaining the analytical power of the Strategy Tester.
Settings
The settings are divided into groups to manage the execution window and data input:
Backtest Time Period
- Begin Backtest at Start Date: A toggle to enable or disable a specific starting point for the backtest calculation.
- Start Date: Sets the specific day, month, and year for the strategy to begin processing signals.
General Settings
- Source: The most critical setting, used to select the external indicator's output stream that provides the entry and exit signals.
FAQ
How do I connect the adapter to my indicator? Open the Backtest Adapter settings, go to the "Source" dropdown, and select the specific output stream from your indicator (e.g., "Backtest Stream"). Ensure both scripts are on the chart.
Why are no trades appearing in the Strategy Tester? Ensure that the "Source" is correctly set to an indicator output that provides the values 1, 2, -1, or -2. Also, verify that the "Start Date" is set to a time before the signals occur on the chart.
How can I access the Backtest Adapter? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.