Loading…

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 · MT4 · v1.0 · Free

About Downside Deviation And Sortino Panel

Downside Deviation And Sortino Panel is an indicator for MetaTrader 4. It has 2 settings, such as Window and Target return. MQL source code included.

Files in the download: DownsideDeviationPanel.ex4, DownsideDeviationPanel.mq4, DownsideDeviationPanel.txt.

Settings

SettingDefaultWhat it does
Window20Bars of trailing returns used for each rolling reading
Target return0.0Minimum acceptable per-bar log return (0.0 = anything negative is downside)

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria