Multi-Timeframe Strategies
Most professional strategies don’t operate on a single timeframe. They use a slower timeframe for portfolio decisions and a faster timeframe for daily risk management. Quantlens supports up to four independent intervals in one strategy.
The four intervals
The Config Block block exposes four independently configurable intervals:
Interval |
Default |
Typical use |
|---|---|---|
Primary |
|
Main rebalancing logic — stock selection, ranking, entering/exiting positions. |
Secondary |
|
Daily risk management — stop-loss checks, limit order execution. |
Tertiary |
|
Mid-frequency checks — secondary condition monitoring, partial exits. |
Quaternary |
|
Low-frequency oversight — market regime filter re-evaluation. |
Each interval maps to a On Interval block in your workspace. Blocks nested inside a On Interval only execute when that interval fires.
Interval format:
1d = every trading day
2d = every 2 trading days
1w = every week (Monday)
2w = every 2 weeks
1m = every calendar month
The classic two-timeframe setup
The most widely used pattern is weekly rebalance + daily risk management:
Primary Interval: 1w (or 2w)
Secondary Interval: 1d
Primary (weekly) — stock selection:
Rank stocks by momentum (or RSI condition).
Apply market filter (Index > SMA200).
Enter top-ranked positions.
Exit positions that dropped out of the top.
Secondary (daily) — risk management:
Check stop-losses on all open positions.
Execute any pending limit orders.
Why separate them?
If you only check stop-losses on rebalance day (every 2 weeks), a stock that falls sharply on Tuesday won’t be exited until the next rebalance — potentially a 10–20% additional loss. Daily stop-loss checking dramatically limits how much damage any single position can do.
Full block structure:
┌─ Config ──────────────────────────────────────────────┐
│ Primary Interval: 1w │ Secondary Interval: 1d │
│ Slots: 10 │ Stop Loss: 7% │
└───────────────────────────────────────────────────────┘
┌─ Trading Loop ────────────────────────────────┐
│ │
│ ┌─ Primary (1w) ───────────────────────────────┐ │
│ │ │ │
│ │ IF Index Value > SMA(200) │ │
│ │ → Rank by Momentum(189) │ │
│ │ → Cooldown Filter(20d) │ │
│ │ → Rebalance: Enter │ │
│ │ → Rebalance: Exit (old positions)│ │
│ │ │ │
│ └──────────────────────────────────────────────┘ │
│ │
│ ┌─ Secondary (1d) ─────────────────────────────┐ │
│ │ Check Stop Loss (eod) │ │
│ └──────────────────────────────────────────────┘ │
│ │
└───────────────────────────────────────────────────────┘
Three-timeframe example: Momentum with limit entries
This pattern adds a third interval to implement the “buy the dip” limit order logic:
Primary (2w): Rank stocks, schedule limit orders for next week.
Secondary (1d): Execute any pending limit orders; check stop-losses.
Tertiary (2w): Cancel unexecuted limit orders and start fresh.
Config:
Primary Interval: 2w
Secondary Interval: 1d
Tertiary Interval: 2w
┌─ Trading Loop ────────────────────────────────┐
│ │
│ ┌─ Primary (2w) ───────────────────────────────┐ │
│ │ IF Index > SMA(200) │ │
│ │ → Rank Momentum → Enter Next-Week Limit │ │
│ │ → Rebalance: Exit (old positions)│ │
│ └──────────────────────────────────────────────┘ │
│ │
│ ┌─ Secondary (1d) ─────────────────────────────┐ │
│ │ Execute Limit Orders │ │
│ │ Check Stop Loss (eod) │ │
│ └──────────────────────────────────────────────┘ │
│ │
└───────────────────────────────────────────────────────┘
Why limit entries?
Instead of buying at the weekly close (which may be elevated after a strong week), you set a limit at 0.5–1% below the close. If the stock dips early in the following week, you get a better fill price. If it never dips, the order is not filled — you avoid chasing the position.
Using intervals for regime detection
A fourth interval can implement a slower “regime check” — updating the market regime less frequently than the rebalance to avoid reacting to short-term noise:
Config:
Primary Interval: 2w (rebalance)
Secondary Interval: 1d (stop-loss)
Quaternary Interval: 1m (regime check — monthly)
Monthly regime check logic:
┌─ Quaternary (1m) ────────────────────────────────┐
│ IF Index Value < Index Weekly Quantile(25) │
│ (index is in its lowest 25% historically) │
│ → Rebalance: Exit (exit everything) │
└──────────────────────────────────────────────────┘
This exits all positions if the market enters a deep bear regime (bottom 25% of all weekly closes), and stays out until the monthly check confirms recovery.
Interval timing reference
When exactly does each interval fire?
Format |
Fires on |
|---|---|
|
Every trading day. |
|
Every 2nd trading day from the strategy start date. |
|
The first trading day of each calendar week (Monday, or next open day). |
|
The first trading day of every other calendar week. |
|
The first trading day of each calendar month. |
Note
Intervals are counted from the strategy’s Start Date, not from today.
A 2w interval starting on a Wednesday will fire every other Wednesday throughout the test.
Common mistakes
Mistake 1 — Checking stop-losses only on the rebalance interval
If Primary = 2w and you put Check Stop Loss inside the Primary block,
stop-losses are only evaluated every two weeks.
A stock can fall 20% in the middle of a two-week period before being caught.
Always place Check Stop Loss inside the Secondary (1d) block.
Mistake 2 — Executing limit orders on the rebalance day only
Limit orders need to be checked daily — otherwise they only trigger on rebalance day.
Place Execute Limit Orders inside the Secondary (1d) block.
Mistake 3 — Conflicting enter/exit logic across intervals
If Primary enters positions and Secondary also contains entry logic, they may conflict — entering the same stock twice or fighting over slot allocation. Keep entry logic in one interval and risk management in another.