Volume Strategy icon

Volume Strategy

Execute volume trading strategies using the indicatorts library

Overview

This node executes various volume-based trading strategies using historical OHLCV (Open, High, Low, Close, Volume) data. It leverages the indicatorts library to analyze volume indicators and generate trading signals such as BUY, SELL, or HOLD. The node supports multiple well-known volume strategies including Chaikin Money Flow, Ease of Movement, Force Index, Money Flow Index, Negative Volume Index, and Volume Weighted Average Price.

Typical use cases include:

  • Automating technical analysis for stock, forex, or cryptocurrency markets based on volume indicators.
  • Generating actionable trading signals from historical market data.
  • Backtesting volume-based trading strategies by analyzing past OHLCV data.
  • Integrating with other nodes to trigger trades or alerts based on strategy outputs.

For example, a user can input OHLCV data for a stock and select the Money Flow Index strategy to receive BUY/SELL/HOLD signals indicating potential entry or exit points.

Properties

Name Meaning
Strategy Select one of the volume trading strategies:
- Chaikin Money Flow Strategy
- Ease of Movement Strategy
- Force Index Strategy
- Money Flow Index Strategy
- Negative Volume Index Strategy
- Volume Weighted Average Price Strategy
OHLCV Data JSON string containing an array of OHLCV data arrays. Each element is expected to be an array representing [open, high, low, close, volume].
Date Data JSON string containing an array of dates corresponding to the OHLCV data points. Optional; if not provided, dates are generated based on current date minus index days.
CMF Period Number specifying the period for Chaikin Money Flow calculation (only shown if that strategy is selected). Default: 20
EMV Period Number specifying the period for Ease of Movement calculation (only shown if that strategy is selected). Default: 14
Force Index Period Number specifying the period for Force Index calculation (only shown if that strategy is selected). Default: 13
MFI Period Number specifying the period for Money Flow Index calculation (only shown if that strategy is selected). Default: 14
NVI Period Number specifying the period for Negative Volume Index calculation (only shown if that strategy is selected). Default: 1
NVI Start Value Starting value for Negative Volume Index calculation (only shown if that strategy is selected). Default: 1000
VWAP Period Number specifying the period for Volume Weighted Average Price calculation (only shown if that strategy is selected). Default: 14
Options > Return Type Choose output format:
- Actions Only: returns only BUY/SELL/HOLD actions
- With Metadata: returns actions plus additional metadata and analysis
Options > Include Gains Calculation Boolean flag to calculate and include strategy gains based on actions (only available when "With Metadata" return type is selected). Default: false

Output

The node outputs an array of JSON objects, each containing:

  • strategy: The selected strategy identifier.
  • parameters: The parameters used for the strategy calculation (e.g., periods).
  • actions: An array of strings representing trading signals for each data point: "BUY", "SELL", or "HOLD".
  • actionValues: The raw action values as returned by the underlying indicator library (numeric or enum values mapped to actions).
  • If "With Metadata" return type is selected:
    • metadata: Object containing summary statistics such as total number of actions, counts and percentages of buy/sell/hold signals, input data length, and timestamp of calculation.
    • If gains calculation is enabled:
      • gains: Array of cumulative gain values calculated from the closing prices and actions.
      • totalGain: Final gain value after applying all actions.
    • If gains calculation fails, gainsError contains the error message.

The node does not output binary data.

Dependencies

  • Requires the indicatorts npm library for calculating volume-based indicators and strategies.
  • No external API keys or services are required.
  • Input data must be provided as JSON strings containing OHLCV arrays and optionally date arrays.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Failed to parse OHLCV data: This error occurs if the OHLCV input string is not valid JSON or is not an array. Ensure the input is a correctly formatted JSON string representing an array of OHLCV arrays.
  • OHLCV data must be a non-empty array: The node requires at least one OHLCV data point to operate. Provide valid historical data.
  • Unsupported strategy: Occurs if an invalid or unsupported strategy name is provided. Select one of the supported strategies listed in the properties.
  • Failed to parse date data: If the optional date data cannot be parsed, the node will fallback to generating dates based on the current date minus the index. This is a warning, not an error.
  • Gains calculation errors: If enabled, gains calculation may fail due to inconsistent data or logic errors. The error message will be included in the output under gainsError.

To resolve issues:

  • Validate JSON inputs before passing them to the node.
  • Use supported strategy names exactly as specified.
  • Provide consistent OHLCV and date arrays of matching lengths.
  • Disable gains calculation if it causes errors.

Links and References

Discussion