← Back to BlogJune 28, 2026Tutorial

Advanced Pipeline: Mean Reversion with Z-Score and RSI

In this advanced tutorial, you'll build a mean-reversion check for one asset. The Z-Score measures how far today's price sits from its own recent average, RSI measures momentum, and an Alert node reports when the Z-Score drops below your threshold.

PIPELINE FLOW

Symbol→Price Feed→Z-Score→Alert

RSI and Chart nodes sit beside the Z-Score to show momentum and the price history.

What Is Mean Reversion?

Mean reversion assumes that prices tend to return toward their average over time. A Z-Score below -2 means the price is unusually low against its own recent history; above +2 means unusually high. RSI below 30 is read as oversold, above 70 as overbought. Neither is a guarantee: the pipeline only shows where the asset stands.

Step 1: Add Symbol and Price Feed

  1. Open /terminal/pipeline.
  2. Drag a Symbol node onto the canvas and set its ticker to AAPL.
  3. Drag a Price Feed node and connect Symbol's output to its input.

Step 2: Add Z-Score

The Z-Score compares the log price with its rolling mean and standard deviation over the window.

  1. Drag a Z-Score node onto the canvas.
  2. Connect Price Feed's Price Series output to Z-Score's input.
  3. Keep the Window at 252 days (about one trading year).
// Z-Score (window N)
z = (log price - rolling mean of log price) / rolling std dev

Step 3: Add RSI and a Chart

  1. Drag an RSI (Pro node) onto the canvas and connect Price Feed's Price Series to it.
  2. Keep Period at 14 (the standard).
  3. Drag a Chart node. Connect Price Feed's Price Series to Main Series.
  4. Connect the RSI node's RSI Series output to an overlay. The chart draws it in a panel below the price.

Step 4: Add an Alert

  1. Drag an Alert node onto the canvas.
  2. Connect Z-Score's Z-Score output (the latest value) to the Alert's Value input.
  3. Set Trigger when to Below threshold and Threshold to -2.

Step 5: Run and Read the Result

  1. Click ▶ Run.
  2. The Z-Score node shows the latest value. The Alert shows Triggered when the value is below -2, and Watching otherwise.
  3. The Alert only reports the state inside the editor. It does not send notifications, so check the pipeline when you want an update.

TIP: Check the Forecast Before You Trust a Signal

Add a Forecast node to the Price Series and connect its Forecast output to the chart. The Skill vs No Change output shows how the chosen model did against the "no change" forecast on this asset's own past. If skill is near zero, the model has no edge here.

Tuning Your Strategy

  • Shorten the Z-Score window (e.g., 60) to react to shorter swings, at the cost of more noise.
  • Combine signals with a Weighted Average node: connect RSI and Z-Score to its inputs and display the result.
  • Compare with a reference using Compare to Reference, for example against a fair value or a target price, to label the price as Undervalued or Overvalued within a tolerance band.
// Pipeline nodes used in this tutorial
[
{ "type": "symbolInput", "data": { "symbol": "AAPL" } },
{ "type": "priceFeed", "data": {} },
{ "type": "zScore", "data": { "window": 252 } },
{ "type": "rsiIndicator", "data": { "period": 14 } },
{ "type": "chartOutput", "data": {} },
{ "type": "alertOutput", "data": { "condition": "below", "threshold": -2 } }
]

Check the complete Pipeline Node Reference for all 21 node types.