Synthetic Price Action Generator
Jan 8, 2022

The Synthetic Price Action Generator tool creates a fully customizable environment of randomized, synthetic price candles designed specifically for developers to test and troubleshoot technical indicators. It simulates realistic market fractals and price movement patterns without reflecting actual ticker data, providing a controlled sandbox for evaluating algorithm performance.
Usage
The Usage section focuses on how developers can use this generator to stress-test their scripts. By replacing standard OHLC variables with the synthetic outputs of this generator, users can observe how their indicators react to varying levels of volatility, unusual wick lengths, or specific price ranges.
Examples of usage include:
- Indicator Initialization: Use keyboard shortcuts (ALT + SHIFT + Left Arrow) to jump to the start of the chart history and verify if an indicator's recursive filters (IIR) initialize correctly at
bar_index == 0. - Volatility Testing: Adjust the "Perturbate high/low Volatility" setting to generate massive wicks, allowing you to see if your trading logic "flakes out" during extreme price fluctuations.
- Pattern Recognition: Use the "Manipulate Price Action" setting and arrow keys to cycle through different synthetic waveforms to practice manual pattern recognition.
Details
The script is inspired by the work of John F. Ehlers but utilizes a unique "mutagenic" approach in Pine Script to generate candle formations. It employs three internal Exponential Moving Averages (EMAs) to manage the randomness and maintain the relationship between the synthetic High, Low, and Close values.
The generator produces a tuple containing synthetic Open, High, Low, and Close values. Developers can copy the core spg() function into their own scripts and assign these values to local variables to "shadow" the built-in price data. This allows for a completely artificial environment that still exhibits the mathematical properties of fractal symmetry found in real financial markets.
Settings
SPAG Close Controls
- Initial Value: Sets the starting price at the first bar. Over time, the generator gravitates back toward a baseline of 50.
- Manipulate Price Action: Acts as a randomness reset. Changing this value cycles the generator through entirely different synthetic waveforms.
- Perturbate close Randomness: Controls the randomness of the closing price. Values near the limits will result in smoother, less random movements.
Additional SPAG Controls
- Price Multiplier: Scales the overall price action. Using a negative value transforms the output into an oscillator centered around zero.
- Perturbate high/low Volatility: Adjusts the average length of candle wicks.
- Variability of open/close: Determines the relationship between the current Open and the previous Close. A value of 0 makes the Open exactly equal to the previous Close.
FAQ
How do I use this to test my own indicator?
You can copy the spg() function into your script and assign its outputs to variables named open, high, low, and close. This will override the chart data for your calculations.
Can I use this for actual trading signals? No, this script produces "fake" price action and does not reflect market reality. It is strictly a developer utility for testing purposes.
How do I access Synthetic Price Action Generator? 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.