Strategy·May 5, 2026·12 min read

Writing your first strategy, line by line.

A walkthrough of the simplest profitable strategy file we publish (Funding Harvester) broken into its four blocks. What each block does, why it's there, and the two failure modes you'll want to design out of your own file before you ship it.

EN
The Engine Team
Dusk Labs
Share

A strategy on Engine is a file. Not a config form, not a YAML schema you'll never love, not a no-code drag-and-drop. A markdown file with four sections (universe, signals, risk, daily-loss cap) that you can read out loud to another human and they'd understand what you mean.

The agent reads that file the same way you do. When the agent acts, it cites a rule from your file by name. When you change the file, the agent picks up the new rules on the next tick. The file is the strategy.

This post walks through the simplest of our public strategies, Funding Harvester, line by line. By the end you should be able to write a useful strategy file of your own. We'll also flag the two mistakes most people make on their first one.

The four blocks

Every Engine strategy file has the same skeleton:

# Strategy name
> One-line description of what this strategy does.

## Universe
- which markets the agent is allowed to trade

## Signals
- what conditions, in what combinations, count as an entry

## Risk
- how big positions can be, where stops go, what gets capped

That's it. Four blocks, plain headings, plain bullets. You can write a perfectly good strategy in 30 lines. Funding Harvester is 28.

Block one: the universe

## Universe
- BTC-PERP, ETH-PERP, SOL-PERP, HYPE-PERP
- Min 24h volume: $50M

Two lines. The first names the markets you'll allow the agent to consider. The second is a guardrail: a market only enters the agent's attention if it's been doing $50M+ in 24-hour volume.

The volume floor matters more than people think. Funding signals on a thin perp are noisier and easier to push around with size, and a strategy that works on ETH will misbehave on a $5M-volume meme perp. Naming markets explicitly and setting a volume floor protects you from a Twitter-driven listing showing up in your universe before you've decided whether to trade it.

You can also use a category instead of explicit names (top 10 by 30d volume is a valid universe) but we'd recommend you start explicit. You'll learn faster about what works on which markets, and you'll be less surprised when something new lists.

Block two: the signals

## Signals
- funding_rate < -0.012% over 2 consecutive epochs
- Confirm with OI delta > +$1M in last 30m
- Skip if BTC realized vol > 80%

This is the entry rule, in plain language. You can read it left to right: trade when funding is below this number, confirmed by this other thing, except in this regime.

A few principles to take into your own file:

Lead with the strongest condition. The thing that defines the strategy goes first. Funding Harvester is a funding strategy, so the funding condition leads. Confirmation rules come second. Veto conditions come last.

Confirmation, not stacking. A common first-strategy mistake is to AND together five signals all measuring the same thing. (Funding low, premium negative, basis tight, perp at discount.) These are all funding-shaped. Adding them doesn't make the signal stronger; it just delays the entry until everything is moving together, which usually means you're late.

A good confirmation is a different kind of evidence. Funding tells you about the cost of being long. OI delta tells you about flow: money is still piling in. The two together is the asymmetry.

Always have a regime gate. "Skip if BTC realized vol > 80%" is a regime check. It says: this strategy is meant for normal markets, and during a vol spike I don't trust it. Almost every strategy that works in calm markets will lose its shirt during a vol spike, and the way you avoid that isn't to optimize the entry; it's to not enter at all during the regime your strategy wasn't designed for.

If your file doesn't have a regime gate, you don't have a strategy. You have a backtest with selection bias.

Block three: the risk

## Risk
- Max position_size: 5% NAV
- Stop loss: -1.2% · Take profit: +2.0%
- Daily loss limit: -3.2%
- Trail stop after +1.0% in profit

Four lines, and they're doing a lot of work.

Max position size as a percentage of NAV. Not in dollars, not in contracts. As a percentage. This means the strategy keeps the same risk shape whether your account is $5,000 or $5,000,000. Small accounts blow up because they treat $1,000 the same way a $50,000 account would; large accounts blow up because they keep sizing as if they were small. Percentage of NAV solves both.

Asymmetric stop and take-profit. -1.2% loss against +2.0% gain is a 1.67:1 reward-to-risk. With even a 50% win rate this is profitable; in our backtest the strategy hits closer to 58%. The exact ratio is less important than the direction: your TP should be wider than your stop. Otherwise you're picking up nickels.

