Downside Deviation And Sortino Panel
Standard deviation punishes a big rally exactly as much as a big selloff. For a trader who only cares about losing money, that is the wrong statistic. This indicator computes the real downside-deviation formula instead: over a rolling window of InpWindow bars, every return at or above InpTargetReturn contributes exactly zero to the risk figure, and only the shortfall of returns BELOW that target is squared and averaged - using the full window as the denominator, not just the count of losing bars, which is the standard Sortino-style definition rather than a "stdev of losing bars only" shortcut that some simplified versions use. The Sortino ratio line divides the window's mean excess return (mean return minus InpTargetReturn) by that same downside deviation. Because upside volatility never enters the denominator, the Sortino ratio can rise even during a period of large day-to-day swings, as long as those swings are mostly to the upside - a case where a Sharpe-style ratio built on plain standard deviation would stay roughly flat or even fall. Notes and limitations - Both lines use close-to-close log returns on the chart's own timeframe, expressed in native per-bar terms - neither is annualised, since annualising needs a trading-days assumption that varies by broker and symbol. - When a window has no downside shortfall at all (every return met or beat target), the Sortino Ratio line is left blank rather than shown as an artificial "infinite" reading - Downside Dev% would read zero in that same window. - InpTargetReturn is a log-return figure (small decimals, e.g. 0.0005 for roughly 0.05% per bar), not a percentage or a pip count. - Describes historical risk-adjusted performance of price action itself; it does not know about your entries, exits, or position sizing.
Indicator · MT5 · v1.0 · Free
About Downside Deviation And Sortino Panel
Downside Deviation And Sortino Panel is an indicator for MetaTrader 5. It has 2 settings, such as Window and Target return. MQL source code included.
Files in the download: DownsideDeviationPanel.ex5, DownsideDeviationPanel.mq5, DownsideDeviationPanel.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Window | 20 | Bars of trailing returns used for each rolling reading |
| Target return | 0.0 | Minimum acceptable per-bar log return (0.0 = anything negative is downside) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: MT5 Indicator · MQL5 Source Code