Trend Survival States
- Indicators
-
Narayanan Mohanan Mohanan Krishnan
I build measurement tools for MetaTrader. They describe what the market has done, and state the limits of each measurement rather than hiding them. - Version: 1.5
Trend Survival States for MetaTrader 5 — a free market regime indicator measuring bull and bear pressure with adaptive volatility bands and a five-state trend classification
Bull and bear pressure, an adaptive-band spread, and a five-state market classification, free for MT5. It measures the buying and selling pressure behind the current move and classifies that into a market state: strong bull, weak bull, neutral, weak bear, strong bear.
This is a complete regime indicator, not a time-limited trial and not a crippled demo. Everything drawn on the chart is the full calculation.
What the paid version adds. Trend Survival Rate reports how often the current state has survived to the next bar, and scores that forecast against what actually happened using a Brier score. Those two numbers, and the settings that govern them, are what this free version does not include. Everything else is identical — and both can run on the same chart at the same time, so the difference is visible rather than described.
How it works
Two pressure components are computed from price: an upper envelope and a lower one, each measured over a lookback window. The difference between them is the spread, and its sign says which side is dominant. Adaptive standard-deviation bands over the spread say whether that dominance is ordinary or unusual for this instrument.
Sign and bands together classify every completed bar into one of five states. The sign decides direction; the bands decide conviction.
A note on the envelope mapping, because it is counter-intuitive and worth stating: the upper envelope is a ceiling that sits far above price during a downtrend, so its variance measures bear pressure. The lower envelope is a floor that lags below price during an uptrend, so it measures bull pressure. The crossed mapping is deliberate and correct.
Input series is close . Not high/low — the extremes already capture excursion, and using high/low would double-count it. Stated here so the values can be reproduced.
The dashboard
Bull and bear pressure are shown as percentage shares of total pressure, not as raw values. The raw terms carry the instrument's price units: the same reading is 28.48 on gold and 0.0003 on EURUSD, and on a low-priced cross both round to zero while still being meaningfully different. The shares are the comparable quantity, so the shares are what the dashboard shows. Balance runs from −100 (all bear) through 0 (even) to +100 (all bull), and reads the same on every instrument and timeframe.
The dashboard also reports the current state and how many bars it has held. The raw values remain available in the buffers for an Expert Advisor that wants them.
Calculation behaviour
Values are calculated from completed bars. Closed values do not repaint.
The five-state classification is not symmetric in duration — a neutral reading can persist for many bars on a quiet instrument, and a strong state can last one bar. The state age field on the dashboard is there so this is visible rather than inferred.
Inputs
- Pressure lookback — the window for both envelope components. Default 21.
- Signal line period — smoothing for the signal line. Default 9.
- Spread smoothing — 1 turns it off. Default 5, chosen by measurement: at 20 the states barely changed, at 1 the spread was too jagged for the strong/weak comparison.
- Bands period and band width — the window and width that decide conviction. Default 20 and 1.0 — one standard deviation, the boundary of ordinary variation.
- Dashboard — show or hide, place it on the price chart or in the indicator window, text size, colours and offsets.
The settings that govern the survival rate and the forecast score are not shown in this version, because this version does not compute them. A control that changes nothing is worse than an absent one.
Buffers for Expert Advisors
Nine plots, seven drawn and two data-only. All nine are readable with iCustom() and CopyBuffer() , and all nine appear in the Data Window.
- Buffer 0 — Bull Pressure
- Buffer 1 — Bear Pressure
- Buffer 2 — Signal
- Buffer 3 — Spread (bull − bear)
- Buffer 4 — colour index for the spread histogram, not a data series
- Buffer 5 — Upper Band
- Buffer 6 — Band centre
- Buffer 7 — Lower Band
- Buffer 8 — State: 2 = strong bull, 1 = weak bull, 0 = neutral, −1 = weak bear, −2 = strong bear
- Buffer 9 — State age, bars the current state has held
Read shift 1 — the last fully closed bar — for values that will not change.
In Trend Survival Rate, buffer 9 is the survival rate and buffer 10 the forecast score, with state age at 11. An EA written against this free version reads buffers 0 to 8 identically in both, so the shared series need no code changes; only the survival buffers differ in position.
What the screenshots show
- US30 Daily — the Trend Survival States settings dialog and Data Window, closed 14 August bar. Nine rows, ending at state age.
- XAUUSD Daily — Trend Survival States and Trend Survival Rate on one chart, in separate windows. Same bar, same settings. The pressures, spread and bands are identical in both; the paid version adds the survival rate and the forecast score.
- US30 Weekly — both versions on a clean uptrend, with the state reading NEUTRAL. The state and the trend are different questions.
- Tesla Daily — a ranging instrument, where the states change often.
- DAX (DE30) Daily — the same defaults on an index, no re-tuning.
- EURUSD Daily — a major pair.
- BTCUSD Daily — a state transition, with the hold counter resetting.
- US30 Daily — the Trend Survival Rate settings dialog and Data Window, same bar, for comparison: eleven rows, and the survival settings this free version does not carry.
Notes
- Separate indicator window, 7 drawn plots and 2 data-only.
- No external dependencies. Everything is calculated inside the indicator; it calls no other indicator.
- Multiple instances on one chart are supported. Two copies with different settings each keep their own dashboard. Two copies with identical settings share one: MetaTrader loads the program once and serves both windows from it, so there is a single dashboard to draw. The plots are unaffected either way.
- This version and Trend Survival Rate use different program names, so they run side by side without interfering with each other.
This indicator is a tool for technical analysis and market-condition measurement. It is not a trading system, it does not generate trading signals, it does not provide investment advice, and it does not open or manage trades automatically. No performance claims are made for it.
| More tools from this developer I build MT5 indicators and Expert Advisors with an emphasis on clean, documented, no-repaint code — closed-bar logic, validated buffers, and no dependencies on other indicators. Questions about the calculation, the states, or using this in your own EA? Send me a private message — I am happy to answer. |
Developed and maintained by Narayanan Mohanan, MT5/MQL5 Developer.
