Rolling Midpoint Engine [AGPro Series]Rolling Midpoint Engine
### Overview
Rolling Midpoint Engine is an on-chart study that converts the geometric midpoint of the last N bars' high-low range into a living control line. The midline is tracked through three behavioral states — Accepted Above, Accepted Below, and Fight — and a fourth modifier (Strong) highlights high-conviction acceptance beyond an ATR threshold. The goal is to surface how price behaves around a single dominant reference level, not to predict direction or issue trade signals.
### Unique Edge
Most midpoint tools plot a static line and let the user eyeball whether price accepts or rejects it. Rolling Midpoint Engine formalises that observation into a finite state machine that requires consecutive body-closes on one side of the midline before declaring acceptance. This filters single-bar noise and distinguishes casual tags from genuine commitment. The ATR-based Strong modifier adds a second axis of information — how firmly the current side is being held — without multiplying states or cluttering the chart with additional lines.
### Methodology
The midline is computed as the average of the highest high and the lowest low over a user-defined rolling window. Optional light EMA smoothing reduces visual jitter without materially shifting the level; a Strict Reset mode disables smoothing for pure rolling output.
Acceptance is evaluated through two streak counters tracking consecutive closes (or full bars, if the user prefers a stricter rule) on each side of the midline. When a streak reaches the Acceptance Bars threshold, the state transitions to Accepted Above or Accepted Below. If the running streak is positive but below threshold, the state is Fight. A Strong flag activates whenever the current distance from the midline exceeds a configurable ATR multiple.
All logic uses confirmed bar closes. The script does not repaint historical states once a bar has closed.
### States & Alerts
States:
- Fight — price is oscillating around the midline without sustained commitment
- Accepted Above — body-closes above the midline for the required number of bars
- Accepted Below — body-closes below the midline for the required number of bars
- Strong (modifier) — current Accepted state is held beyond the ATR threshold
Alerts:
- Midline Crossed Up / Down — raw price cross of the midline
- Accepted Above / Below — state transitions into acceptance
- Midline Rejection — state flip between Accepted Above and Accepted Below, or collapse from an Accepted state back to Fight
### Key Inputs
- Rolling Length — number of bars defining the range window
- Strict Reset Mode — toggle between pure rolling midline and lightly smoothed output
- Acceptance Bars — consecutive body-closes required for acceptance
- Use Body Close vs. Full Bar — strictness of the side-determination rule
- Strong Threshold — ATR multiple that qualifies an accepted side as Strong
- Label Style / Size — Edge Only, Edge + Transitions, or Off
- Panel Location / Theme / Font Size — four corners plus Middle Right, Dark / Light / Auto themes
- Color Midline by State — toggle state-coloring on the dominant line
### How to Use
Apply the indicator to any symbol and timeframe. The midline acts as a rolling control level; the state label on the right edge summarises the current behavior. Treat Accepted Above / Below as evidence that the midline is holding as support or resistance on the corresponding side. A transition into Strong indicates the holding is well beyond routine noise. A rejection event — the state flipping or collapsing back to Fight — suggests the prior control has been compromised.
This is a contextual reading tool. It does not produce entries, exits, targets, or stops, and should not be read as a recommendation to transact.
### Limitations & Transparency
The midline reflects past price data only and will adapt as new highs or lows enter the rolling window. On illiquid or very low-timeframe charts, the streak-based acceptance logic can feel slow; increasing Acceptance Bars on noisier instruments or lowering it on cleaner ones is expected tuning. The Strong Threshold is volatility-relative via ATR but still an arbitrary cut — defaults are calibrated for typical liquid markets and may need adjustment for thinly traded symbols.
The script uses confirmed closes and does not alter historical state once a bar has closed. Intrabar, the displayed state can update in line with current price, as with any live indicator.
### Risk Disclosure
This indicator is an analytical study. It is not a strategy, not a signal service, and not financial advice. It does not forecast future prices and does not guarantee any outcome. Past behavior of price around the midline does not imply future behavior. Every trading decision is the sole responsibility of the user. Use appropriate risk management and test the tool in a non-committed environment before incorporating it into any workflow.
Indicador Pine Script®






















