Guide
This walkthrough takes you from zero to a backtested, optimized algorithm. By the end, you’ll have created an algorithm, run a backtest, interpreted the results, and improved it with optimization.
Step 1: Pick a Market
Section titled “Step 1: Pick a Market”Choose the asset and exchange you want to trade. Reversion supports Hyperliquid perpetual futures and HIP-3 XYZ DEX perpetual markets for tradfi assets.
Start with a liquid market like BTC/USDC or ETH/USDC — these have tight spreads and deep orderbooks, which means more reliable backtests.
Step 2: Explore Indicators
Section titled “Step 2: Explore Indicators”Before building an algorithm, explore how indicators behave on your chosen market. This helps you pick the right signals and thresholds.
For example, test RSI on ETH 4-hour candles:
- Indicator: RSI
- Period: 14 bars (56 hours on 4h timeframe)
- Signal:
value_below_thresholdwith threshold 30 (oversold → buy signal)
Use the explore_indicator tool or the charting UI to visualize signals against price data. Look for:
- Does the signal trigger at reasonable points?
- How often does it fire? (too frequent = noisy, too rare = missed opportunities)
- Does it align with price reversals?
Step 3: Define Your Algorithm
Section titled “Step 3: Define Your Algorithm”An algorithm needs at minimum:
- Type —
LONG,SHORT, orBOTH - Entry condition — when to open a position
- Exit condition — when to close it
- Position sizing — how much capital per trade
- Starting capital — the initial USD balance
Example: RSI Mean Reversion (Long Only)
Section titled “Example: RSI Mean Reversion (Long Only)”This algorithm buys when RSI is oversold and sells when it’s overbought:
| Setting | Value |
|---|---|
| Type | LONG |
| Long Entry | RSI below 30 (required) |
| Long Exit | RSI above 70 (required) |
| Stop Loss | 5% trailing |
| Position Size | 50% of equity (REL) |
| Order Type | MARKET |
| Starting Capital | $1,000 |
| Timeout | COOLDOWN_ONLY, 3 bars |
Entry & Exit Conditions
Section titled “Entry & Exit Conditions”Conditions use two groups:
- Required — ALL indicators in this group must be true (AND logic)
- Optional — at least ONE indicator must be true (OR logic)
Both groups must be satisfied for the condition to trigger. This lets you build layered rules like:
Enter when RSI is oversold (required) AND either Bollinger Band is touched OR volume spikes (optional)
See Algorithms → Conditions for the full reference.
Stop Loss & Take Profit
Section titled “Stop Loss & Take Profit”Add risk management to your exit condition:
- Stop Loss — exit at a fixed USD amount (ABS) or percentage (REL) below entry
- Take Profit — exit at a fixed amount or percentage above entry
- Trailing Stop — SL level follows price as it moves in your favor
- Dynamic — SL/TP modulated by an indicator value (DYN)
Position Sizing
Section titled “Position Sizing”Three modes:
| Mode | Description | Example |
|---|---|---|
ABS | Fixed USD amount per trade | $500 per trade |
REL | Percentage of current equity | 50% of equity |
DYN | Driven by an indicator value | ATR-scaled sizing |
Step 4: Create the Algorithm
Section titled “Step 4: Create the Algorithm”You can create algorithms through:
- Web app — the algorithm builder UI
- MCP agent —
create_algorithmtool via natural language - API —
POST /algo/configs
The platform saves your config and assigns an algoId. Each subsequent edit creates a new version — previous versions are preserved and can be backtested independently.
Step 5: Run a Backtest
Section titled “Step 5: Run a Backtest”With your algorithm created, run a backtest to see how it would have performed:
| Parameter | Description |
|---|---|
algoId | Your algorithm’s ID |
version | Which version to test (latest by default) |
symbol | Trading pair (e.g., BTC/USDC) |
startTime | Backtest start date |
endTime | Backtest end date |
capitalScaler | Multiplier for starting capital (default: 1.0) |
The backtest runs asynchronously — you’ll get a runId to check results.
Step 6: Interpret Results
Section titled “Step 6: Interpret Results”Key Metrics
Section titled “Key Metrics”Once the backtest completes, check these metrics first:
| Metric | What It Tells You | Good Range |
|---|---|---|
| Win Rate | % of trades that were profitable | > 40% (depends on R:R) |
| Profit Factor | Gross profit / gross loss | > 1.5 |
| Sharpe Ratio | Risk-adjusted return (annualized) | > 1.0 |
| Sortino Ratio | Like Sharpe but only penalizes downside | > 1.5 |
| Max Drawdown | Largest peak-to-trough decline | < 20% |
| Calmar Ratio | Annualized return / max drawdown | > 1.0 |
| Avg Trade Duration | How long positions are held | Depends on strategy |
Equity Curve
Section titled “Equity Curve”Plot the equity curve (plot_backtest) to visually inspect:
- Is the curve consistently rising, or does all profit come from a few lucky trades?
- Are drawdowns sharp and frequent, or gradual and recoverable?
- Does the strategy stall in certain market regimes?
Indicator Usefulness
Section titled “Indicator Usefulness”The algo metrics include a usefulness score (0–100) for each indicator. This tells you how much each indicator contributes to the strategy:
- High score — the indicator is driving meaningful entries/exits
- Low score — the indicator is rarely triggered or always agrees with other signals (consider removing it)
Also check near-miss analysis — how close conditions came to triggering without actually firing. This can reveal if thresholds need tweaking.
Step 7: Iterate
Section titled “Step 7: Iterate”Based on your results, adjust:
- Thresholds — if RSI 30/70 doesn’t work, try 25/75 or 35/65
- Indicators — swap underperforming indicators (low usefulness scores) for alternatives
- Position sizing — if drawdowns are too large, reduce position size
- Timeframe — try different candle intervals (1h, 4h, 1d)
- Stop loss — tighten or loosen SL; try trailing stops
Each change creates a new version. Backtest again and compare.
Step 8: Optimize
Section titled “Step 8: Optimize”Once you have a working strategy, use Bayesian optimization to systematically search for the best parameters:
- Define parameter space — which parameters to vary and their bounds
- Choose a scoring function — what to maximize (Sharpe, profit factor, custom)
- Run optimization — the engine tries different parameter combinations using Optuna TPE
- Validate — run rolling cross-validation to ensure the optimized params aren’t overfit
Step 9: Deploy
Section titled “Step 9: Deploy”When you’re confident in your strategy:
- Create a run with
isBacktest: false - The algorithm executes live using the same state machine as backtesting
- Monitor via
get_account_overviewor the web app - Stop anytime by updating run status to
STOPPED
The live engine uses the same indicator evaluation and condition logic as the backtester — what you tested is what runs.
Next Steps
Section titled “Next Steps”- Algorithms — full reference for all algorithm config options
- Backtesting — deep dive into metrics and the simulation pipeline
- Optimization — Bayesian optimization and cross-validation