Trend Survival Rate
- 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
- Activations: 10
Trend Survival Rate for MetaTrader 5 — a market regime indicator that measures how often the current trend state has survived to the next bar, and scores its own forecast
Trend survival rate, market state classification and a live Brier forecast score, in one MT5 indicator window. It measures the buying and selling pressure behind the current move, classifies that into a market state, and reports how often that state has survived to the next bar — then grades its own forecast against what actually happened.
Most indicators tell you what conditions are. This one also tells you how often that reading has been followed by more of the same, and how well it has been doing lately.
A free version is available: Trend Survival States. It draws the identical pressures, spread, bands and five-state classification — the survival rate and the forecast score are what this paid version adds. Both can run on the same chart at the same time.
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: strong bull, weak bull, neutral, weak bear, strong bear. 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 survival rate
For the state the market is in now, the indicator searches back through the configured history and counts every bar that was in the same direction family. Of those, it counts how many were still in that family on the next bar. The survival rate is that ratio.
Survival is measured by direction family, not by exact state. Weak bull becoming strong bull is a trend continuing, not a trend ending. Requiring an exact match made the number pessimistic in precisely the moves traders care about, and made it read highest when nothing was happening.
The rate is shown only once the minimum number of observations has been collected. Below that it shows a dash, because a percentage computed from four samples is not a percentage worth reading.
The forecast score, and why it is not inverted
The survival rate is a one-step-ahead forecast: it says how likely the current state is to persist. So it can be scored against what actually followed, and it is — with a Brier score over a rolling window.
0 is perfect. 0.25 is what you would score by always saying "fifty-fifty". Lower is better. The raw score is published rather than an inverted, friendlier-looking version, because a Brier score is a standard statistic and a number climbing toward 100 would look like a performance figure. This one forces the honest question — compared to what? — and answers it on the chart.
This means the indicator can and sometimes does report that its own forecasts have been poor. That is the intended behaviour. A measure that cannot show a bad result is not a measure.
Calculation behaviour — read this before the screenshots
The survival rate moves independently of the market state, and this is correct. One verification run produced 89.4%, 89.7%, 89.7%, 86.5% and 73.3% — and the lowest of those sat beside a strong bull state with bull pressure at 100%.
The two numbers answer different questions. The state is where the market is now. The survival rate is how often that state has persisted historically. A maximally bullish reading next to a mediocre survival number is the indicator measuring rather than agreeing with itself.
A long uninterrupted trend reads 100%. Not because continuation is certain, but because the direction family has not broken anywhere in the searched history. It is a statement about the past, and the searched window is a setting you control.
Shortening the history raises the rate. Reducing the searched history from 100 bars to 10 moved a reading from 95.2% to 100.0% on the same chart and the same bar. Fewer observations, fewer breaks, a flattering number. That is what the minimum-observations guard exists to prevent, and it is why the default window is long.
Values are calculated from completed bars. The survival search starts two bars back so the currently forming bar cannot contaminate the count. Closed values do not repaint.
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 raw values remain available in the buffers for an Expert Advisor that wants them.
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.
- History searched for the survival rate — how far back to look for comparable states. Default 100.
- Minimum observations — below this the rate shows a dash instead of a number. Default 10.
- Forecast score lookback — the rolling window for the Brier score. Default 20.
- Dashboard — show or hide, place it on the price chart or in the indicator window, text size, colours and offsets.
Buffers for Expert Advisors
Eleven plots, seven drawn and four data-only. All eleven are readable with iCustom() and CopyBuffer() , and all eleven 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 — Survival rate, 0 to 100
- Buffer 10 — Forecast score, raw Brier, 0.0 to 1.0
- Buffer 11 — State age, bars the current state has held
Buffers 9 and 10 are what this version adds. The survival probability is handed to your own code rather than consumed internally, so an EA can act on the number, log it, or filter with it. The score is the raw statistic, not a display transform.
Read shift 1 — the last fully closed bar — for values that will not change.
What the screenshots show
- XAUUSD Daily — Trend Survival Rate and Trend Survival States on one chart, in separate windows. Same bar, same settings. The pressures, spread and bands are identical; the paid version adds the survival rate and the forecast score.
- Strategy Tester, XAUUSD Daily — a STRONG BEAR reading while price sits near its high. Bear pressure 89%, balance −77, survival rate 86.7%. The state is measured from pressure, not from the direction of the last few candles, and this is what that difference looks like.
- US30 Daily — the Trend Survival Rate settings dialog and Data Window. Eleven Data Window rows on the closed 14 August bar: survival rate 91.8033, forecast score 0.0907, state age 2.
- US30 Weekly — both versions on a clean uptrend. Survival rate 91.4%, forecast score 0.16, while the state reads NEUTRAL. The state and the trend are different questions.
- Strategy Tester — STRONG BULL with bull pressure at 100%, and a survival rate of 80.0%. The two numbers move independently, which is correct and is explained above.
- BTCUSD Daily — a state transition, with the hold counter resetting.
- Tesla Daily — a ranging instrument, where the states change often and the survival rate falls accordingly.
- DAX (DE30) Daily — the same defaults on an index, no re-tuning.
- EURUSD Daily — a major pair, survival rate 89.8%, forecast score 0.09.
- Strategy Tester — STRONG BULL, survival rate 89.7%. The panel renders and updates live in visualisation mode, which most indicator panels do not survive.
- US30 Daily — the Trend Survival States settings dialog and Data Window, same bar. Nine rows rather than eleven, and no survival settings, because this free version does not compute them.
Notes
- Separate indicator window, 7 drawn plots and 4 data-only.
- Around 120 bars of history are needed before the survival rate can be shown at the default settings.
- 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.
- A high minimum observations setting can leave the forecast score blank for long stretches — a forecast that was never made cannot be graded. Lower it, or lengthen the history, if the score matters more than the strictness.
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 — and the forecast score exists precisely so that its own accuracy is visible rather than asserted.
| 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 survival rate, 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.
