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:
- Traders wanting to automate signal generation based on popular momentum indicators.
- Analysts backtesting different momentum strategies on historical market data.
- Integrating strategy signals into larger workflows for portfolio management or alerting.
Practical example:
You provide a JSON array of OHLCV data from your exchange or data provider, select the "RSI2 Strategy," and receive a sequence of BUY/SELL/HOLD signals indicating when the asset is deeply oversold or overbought according to the 2-period RSI indicator.
Properties
| Name | Meaning |
|---|---|
| Strategy | Select the momentum strategy to apply. Options: - 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 data point is expected to be an array with at least 5 elements representing [open, high, low, close, 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 current date. |
| AO Fast Period | Fast period parameter for Awesome Oscillator calculation (only shown if Awesome Oscillator Strategy selected). Default: 5 |
| AO Slow Period | Slow period parameter for Awesome Oscillator calculation (only shown if Awesome Oscillator Strategy selected). Default: 34 |
| Ichimoku Short Period | Short period for Ichimoku Cloud calculation (only shown if Ichimoku Cloud Strategy selected). Default: 9 |
| Ichimoku Medium Period | Medium period for Ichimoku Cloud calculation (only shown if Ichimoku Cloud Strategy selected). Default: 26 |
| Ichimoku Long Period | Long period for Ichimoku Cloud calculation (only shown if Ichimoku Cloud Strategy selected). Default: 52 |
| Ichimoku Close Period | Close period for Ichimoku Cloud calculation (only shown if Ichimoku Cloud Strategy selected). Default: 3 |
| Stochastic K Period | K period for Stochastic Oscillator calculation (only shown if Stochastic Oscillator Strategy selected). Default: 14 |
| Stochastic D Period | D period for Stochastic Oscillator calculation (only shown if Stochastic Oscillator Strategy selected). Default: 3 |
| Williams %R Period | Period for Williams %R calculation (only shown if Williams %R Strategy selected). Default: 14 |
| Options.Return Type | Choose output format: - Actions Only: Return only the strategy actions (BUY/SELL/HOLD) - With Metadata: Return actions plus additional metadata and analysis |
| Options.Include Gains Calculation | When "With Metadata" is selected, optionally calculate and include strategy gains based on the generated actions (boolean). Default: false |
Output
The node outputs an array with one item per input item. Each output item contains a json object structured as follows:
strategy: The chosen strategy identifier string.parameters: Object with parameters used for the strategy (e.g., periods).actions: Array of strings representing the trading signals for each data point:"BUY","SELL", or"HOLD".actionValues: Raw action values as returned by the underlying library (numeric or enum values).- If
Options.Return Typeis set to"metadata":metadata: 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 action type.inputLength: Number of OHLCV data points processed.calculationTimestamp: ISO timestamp of when the calculation was performed.
- If
Options.Include Gains Calculationis true: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.
No binary data output is produced by this node.
Dependencies
- Requires the
indicatortsnpm library for implementing the momentum strategies. - Uses n8n's standard node framework and error handling.
- Input data must be provided as JSON strings representing arrays of OHLCV data and optionally dates.
- No external API keys or services are required.
Troubleshooting
Failed to parse OHLCV data:
Error occurs if the OHLCV JSON string is invalid or not an array.
Resolution: Ensure the input JSON string is correctly formatted and represents a non-empty array of OHLCV data points.Unsupported strategy:
If a strategy value outside the supported list is provided, the node throws an error.
Resolution: Select one of the predefined strategies in the node 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 is logged as a warning but does not stop execution.Gains calculation errors:
If enabled, gains calculation may fail due to inconsistent data or internal errors. The error message is included in the output undergainsError.Empty or missing OHLCV data:
The node requires a non-empty array of OHLCV data; otherwise, it will throw an error.Continue On Fail behavior:
If enabled, the node will output error messages in the JSON instead of stopping execution on errors.
Links and References
- Momentum Indicators Documentation — General info on momentum indicators.
- Awesome Oscillator Explanation
- Ichimoku Cloud Overview
- Relative Strength Index (RSI)
- Stochastic Oscillator Guide
- Williams %R Indicator
- Indicatorts Library GitHub — Source code for the underlying strategy implementations.