Candle Color
SignalUtility
The Candle Color node inspects each bar's open and close prices and outputs 1 when the bar matches the target color, or 0 when it doesn't. Connect it to a Logic node to gate entries, exits, or any condition on candle direction.
How It Works
isGreen=close[i] >= open[i]
value (green)=isGreen ? 1 : 0
value (red)=isGreen ? 0 : 1
A doji (close == open) is treated as green. The source node must supply OHLC data (fields o and c).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| color | 'green' | 'red' | 'green' | Target candle direction. Output is 1 when the bar matches this direction. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Input | ||
| input | OHLCV node | Must supply o (open) and c (close) arrays of equal length. |
| Outputs | ||
| values | (1 | 0)[] | Per-bar signal: 1 when bar color matches the parameter, 0 otherwise. |
| timestamps | number[] | UNIX ms timestamps aligned 1-to-1 with values. |
| lastCandleColor | 'green' | 'red' | null | Actual color of the most recent completed candle, regardless of the color parameter. |
Use Cases
Trend confirmation filter
AND-combine a moving average crossover signal with Candle Color (green) to only take long entries when the close bar is bullish. This filters out crossovers that occur on bearish bars, improving signal quality.
Consecutive candle counter
Connect Candle Color into a Rolling Fn node with func = sum and period = 3. The result equals the number of green (or red) bars in the last 3 candles, enabling pattern-based strategies.