Use this file to discover all available pages before exploring further.
ta4j can serialize indicators, rules, and strategies to JSON. This lets you persist strategies to a database, share them as configuration files, or send them to Python or TypeScript consumers.
Pass the BarSeries and the JSON string to the static fromJson methods:
import org.ta4j.core.Indicator;import org.ta4j.core.Strategy;// Restore an indicatorIndicator<?> restoredRsi = Indicator.fromJson(series, rsiJson);// Restore a strategyStrategy restoredStrategy = Strategy.fromJson(series, strategyJson);// Use the restored strategy just like the originalTradingRecord record = new BarSeriesManager(series).run(restoredStrategy);
The BarSeries argument anchors the restored objects to price data. Indicators recalculate lazily as they do when created normally.
Bar data, the NumFactory, and the BarBuilderFactory configuration are preserved across the round-trip.
ConcurrentBarSeries reinitialises its internal locks after deserialization and recreates the trade bar builder lazily.
Builder state set directly on the builder (for example, a custom time period) must be re-applied after deserialization unless it was configured through the factory.
Export a strategy as JSON and share it with a colleague or publish it to a repository. The recipient only needs a BarSeries to instantiate it.
Cross-platform integration
The JSON output is plain text and follows a self-describing structure. A Python or TypeScript consumer can parse it to understand what indicators and rules a strategy uses, even without running the Java backtest engine.This is useful for building trading dashboards that display strategy configuration, or for pipelines that generate strategy variants and pass them back to the Java executor.
Live trading
Restore serialized strategies on service restart.
Parallel backtesting
Generate and persist large numbers of strategy variants.