MTF Range Flip HTF Market Structure Bias — Strategy by Mikey2timez

By Mikey2timez

Performance Metrics

Description

What this doesThis is an intraday strategy for index futures that combines a range-flip entry model on thechart timeframe with a market-structure bias taken from a higher timeframe. It only takestrades in the direction the higher timeframe is trending, and only when price has pulled backinto the discount half of the higher-timeframe range.The range flipA "range" here is defined by price action rather than a fixed window. When a candle closesbeyond the current range's high or low, that close is treated as meaningful — a new range isbuilt 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 structureThe strategy only takes longs when higher-timeframe structure is bullish and shorts when itis bearish. Two structure definitions are available:BOS — a higher-timeframe close beyond the last confirmed swing pointHH-HL sequence — successive higher highs and higher lows, or the bearish mirrorSwing points are confirmed with a configurable pivot length, so structure is only ever readfrom bars that have already closed.Location — the midline ruleBy default the strategy buys weakness inside strength: a long needs price below thehigher-timeframe range midline, a short needs price above it. This keeps entries on thepullback side rather than chasing extension. A breakout variant is available if you preferthe opposite behaviour.Entry, stop and targetEntry — a chart-timeframe range flip that agrees with bias and location, inside thesession window.Stop — the most recent confirmed swing pivot beyond the entry, plus a tick buffer. Thestop is frozen at the moment of the fill, so later swings never move it. Alternativereferences (the flip candle's own range, or the previous range) are selectable, and optionalminimum and maximum stop widths are available.Target — a multiple of the stop distance, set separately for each side. The default is1.5R on longs and 0.5R on shorts, reflecting that in testing the two sides did not behavesymmetrically. An optional breakeven rule can be armed at a chosen R multiple and applied toone side or both.Depth-based position sizingDepth measures where an entry sits inside the higher-timeframe range, normalised to rangewidth — 0.50 is the midline, 0.00 is the range edge, and a negative value means price isbeyond the edge while the higher timeframe has not yet flipped.When enabled, entries deeper than the threshold receive a larger multiplier. The idea is thatnot every pullback is equal, and the deepest ones can be treated differently from shallowones. Sizing can be applied to longs, shorts, or both.A separate depth gate can block entries outright unless they are deep enough — useful forisolating whether depth is what separates good entries from poor ones on your instrument.Optional filtersVolatility regime — requires daily ATR to sit above a chosen percentile of its ownrecent history. This model needs range expansion to reach its targets, and this stands itaside in quiet conditions. Off by default.VWAP — session or weekly anchored. Can require price above or below VWAP, or simplyblock 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 toone side. Off by default.Session windows — a general entry window plus a separate, later window for shorts.On-chart panelA live table reports bias state, current range, position, stop widths for both sides, filterstatus, and a signal funnel showing how many flips were blocked by each filter. It alsoreports average R — overall, split by side, and split by depth bucket. Net profit on astructural-stop strategy is influenced by how wide the stops happened to be, so average R isthe more honest read on whether a change actually improved entry quality.Default settings used for the published resultsInstrument and timeframe: NQ1!, 5-minute chart, higher timeframe 60-minuteInitial capital: 100,000 USDOrder size: 2 contracts, fixed quantityPyramiding: 0 — one position at a time, no scaling inCommission: 2.25 USD per contractSlippage: 1 tickBar detalization: High (~40 ticks per bar) — set this in PropertiesScript execution: on bar closeNotes and limitationsBacktested results are hypothetical and do not represent actual trading. Past performancedoes not guarantee future results, and no strategy performs the same across all marketconditions.Set bar detalization to High. With coarse detalization the backtester has to guess theorder of touches inside a bar, which flatters any strategy whose stop and target can both sitinside 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 chartholds roughly 250 trading days, so a 252 setting will return no data. The panel prints anexplicit 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 get4 contracts; fractional results are rounded and floored at 1.Sample size. The stricter filters and gates cut trade count quickly. If a configurationleaves you with only a few dozen trades, treat the result as indicative rather thanconclusive regardless of how good it looks.Defaults are a starting point, not a recommendation. Test on your own instrument, timeframeand cost assumptions before drawing conclusions.This script is published for educational purposes. It is not financial advice.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView