Trend Strategy icon

Trend Strategy

Execute trend trading strategies using the indicatorts library

Overview

This node executes various trend trading strategies on financial OHLCV (Open, High, Low, Close, Volume) data using the indicatorts library. It analyzes historical price and volume data to generate trading signals such as BUY, SELL, or HOLD based on selected technical indicators.

Common scenarios for this node include:

  • Automating technical analysis in trading workflows.
  • Backtesting different trend strategies on historical market data.
  • Generating actionable trade signals for algorithmic trading systems.
  • Enhancing decision-making by combining multiple indicator-based strategies.

For example, a user can input OHLCV data from a cryptocurrency exchange and select the MACD strategy to receive buy/sell signals based on Moving Average Convergence Divergence trends.

Properties

Name Meaning
Strategy The trend strategy to apply. Options: Absolute Price Oscillator, Aroon, Balance of Power, Chande Forecast Oscillator, KDJ, MACD, Parabolic SAR, Typical Price, Vortex, VWMA.
OHLCV Data JSON string containing an array of OHLCV data points. Each data point is expected to be an array with at least open, high, low, close, and optionally volume values.
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.
APO Fast Period Fast period parameter for Absolute Price Oscillator strategy (only shown if that strategy is selected).
APO Slow Period Slow period parameter for Absolute Price Oscillator strategy.
Aroon Period Period parameter for Aroon strategy.
KDJ R Period R period parameter for KDJ strategy.
KDJ K Period K period parameter for KDJ strategy.
KDJ D Period D period parameter for KDJ strategy.
MACD Fast Period Fast period parameter for MACD strategy.
MACD Slow Period Slow period parameter for MACD strategy.
MACD Signal Period Signal period parameter for MACD strategy.
PSAR Step Step value parameter for Parabolic SAR strategy.
PSAR Max Maximum value parameter for Parabolic SAR strategy.
Vortex Period Period parameter for Vortex strategy.
VWMA Period Period parameter for Volume Weighted Moving Average strategy.
Options Collection of additional options:
- Return Type: "Actions Only" (BUY/SELL/HOLD) or "With Metadata" (includes detailed metadata and analysis).
- Include Gains Calculation: Whether to calculate gains based on actions (only if Return Type is "With Metadata").

Output

The node outputs an array of JSON objects, each representing the result of applying the selected strategy to the input data. Each output object contains:

  • strategy: The name of the applied strategy.
  • parameters: The parameters used for the strategy calculation.
  • actions: An array of action strings ("BUY", "SELL", "HOLD") corresponding to each data point.
  • actionValues: The raw action values as returned by the underlying indicator library (numeric or enum values).
  • If "With Metadata" return type is selected:
    • metadata: Object containing summary statistics such as total actions, counts and percentages of buy/sell/hold signals, input length, and timestamp of calculation.
    • gains (optional): Array of calculated gains over time based on the actions.
    • totalGain (optional): Final cumulative gain value.
    • gainsError (optional): Error message if gains calculation failed.

The node does not output binary data.

Dependencies

  • Requires the indicatorts library for technical indicator calculations.
  • Input data must be provided as JSON strings containing OHLCV arrays and optionally date arrays.
  • No external API keys or credentials are required.
  • Runs fully within n8n environment without external service dependencies.

Troubleshooting

  • Failed to parse OHLCV data: Ensure the OHLCV input is a valid JSON string representing a non-empty array of arrays with correct numeric values.
  • Unsupported strategy error: Verify that the selected strategy matches one of the supported options.
  • Empty or invalid date data: If date data is malformed or missing, the node defaults to generating dates based on current date minus index days.
  • Gains calculation errors: If enabled, gains calculation may fail due to inconsistent action sequences or data issues; check input data integrity.
  • General JSON parsing errors: Confirm all JSON inputs are properly formatted and escaped.

To resolve errors, validate input JSON strings carefully and ensure parameters correspond to the chosen strategy.

Links and References

Discussion