Skip to content

Strategy guide

Build a trend-following strategy with an AI agent

A trend-following strategy applies the same directional rule to completed market data at each review. With Fensory MCP, a connected agent can read Hyperliquid candles, calculate a signal, check the signed-in account and prepare a bounded perpetual-futures order for review.

The current workflow is client-run. Fensory supplies the market, account and order tools, while the connected client performs each calculation and decides when to call them. Fensory does not host the recurring evaluation in this workflow, so it stops checking new data when the client or external scheduler stops. Fensory is not available to US persons.

Copy this prompt

Use the Fensory tools to assess BTC perpetual futures with a transparent trend-following rule. Stay read-only first. Call get_perps_status, get_market and get_candles. Use the latest 100 completed one-hour candles and ignore the candle that is still forming. Calculate the 20-period and 50-period exponential moving averages for the latest and immediately preceding completed candles. Mark a long entry candidate only when the latest close is above both averages, EMA20 is above EMA50, and the preceding candle did not have the same long alignment. Mark a short entry candidate only when the latest close is below both averages, EMA20 is below EMA50, and the preceding candle did not have the same short alignment. If the same alignment was already present, report existing alignment and no new entry candidate. Print both candle timestamps, closes, EMA values and the exact condition that passed or failed. Then call get_account_state and get_open_orders. State the existing position, available balance, allowed markets, access expiry and per-order cap. If the account already has a long position, mark an exit candidate when a completed close falls below EMA20. If it has a short position, mark an exit candidate when a completed close rises above EMA20. If an entry candidate exists, prepare but do not submit a limit order worth no more than the lower of $25 and the current per-order cap, without changing leverage or margin mode. For a long candidate, use the lowest low of the latest ten completed candles, including the signal candle, as the proposed stop reference. For a short candidate, use the highest high of the same window. If a size calculated from the stop distance exceeds either ceiling, reduce the size instead of moving the stop. If the reduced size cannot meet the venue minimum, report no executable order. Treat the stop as a separate stop-market order that the connected client must place and verify after confirmation. It is not an account-enforced loss limit, and its fill can differ from its trigger in a fast or thin market. Show the exact entry and stop arguments, current funding, estimated fees and liquidation risk. Do not place, cancel or replace anything until I confirm that exact action. Stop if candle history is incomplete, stale or contains a gap.

Who this is for

This guide is for an eligible user who wants a transparent, repeatable way to test a directional rule with completed candles and a small supervised perpetual-futures order. The example uses EMA alignment because every input can be printed and checked.

What it is not

It is not a performance claim, a backtest or an unattended strategy. A moving-average rule can reverse late, trade repeatedly in a flat market and lose through fees, funding, slippage or liquidation. The agent should report a signal without presenting it as a recommendation.

What you need

  • One written rule

    This example creates an entry candidate only on the first completed candle where full EMA alignment becomes true. It creates an exit candidate when a completed close crosses EMA20 against the position. The rule is fixed before the chart is read so the result can be reproduced.

  • Enough completed candles

    The longest lookback needs a stable history. This example requests 100 completed one-hour candles for a 20-period and 50-period EMA comparison and excludes the still-forming candle.

  • A bounded Fensory account

    Set the access expiry, exact market allow-list and per-order cap in the app. Keep leverage unchanged and size the test below both your prompt ceiling and the account cap.

  • A client or scheduler you operate

    The connected agent must run the same check again when a new candle closes. If that client, routine or scheduler stops, the strategy stops evaluating new data.

What the agent does

  1. 01

    Resolve the perpetual-futures market

    The agent verifies that perpetual-futures execution is available and that the requested symbol resolves to the intended Hyperliquid market. A familiar ticker is not enough because the same name may describe another instrument elsewhere in the app.

    Tools: get_perps_status · get_market

  2. 02

    Read only completed candles

    The current candle can change before it closes. The agent removes it from the calculation, checks timestamps for gaps and prints the exact history window so another reader can reproduce the averages.

    Tools: get_candles

  3. 03

    Calculate and explain the signal

    The client calculates both EMAs from the returned closes and reports whether alignment became true on the latest completed candle. Ongoing alignment is not a fresh entry signal. An existing position receives a separate exit check against EMA20. The client does not claim that this rule has been backtested by Fensory.

  4. 04

    Read exposure and account controls

    A valid signal does not authorize an order. The agent checks the current position, resting orders, account balance, expiry, market allow-list and per-order cap before preparing anything new.

    Tools: get_account_state · get_open_orders

  5. 05

    Prepare one order and verify its state

    The agent applies the lower of the prompt ceiling and account cap, then shows the complete limit order and separate proposed stop-market order before submission. After a confirmed action it reads the venue state again. The stop is client-managed, and its eventual fill can differ from its trigger.

    Tools: place_perps_order · get_order_status · get_fills · get_open_orders

Failure modes and limits

  • A flat market creates repeated reversals

    Two averages can cross back and forth when price has no sustained direction. Each reversal can add fees and slippage even when the market finishes near its starting point.

  • The newest candle is incomplete

    An intraperiod move can make the EMA alignment appear and disappear before the candle closes. The prompt uses completed candles so the same timestamp produces the same calculation.

  • The signal arrives after the move

    Moving averages use past prices and can react late. The page does not imply that EMA alignment predicts the next move or that a faster setting is better.

  • A stop trigger is not a guaranteed fill

    The proposed stop is a separate venue order, not an account-enforced maximum loss. A stop-market order can fill beyond its trigger when price moves quickly or visible liquidity is thin.

  • Costs outlast the signal

    Perpetual futures add venue fees, the Fensory builder fee, funding and execution spread. A short-lived signal can be smaller than those combined costs.

  • The client stops running

    Fensory MCP does not keep this prompt running by itself. No new candle is evaluated after the connected client or the user-operated schedule stops, although existing positions and orders remain live at the venue.

Read the result in the terminal

Position and liquidation price
Confirm the market, side, size, entry price, mark price, margin mode and liquidation price. The calculated signal is not authoritative once the account holds a live position.
Open orders and fills
A limit order may remain open or fill only partly. Compare the remaining quantity with the fill records before the next evaluation prepares another order.
Funding and fees
Funding can change while a position is open, and the actual fill carries the fee record. These costs belong in every review of the strategy result.

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

Can Fensory run this trend-following strategy continuously today?
The current guide is client-run. A connected agent can read candles, calculate the rule and use Fensory tools while the client or user-operated schedule is running. Fensory does not host the recurring evaluation in this workflow.
Why use completed candles?
The still-forming candle can change before the period ends and can make the EMA alignment appear temporarily. Completed candles make the input window and signal reproducible.
Does EMA alignment predict that price will continue?
No. It describes a relationship in past prices. It can react late or reverse repeatedly, especially in a flat market. Fensory does not publish a return claim for this example.
What ends the example trend?
For an existing long position, the example marks an exit candidate after a completed close falls below EMA20. For an existing short, it marks one after a completed close rises above EMA20. The proposed stop-market order is a separate client-managed control and can fill away from its trigger.
Can the agent change the Fensory account limits?
No. Access expiry, allowed markets, per-order cap and the trading kill-switch are account settings controlled in the app. The agent reads them and any order outside them is rejected.
What happens if the client disconnects while a position is open?
The calculation loop stops, but a filled position or resting order remains at the venue. Check the terminal, manage the position directly and disable agentic trading if no new agent action should be accepted.