Overview
This node executes various momentum trading strategies on financial OHLCV (Open, High, Low, Close, Volume) data using the indicatorts library. It supports multiple well-known technical analysis strategies such as Awesome Oscillator, Ichimoku Cloud, RSI2, Stochastic Oscillator, and Williams %R. The node analyzes historical price data to generate trading signals (BUY, SELL, HOLD), which can be used for automated trading decisions or further analysis.
Common scenarios where this node is beneficial include:
- Backtesting trading strategies on historical market data.
- Generating actionable trading signals based on momentum indicators.
- Integrating with other nodes to automate trading workflows.
- Analyzing market trends and momentum for decision support.
Practical example: A user provides OHLCV data from a cryptocurrency exchange and selects the RSI2 strategy to identify deeply oversold or overbought conditions, receiving BUY/SELL/HOLD signals to guide trading actions.
Properties
| Name | Meaning |
|---|---|
| Strategy | Select one of the following momentum strategies: - Awesome Oscillator Strategy - Ichimoku Cloud Strategy - RSI2 Strategy - Stochastic Oscillator Strategy - Williams %R Strategy |
| OHLCV Data | JSON string containing an array of OHLCV data points. Each element should 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 index and current date. |
| AO Fast Period | Fast period parameter for Awesome Oscillator calculation (only shown when Awesome Oscillator Strategy is selected). Default: 5 |
| AO Slow Period | Slow period parameter for Awesome Oscillator calculation (only shown when Awesome Oscillator Strategy is selected). Default: 34 |
| Ichimoku Short Period | Short period parameter for Ichimoku Cloud calculation (only shown when Ichimoku Cloud Strategy is selected). Default: 9 |
| Ichimoku Medium Period | Medium period parameter for Ichimoku Cloud calculation (only shown when Ichimoku Cloud Strategy is selected). Default: 26 |
| Ichimoku Long Period | Long period parameter for Ichimoku Cloud calculation (only shown when Ichimoku Cloud Strategy is selected). Default: 52 |
| Ichimoku Close Period | Close period parameter for Ichimoku Cloud calculation (only shown when Ichimoku Cloud Strategy is selected). Default: 3 |
| Stochastic K Period | K period parameter for Stochastic Oscillator calculation (only shown when Stochastic Oscillator Strategy is selected). Default: 14 |
| Stochastic D Period | D period parameter for Stochastic Oscillator calculation (only shown when Stochastic Oscillator Strategy is selected). Default: 3 |
| Williams %R Period | Period parameter for Williams %R calculation (only shown when Williams %R Strategy is selected). Default: 14 |
| Options > Return Type | Choose output format: - Actions Only: Returns only the strategy actions (BUY/SELL/HOLD) - With Metadata: Returns actions along with 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 with one item per input. Each output item contains a JSON object with the following structure:
strategy: The name of the selected strategy.parameters: The parameters used for the strategy calculation (e.g., periods).actions: An array of strings representing the trading signals for each data point. Possible values:"BUY","SELL","HOLD".actionValues: The raw action values as returned by the underlying library (numeric or enum values mapped internally).- If "With Metadata" return type is selected:
metadata: An object containing summary statistics:totalActions: Total number of actions generated.buySignals: Count of BUY signals.sellSignals: Count of SELL signals.holdSignals: Count of HOLD signals.buyPercentage,sellPercentage,holdPercentage: Percentages of each signal type.inputLength: Number of input OHLCV data points.calculationTimestamp: ISO timestamp of 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,
gainsErrorcontains the error message.
The node does not output binary data.
Dependencies
- Requires the
indicatortslibrary for technical indicator calculations. - Uses n8n's core workflow utilities for error handling and input/output management.
- Input data must be provided as JSON strings representing arrays of OHLCV data and optionally dates.
- No external API keys or credentials are required.
- No special environment variables needed.
Troubleshooting
- Failed to parse OHLCV data: This error occurs if the OHLCV input string is not valid JSON or 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 the selected strategy is not recognized. Verify that the strategy name matches one of the supported options.
- Failed to parse date data: If the optional date data cannot be parsed, the node falls back to generating dates based on the current date and index. This is a warning, not a fatal error.
- Gains calculation errors: If enabled, gains calculation may fail due to inconsistent data or internal errors. The error message will be included in the output under
gainsError.
To resolve issues:
- Validate all JSON inputs before running the node.
- Use consistent and complete OHLCV data.
- Select supported strategies and provide required parameters.
- Enable "Continue On Fail" in the node settings to handle errors gracefully during batch processing.