Skip to content

Strategy guide

Build a mean-reversion strategy with an AI agent

A mean-reversion strategy tests whether price has moved far enough from a defined reference to justify watching for a move back toward it. With Fensory MCP, a connected agent can calculate that distance from completed candles, inspect the account and prepare a bounded perpetual-futures order for review.

Mean reversion is a hypothesis, not a property every market obeys. Academic evidence changes across assets and periods, and a strong trend can keep moving away from the reference. The current Fensory workflow is client-run and does not imply a hosted recurring loop, a backtest or a predicted return. Fensory is not available to US persons.

Copy this prompt

Use the Fensory tools to assess a BTC perpetual-futures mean-reversion rule. Stay read-only first. Call get_perps_status, get_market and get_candles. Request at least 100 completed one-hour candles and ignore the candle that is still forming. Using the 20 completed candles immediately before the latest completed candle, calculate the mean close and sample standard deviation. Calculate the latest completed close's z-score against that window. Mark a long candidate only when z is at or below -2. Mark a short candidate only when z is at or above 2. Otherwise report no signal. Use the reference mean as the illustrative exit target and a move beyond an absolute z-score of 3 as the invalidation threshold. Print every timestamp, value and formula input used. Then call get_account_state, get_open_orders, get_predicted_fundings and get_orderbook. State the current position, funding, spread, nearby depth, balance, allowed markets, access expiry and per-order cap. If a candidate exists, prepare but do not submit a limit order worth no more than $25, without changing leverage or margin mode. Show the exact entry, target and proposed stop arguments, estimated fees and liquidation risk. Ask for confirmation for that exact action. Stop if the history is incomplete, the standard deviation is zero, the latest data is stale or price continues to extend beyond the invalidation threshold.

Who this is for

This guide is for an eligible user who wants an agent to calculate a simple deviation rule consistently and explain why a candidate exists. The example uses a 20-candle mean and standard deviation so every input can be shown.

What it is not

It is not a claim that an asset has a stable fair value or that every extreme will reverse. It does not support a two-asset pairs trade, and it should not be described as arbitrage. A one-market perpetual-futures position can keep losing while price moves farther from the mean.

What you need

  • A defined reference

    State the timeframe and lookback before calculation. The example uses the mean and standard deviation of the previous 20 completed one-hour closes.

  • Entry and invalidation thresholds

    This example watches at two standard deviations and treats a move beyond three as invalidation. These are inspectable parameters, not validated Fensory defaults.

  • A trend warning

    The agent must say when recent closes continue moving in one direction. A deviation can be the start of a larger move rather than a temporary stretch.

  • A small supervised account scope

    Set the exact market, access expiry and per-order cap in the app. Keep the example below the account ceiling and do not change leverage or margin mode through the prompt.

What the agent does

  1. 01

    Resolve the market and collect completed data

    The agent verifies the instrument, removes the current candle and checks the one-hour timestamps. It does not mix spot prices with the perpetual-futures position it may later prepare.

    Tools: get_perps_status · get_market · get_candles

  2. 02

    Calculate the reference window

    The mean and sample standard deviation come from the 20 candles before the latest completed close. The client prints the window so the z-score can be recalculated independently.

  3. 03

    Separate an extreme from an instruction

    A threshold crossing creates a candidate, not an order. The agent reports the direction, distance from the mean and invalidation level without calling the signal safe or likely to win.

  4. 04

    Check funding, liquidity and existing exposure

    A position held while waiting for a reversion can pay funding and face changing spread or depth. The account may already contain exposure or a resting order, so those records are checked before a new proposal.

    Tools: get_predicted_fundings · get_orderbook · get_account_state · get_open_orders

  5. 05

    Prepare one bounded action and read the result

    The agent shows the limit order, target and stop proposal first. After confirmation it reads the actual venue state and distinguishes a resting order, partial fill and completed fill.

    Tools: place_perps_order · get_order_status · get_fills · get_open_orders

Failure modes and limits

  • The market is trending rather than reverting

    Price can continue away from the reference for many candles. A larger z-score is not proof that a reversal is closer, and increasing size as the move extends compounds the risk.

  • The reference mean moves

    Each new completed candle changes the rolling mean and standard deviation. A target calculated in one review may differ at the next review, so the agent must report its timestamp.

  • The sample is too quiet

    A very small or zero standard deviation makes the z-score unstable or undefined. The prompt stops rather than dividing by zero or treating a tiny move as a reliable extreme.

  • Funding and time work against the position

    A reversion can take longer than expected or never arrive. Funding, fees and spread continue to affect the account while the position remains open.

  • The client stops before the next review

    This is a client-run process. The position and protective orders remain at the venue, but the agent does not recalculate the rolling window after its client or external schedule stops.

Read the result in the terminal

Position relative to the reference
Compare the live mark, entry, reference mean and invalidation level, but keep the calculation timestamp visible. The terminal price is current while the signal came from a completed candle.
Funding and liquidation
Read funding, margin mode and liquidation price while the position is open. Waiting for a statistical reversion does not suspend venue funding or liquidation rules.
Open orders and fills
Confirm whether the entry, target or stop is resting, partly filled or complete. Do not infer the position from the conversation when the account record differs.

Runs on

The client list comes from the same release record as the MCP page. Every verified client has its own setup guide.

Questions people ask

What does mean reversion mean in this guide?
It is the hypothesis that a price stretched away from a defined rolling reference may move back toward it. The page measures the stretch and does not claim that every market or period follows that pattern.
Is a two-standard-deviation move guaranteed to reverse?
No. Two standard deviations is an illustrative threshold. Price can continue moving in the same direction, the rolling distribution can change and a leveraged position can be liquidated.
Is this a pairs-trading strategy?
No. This example evaluates one perpetual-futures market against its own rolling price history. A pairs trade needs evidence for a relationship between two instruments and a verified multi-leg execution path.
Why show the funding rate before preparing an order?
Perpetual-futures funding is a recurring payment between long and short holders. A position waiting for a reversion may remain open long enough for funding to affect its cost.
Does Fensory run this strategy continuously?
This page describes the current client-run MCP workflow. The connected agent evaluates the rule only while the client or a schedule you operate is active. Fensory does not host the recurring evaluation in this workflow.