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 price and volume data.
  • Backtesting volume-based strategies by calculating gains from generated actions.
  • Integrating with other n8n workflows 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 along with metadata about signal distribution and potential gains.

Properties

Name Meaning
Strategy Selects the volume trading strategy to apply. Options: Chaikin Money Flow, Ease of Movement, Force Index, Money Flow Index, Negative Volume Index, Volume Weighted Average Price.
OHLCV Data JSON string representing an array of OHLCV data points. Each element is expected to be an array with at least 5 values corresponding to Open, High, Low, Close, and 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 assuming daily intervals.
CMF Period Number specifying the period length for the Chaikin Money Flow calculation (only shown if that strategy is selected). Default: 20
EMV Period Number specifying the period length for the Ease of Movement calculation (only shown if that strategy is selected). Default: 14
Force Index Period Number specifying the period length for the Force Index calculation (only shown if that strategy is selected). Default: 13
MFI Period Number specifying the period length for the Money Flow Index calculation (only shown if that strategy is selected). Default: 14
NVI Period Number specifying the period length for the Negative Volume Index calculation (only shown if that strategy is selected). Default: 1
NVI Start Value Starting value for the Negative Volume Index calculation (only shown if that strategy is selected). Default: 1000
VWAP Period Number specifying the period length for the Volume Weighted Average Price calculation (only shown if that strategy is selected). Default: 14
Options Collection of additional options:
- Return Type: "Actions Only" (BUY/SELL/HOLD) or "With Metadata" (includes detailed analysis).
- Include Gains Calculation: Boolean to calculate gains based on actions (only available when Return Type is "With Metadata").

Output

The node outputs an array of JSON objects, each corresponding to one input item processed. Each output JSON contains:

  • strategy: The chosen strategy identifier.
  • parameters: The parameters used for the strategy calculation (e.g., period lengths).
  • actions: An array of strings representing the trading signals for each data point: "BUY", "SELL", or "HOLD".
  • actionValues: The raw action codes from the underlying library mapped to the above strings.
  • If "With Metadata" return type is selected:
    • metadata: Object summarizing total 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 volume indicator calculations.
  • No external API keys or services are needed.
  • Input data must be provided as JSON strings containing OHLCV arrays and optionally date arrays.
  • No special environment variables or n8n credentials are required.

Troubleshooting

  • Failed to parse OHLCV data: This error occurs if the OHLCV input string is not valid JSON or is not a non-empty array. Ensure the input is correctly formatted JSON representing an array of arrays with OHLCV values.
  • Unsupported strategy: Happens if an invalid strategy option is passed. Verify the strategy parameter matches one of the supported options.
  • Date parsing warnings: If the optional date data cannot be parsed, the node falls back to generating dates based on the current date minus index days. This may affect accuracy if exact dates are important.
  • Gains calculation errors: If enabled, gains calculation might fail due to inconsistent data or internal errors. The node will report the error message in the output but continue processing.
  • To avoid failures stopping the workflow, enable "Continue On Fail" in the node settings.

Links and References

Discussion