STRATEGY LIBRARY

Writing trading strategy filters the way a checklist reads

Contents
Long entry conditions become unreadable as one expression. This shape keeps each requirement on its own line, and it is how most trading strategy filters here are actually written.

1. The shape

# BUY — start from yes, then let each check say no ok = True if not (BuyVol > 0 and SellVol > 0): ok = False elif not (TradeAmount > TradeAmountN(1)): ok = False elif not (ChangePct > 0): ok = False elif not (Ask1 > Bid1): ok = False if ok: Buy()

2. What this buys you

PropertyWhy it matters
each condition on its own lineyou can comment one out and know exactly what changed
explicit orderthe cheap checks run before the expensive ones
default is yesevery line can only take permission away, never grant it
reads as a checklistyou can still follow it a month later
The variable name is arbitrary. What matters is the default-yes structure: written as one long and chain the same logic is correct, and nobody can read it a month later, including you.

3. Why order is a real decision, not a style one

Conditions are evaluated in sequence, so put the ones that reject most candidates first. If Ask1 > Bid1 rejects 2% of ticks and ChangePct > 0 rejects 50%, running the cheap common rejection first saves work on every tick of every symbol. That is a performance argument, but there is a clearer one: the order of a checklist is also its explanation. Reading top to bottom should tell someone what the strategy considers disqualifying, in the order it considers it.

4. How this helps you test

Because each line is separable, you can run the same entry with one check removed at a time and measure what each one contributes. That is a genuinely useful experiment and it is nearly impossible with a single and chain. Watch trade count as you do it. A check that removes 90% of trades and leaves the average return unchanged is filtering at random, and you have made your sample smaller for nothing — see eleven conditions, four trades a month.

5. What to change first

Add a comment above each line saying what it rejects, not what it requires. "Rejects names with no prints yet" is more useful six months later than "buy volume positive", because the rejection is the reason the line exists. Then check the order against your own data: how to backtest a day trading strategy on US stocks.

Educational template for research and backtesting. Not investment advice and not a signal service.

Related reading

← All strategy library

Originally published by TraderWe on August 13, 2026. You may quote and link to this page. Republishing the full text without a link back to the original is not permitted.

2 replies

BacktestBetty· Aug 2026 ago
Two things: (1) the default-yes shape is worth it for me purely because commenting out a single line and re-running gives a clean A/B, with a giant and-chain I could never tell which clause was doing the work; (2) small caution though, once each rule is that easy to toggle it gets very tempting to keep bolting on one more filter until the backtest looks pretty, and that's textbook overfitting. I'd log which line rejected each candidate before I add anything new, and if a condition almost never fires on its own it's decoration, not a filter. Also unclear to me from the piece — does the ordering point matter for runtime on short timeframes, or is it mostly about readability?
G
GapHunterMike· Aug 2026 ago
the elif chain means once one says no the rest never run. fine for speed, annoying when you want to know which checks failed. i keep mine as plain ifs so i can flip a print on each and see all the nos at once.
Sign in to reply →