
BTC on 1-hour bars in the 0xArchive Terminal, 2026-10-25.
Open on a chart
Load it on BTC 1h in the terminal, then change its settings or open it in the script editor.
How it works
funding() reads the rate each hour settled, and ta.ema smooths it over 24 hours. Above the entry threshold strategy.target(-1) goes fully short (longs pay shorts when the rate is positive); below its negative, fully long; back inside the exit band, flat. Between the two bands the position holds.
The funding is the whole edge, so the costs decide the answer. The strategy pays the venue’s fee on every fill and what the order book charged for the order’s size (2 bps a fill where the archive has no reading), and collects or pays funding every hour it holds. The Strategy report puts each beside the gross result, so you can see whether the carry outran the cost of getting in and out, and how far price moved against it meanwhile.
The script
funding-carry.ts