Volatility Strategy icon

Volatility Strategy

Execute volatility trading strategies using the indicatorts library

Overview

This node implements volatility-based trading strategies using historical OHLCV (Open, High, Low, Close, Volume) data. It supports three different strategies based on popular volatility indicators: Acceleration Bands, Bollinger Bands, and Projection Oscillator. The node analyzes the input market data and generates trading signals such as BUY, SELL, or HOLD according to the selected strategy.

Typical use cases include:

  • Automating technical analysis for trading decisions.
  • Backtesting volatility strategies on historical price data.
  • Generating actionable signals for algorithmic trading systems.

For example, a trader can input daily OHLCV data of a stock and select the Bollinger Bands strategy to receive buy/sell signals based on price volatility patterns.

Properties

Name Meaning
Strategy Selects the volatility strategy to apply:
- Acceleration Bands Strategy
- Bollinger Bands Strategy
- Projection Oscillator Strategy
OHLCV Data JSON string representing an array of OHLCV data points. Each element is expected to be an array with at least 4 values (open, high, low, close) and optionally volume.
Date Data Optional JSON string containing an array of dates corresponding to the OHLCV data points. If omitted or invalid, the node uses index-based dates counting backward from the current date.
AB Period Period length for Acceleration Bands calculation (only shown if Acceleration Bands strategy is selected). Default is 20.
AB Multiplier Multiplier factor for Acceleration Bands calculation (only for Acceleration Bands strategy). Default is 4.
BB Period Period length for Bollinger Bands calculation (only shown if Bollinger Bands strategy is selected). Default is 20.
PO Period Period length for Projection Oscillator calculation (only shown if Projection Oscillator strategy is selected). Default is 14.
PO Smooth Smoothing period for Projection Oscillator calculation (only for Projection Oscillator strategy). Default is 3.
Options Collection of additional options:
• Return Type:
 – Actions Only: returns only BUY/SELL/HOLD actions.
 – With Metadata: returns actions plus detailed metadata and analysis.
• Include Gains Calculation (only if "With Metadata" is selected): whether to calculate and include gains based on the generated actions.

Output

The node outputs an array with one item per input. Each output item contains a json object structured as follows:

  • strategy: The chosen strategy identifier.
  • parameters: The parameters used for the strategy calculation (periods, multipliers, smoothing).
  • actions: An array of strings representing the trading signals for each data point: "BUY", "SELL", or "HOLD".
  • actionValues: The raw action codes returned by the underlying indicator library (numeric internally mapped to actions).
  • If "With Metadata" return type is selected:
    • metadata: Object containing summary statistics:
      • totalActions: Total number of signals generated.
      • buySignals, sellSignals, holdSignals: Counts of each signal type.
      • buyPercentage, sellPercentage, holdPercentage: Percentages of each signal type.
      • inputLength: Number of OHLCV data points processed.
      • calculationTimestamp: ISO timestamp when the calculation was performed.
    • If gains calculation is enabled:
      • gains: Array of cumulative gain values calculated from the closing prices and actions.
      • totalGain: Final total gain value.
    • If gains calculation fails, gainsError contains the error message.

The node does not output binary data.

Dependencies

  • Uses the indicatorts library for implementing the volatility strategies and calculating signals.
  • Requires valid OHLCV data input in JSON format.
  • No external API keys or services are needed.
  • Runs entirely within n8n environment.

Troubleshooting

  • Failed to parse OHLCV data: This error occurs if the provided OHLCV JSON string is invalid or empty. Ensure the input is a correctly formatted JSON array of arrays with OHLCV values.
  • OHLCV data must be a non-empty array: Indicates that the parsed OHLCV data is empty or not an array. Provide valid historical price data.
  • Unsupported strategy: Happens if an unknown strategy value is passed. Use one of the supported strategies: Acceleration Bands, Bollinger Bands, or Projection Oscillator.
  • Failed to parse date data: If the optional date array is invalid, the node falls back to generating dates based on the current date minus index offsets.
  • Gains calculation errors: If enabled, gain calculations may fail due to inconsistent data; the error message will be included in the output under gainsError.

To resolve issues:

  • Validate all JSON inputs before passing them to the node.
  • Confirm that the OHLCV data includes at least open, high, low, and close prices.
  • Use supported strategy names exactly as specified.
  • When enabling gains calculation, ensure the closing prices array is consistent and complete.

Links and References

Discussion