Daily loss limit. This is the line that has saved this strategy more than any other. -3.2% per day is the cap. After three losing trades at -1.2% each, the daily limit is hit and the agent stops opening new positions for the rest of the day. You'd be surprised how often the trade after the third loss is the one that would have taken you to -8%.

Trailing stop. Once a position is +1.0% in profit, the stop ratchets up to lock in some gain. This isn't free money (it gives back some upside in choppy markets), but it cuts the worst-case scenario where a winner reverses all the way back through your entry.

Two mistakes everyone makes

Now the part that doesn't fit on a card.

Mistake one: no regime check

We mentioned this in the signals section. It's worth its own heading because it's the single most common reason a strategy file looks great in backtest and bleeds in production.

A strategy without a regime check is implicitly assuming the market it backtested on is the market it'll trade in. Funding strategies are a great example: in a calm regime, fading stretched funding is consistently profitable, because the stretch usually marks an over-eager crowd that gets unwound in the next few hours. In a high-vol regime, fading stretched funding is an excellent way to take the wrong side of a multi-day liquidation spiral.

The fix is to encode a vol gate in the file. Your file can read BTC realized volatility, total market open interest, or a custom regime indicator; the agent has all of them available. The point is that your file knows the regime exists and refuses to trade outside the regime it was designed for.

Mistake two: the daily loss cap is too generous

People set their daily loss cap at -10% and tell themselves it's just a "circuit breaker for extreme cases." A strategy that loses -10% in a day was already telling you, at -3% and -5% and -7%, that something was wrong. By the time you hit -10% you've spent the day digging the hole deeper.

The math: if your strategy averages 1-2 trades per day with a -1.2% stop, your expected worst day from random sequencing is around -3.5% if the strategy is working. If you're seeing -5% or worse, the strategy isn't working today. Stop trading today. Look at the file tomorrow.

Cap it tight. Funding Harvester caps at -3.2%. In live operation, the cap has triggered roughly one day a month. Every one of those days, the trade after the cap would have been a loser. The cap pays for itself with the trades it stops you from taking.

The starter file

Here's a complete file you can copy, fork, edit. It's the actual Funding Harvester:

STRATEGY.md
STRATEGY.md
-----------
# Funding Harvester

Trade against extreme negative funding on liquid perps when open interest
confirms that shorts are still crowding in.

## Entry setup
- Funding is deeply negative and sustained.
- Open interest is rising, not falling.
- Volatility is not in cascade mode.
- Abstain when the book is thin or signals conflict.

## Exit and management
- Use a stop where the crowding thesis is invalidated.
- Take profit when funding normalizes or price squeezes into resistance.
- Trail stops only after the trade has protected entry.

## Rules
entry: funding_1h < -0.003 AND oi_delta_4h > 0.03 AND realized_vol_24h < 0.80
exit: pnl_pct >= 0.02 OR drawdown <= -0.012
size: fixed_pct(0.03) capped at position_pct

strategy.yaml
-------------
name: funding-harvester
slug: funding-harvester
author: "0x4f2a000000000000000000000000000000000001"
version: 1.0.0
universe: [BTC-PERP, ETH-PERP, SOL-PERP, HYPE-PERP]
capacity_usd: 500000
cadence: 5m
mode: both
data: [hl.funding, hl.oi, hl.marks]
risk:
  max_leverage: 2
  max_drawdown: 0.08
  position_pct: 0.05
  daily_loss_limit: 0.032
  stop_loss: 0.012
  take_profit: 0.02
fees:
  perf: 0.10
  hurdle: 0
  hwm: true
inputs: [market_context, positions, account, regime_tags, memory]
permissions:
  can_emit_trade_intents: true
  can_execute_orders_directly: false
outputs: [TradeIntent, NoTrade]
when_to_use: Use in liquid markets when funding is stretched but volatility is not in cascade mode.
min_conviction: 0.55

That's it. Twenty-eight lines. No code, no schema, no compile step. Save it, attach it to a vault, the agent will start ticking against it. Edit it mid-flight and the agent picks up the changes on the next tick.

The file is yours. Fork it, change the universe, tighten the stops, weaken the regime gate at your peril. The whole point of writing the strategy as a file is that you can read it, change it, share it, and argue with it. The agent is just the thing that operationalizes it, tick by tick, until you tell it to stop.

strategytutorialfundingrisk
Share
Keep reading