On a perpetual futures venue the exchange tells you which side crossed the spread. On a stock
exchange nobody does, and the classification has to be inferred from the quote. That makes order
flow a cleaner input here than anywhere else, and it is the reason this strategy is worth writing
using perps specifically.
1. The rule
# BUY — direction chosen per entry
if BuyFlowRatio(60) > 0.3 and ChangePct >= 2:
Long()
elif BuyFlowRatio(60) < -0.3 and ChangePct <= -2:
Short()# SELL — one exit block covers either side
if ProfitPct >= 1.0 or ProfitPct <= -0.5 or HoldTime >= 1800:
Sell()
2. Why the same factor is better here
BuyFlowRatio(60) is (buy flow − sell flow) divided by their sum over the last minute, so it runs
from −1 to +1 and does not change meaning when turnover changes.
How the taker side is decided
Perpetual futures
the exchange publishes it with the trade
US stocks
inferred by comparing the price against the quote
The inferred version is only valid while the quote is fresh, which is why the engine refuses to
classify a stock trade against a quote older than 500 milliseconds. On perps that whole problem
does not exist: the venue states the side, so the flow factors are exact rather than estimated.
The practical consequence is that a threshold like 0.3 means the same thing from one symbol to the
next here, where on stocks it drifts with how continuously the name quotes.
3. Both directions are not one rule mirrored
The entry takes longs and shorts with the same number flipped, and that is a simplification worth
being honest about. It is written that way so the block stays readable, not because the two sides
behave alike.
If you keep it symmetric, test it symmetric: run the short leg on its own and look at whether it
earns its place, rather than reading a combined curve. A combined result can be carried entirely by
one side while the other quietly loses.
The elif matters too. It makes the two branches exclusive, so a bar that somehow satisfied both
conditions would take the long and never the short, instead of firing twice.
4. What the round trip asks of it
Perpetual futures entry in both directions: the exit block drawn to scale, and the break-even win rate before and after measured trading costs
A 1.0% target against a 0.5% stop needs 33% on paper and 40% after a crypto round trip. Compare
that with the same block on US stocks, where the measured round trip would put the bar at 83%.
That gap is the single biggest structural difference between the two markets in this library. A one
percent target is a reasonable thing to ask for on a perp and close to impossible on a mid-priced US
stock, and it is a cost difference rather than anything about the signal.
What the figure does not carry is funding. Holding a perpetual position costs or pays funding every
few hours, and at a 30-minute cap that is usually small, but it is not zero and it is not in the
0.10% above.
5. What to change first
Move the threshold before the time cap. BuyFlowRatio(60) > 0.3 is a strong reading; at 0.15 you
will get several times the trades and can see whether the strength of the imbalance is what mattered
or just its sign.
Then widen the window. One minute of flow on a quiet symbol is a handful of trades, and
BuyFlowRatio(300) asks the same question of five minutes, which is a different and usually steadier
statement. Both are worth running before any threshold is tuned.
Educational template for research and backtesting. Not investment advice and not a signal service.
Originally published by TraderWe on October 4, 2026. You may quote and link to this page. Republishing the full text without a link back to the original is not permitted.