---
name: fensory-trend-following
description: Evaluate a transparent EMA trend-following rule with completed candles, inspect Fensory account controls and prepare a bounded perpetual-futures order for review.
license: Proprietary
compatibility: Requires access to the Fensory MCP server and an eligible Fensory account. Fensory is not available to US persons.
metadata:
  author: Fensory AG
  version: "0.1.0"
  source: "https://fensory.com/skills/trend-following"
---

# Build a trend-following strategy with an AI agent

## When to use

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.

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.

## Operating rules

- Start with read tools and identify the signed-in account, market, venue and instrument before preparing an action.
- Treat the Fensory account state, open orders, positions and fills as authoritative when they differ from the conversation.
- Fensory enforces four controls on the account: a kill-switch, an access expiry, a market allow-list and a per-order cap. Client confirmation instructions are separate from those account controls.
- Never describe a perpetual future as a share or tokenized equity. State the instrument and its risks before discussing an order.
- Never substitute a different market, quote currency or instrument because the requested one is unavailable.
- Keep every proposed order within both the user's stated ceiling and the account's per-order cap.
- Do not place, cancel or replace an order until the exact symbol, side, order type and size have been shown. For a limit order, show the limit price. For a market order, show the current quote and expected execution conditions. The user must confirm that exact action.
- Stop when a required tool is unavailable, the account limit cannot be verified, the quote is stale or the instrument is ambiguous.

## Risk and scope

This file is operational guidance, not financial advice. Trading can lose the full amount committed. Perpetual futures use margin and can be liquidated. Spot assets can lose value. Stop if the instrument, current quote or account controls cannot be verified.

## Procedure

1. **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. **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. **Calculate and explain the signal.** The client calculates both EMAs from the returned closes and reports which condition passed. It does not turn a borderline or incomplete result into a trade, and it does not claim that this rule has been backtested by Fensory.
4. **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. **Prepare one order and verify its state.** The agent shows the complete limit order and proposed stop before submission. After a confirmed action it reads the venue state again, because a submitted order can rest, fill partly, fill completely or fail. Tools: `place_perps_order`, `get_order_status`, `get_fills`, `get_open_orders`.

## Request template

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. Mark a long candidate only when the latest completed close is above both averages and EMA20 is above EMA50. Mark a short candidate only when the close is below both and EMA20 is below EMA50. Otherwise report no signal. Print the candle timestamp, close, both 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 a candidate exists, prepare but do not submit a limit order worth no more than $25, without changing leverage or margin mode. For a long candidate, use the lowest low of the most recent ten completed candles as the proposed stop reference. For a short candidate, use the highest high of those candles. Show the exact order 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.

## Failure handling

- **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.
- **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.

## Response contract

Report the account used, the exact instrument, the tools called, the controls that applied and the current order or position state. Separate a prepared order from a submitted order, and a submitted order from a fill. If no action was taken, say so directly.

## Sources

- [CME research: trend-following proxy systems and limitations](https://www.cmegroup.com/education/files/ac-the-market-environment-for-trendfollowing-sep19.pdf)
- [Hyperliquid perpetual-futures contract specifications](https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications)
- [Hyperliquid order types](https://hyperliquid.gitbook.io/hyperliquid-docs/trading/order-types)
- [Fensory MCP server](https://fensory.com/mcp)

Product behavior and client permissions verified 2026-10-17.
