MTF Range Flip HTF Market Structure BiasWhat this does
This is an intraday strategy for index futures that combines a range-flip entry model on the
chart timeframe with a market-structure bias taken from a higher timeframe. It only takes
trades in the direction the higher timeframe is trending, and only when price has pulled back
into the discount half of the higher-timeframe range.
The range flip
A "range" here is defined by price action rather than a fixed window. When a candle closes
beyond the current range's high or low, that close is treated as meaningful — a new range is
built around that candle, and the old one is discarded. Each of these events is a flip.
Flips are tracked on two timeframes at once. The chart timeframe supplies the entry trigger;
the higher timeframe supplies the range whose midline governs location.
Bias — higher-timeframe market structure
The strategy only takes longs when higher-timeframe structure is bullish and shorts when it
is bearish. Two structure definitions are available:
BOS — a higher-timeframe close beyond the last confirmed swing point
HH-HL sequence — successive higher highs and higher lows, or the bearish mirror
Swing points are confirmed with a configurable pivot length, so structure is only ever read
from bars that have already closed.
Location — the midline rule
By default the strategy buys weakness inside strength: a long needs price below the
higher-timeframe range midline, a short needs price above it. This keeps entries on the
pullback side rather than chasing extension. A breakout variant is available if you prefer
the opposite behaviour.
Entry, stop and target
Entry — a chart-timeframe range flip that agrees with bias and location, inside the
session window.
Stop — the most recent confirmed swing pivot beyond the entry, plus a tick buffer. The
stop is frozen at the moment of the fill, so later swings never move it. Alternative
references (the flip candle's own range, or the previous range) are selectable, and optional
minimum and maximum stop widths are available.
Target — a multiple of the stop distance, set separately for each side. The default is
1.5R on longs and 0.5R on shorts, reflecting that in testing the two sides did not behave
symmetrically. An optional breakeven rule can be armed at a chosen R multiple and applied to
one side or both.
Depth-based position sizing
Depth measures where an entry sits inside the higher-timeframe range, normalised to range
width — 0.50 is the midline, 0.00 is the range edge, and a negative value means price is
beyond the edge while the higher timeframe has not yet flipped.
When enabled, entries deeper than the threshold receive a larger multiplier. The idea is that
not every pullback is equal, and the deepest ones can be treated differently from shallow
ones. Sizing can be applied to longs, shorts, or both.
A separate depth gate can block entries outright unless they are deep enough — useful for
isolating whether depth is what separates good entries from poor ones on your instrument.
Optional filters
Volatility regime — requires daily ATR to sit above a chosen percentile of its own
recent history. This model needs range expansion to reach its targets, and this stands it
aside in quiet conditions. Off by default.
VWAP — session or weekly anchored. Can require price above or below VWAP, or simply
block entries more than N ATR away from it without imposing a direction. Off by default.
Regime switch — an optional daily or weekly structure read that can restrict trading to
one side. Off by default.
Session windows — a general entry window plus a separate, later window for shorts.
On-chart panel
A live table reports bias state, current range, position, stop widths for both sides, filter
status, and a signal funnel showing how many flips were blocked by each filter. It also
reports average R — overall, split by side, and split by depth bucket. Net profit on a
structural-stop strategy is influenced by how wide the stops happened to be, so average R is
the more honest read on whether a change actually improved entry quality.
Default settings used for the published results
Instrument and timeframe: NQ1!, 5-minute chart, higher timeframe 60-minute
Initial capital: 100,000 USD
Order size: 2 contracts, fixed quantity
Pyramiding: 0 — one position at a time, no scaling in
Commission: 2.25 USD per contract
Slippage: 1 tick
Bar detalization: High (~40 ticks per bar) — set this in Properties
Script execution: on bar close
Notes and limitations
Backtested results are hypothetical and do not represent actual trading. Past performance
does not guarantee future results, and no strategy performs the same across all market
conditions.
Set bar detalization to High. With coarse detalization the backtester has to guess the
order of touches inside a bar, which flatters any strategy whose stop and target can both sit
inside the same candle.
Volatility lookback. If you enable the volatility filter, the "ranked vs last N bars"
value must be smaller than the number of daily bars your chart can supply. A one-year chart
holds roughly 250 trading days, so a 252 setting will return no data. The panel prints an
explicit warning if this happens rather than silently passing every trade.
Sizing multipliers use whole contracts. With a base size of 2 and a 2x multiplier you get
4 contracts; fractional results are rounded and floored at 1.
Sample size. The stricter filters and gates cut trade count quickly. If a configuration
leaves you with only a few dozen trades, treat the result as indicative rather than
conclusive regardless of how good it looks.
Defaults are a starting point, not a recommendation. Test on your own instrument, timeframe
and cost assumptions before drawing conclusions.
This script is published for educational purposes. It is not financial advice.
Chiến lược






















