Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Marginal Drawdown Contribution Analyzer - script for MetaTrader 5

Real Author
Published by:
Cristian David Castillo Arrieta
Cristian David Castillo Arrieta
Finance and International Business professional with a specialization in Financial Management. Self-taught MQL5 and Python developer focused on algorithmic trading, multi-asset portfolio construction, and quantitative risk management.
Views:
54
Published:
MarginalDD.mq5 (25.91 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance



Standalone drawdowns and correlation matrices do not show which configuration of a multi-configuration portfolio deepens its drawdown. This script answers that question from daily results.

The script reads one of three sources and prints a full report in the Experts tab:

  • Drawdown added: The portfolio maximum drawdown minus the drawdown without the configuration (leave-one-out).
  • Share of the worst drawdown: The configuration's result between the peak and the trough of the portfolio's worst drawdown, as a share of that loss.
  • Euler variance share: Cov(x_i, P) / Var(P), shown next to the share of net profit.
  • A composite score (A+ to F): It combines drawdown compression, risk spread, drag-free share, and net profit to drawdown, with KEEP, REDUCE, and REMOVE verdicts and written recommendations.

Input. Select the source with InpSource. The demonstration source builds a reproducible portfolio of 12 configurations over 520 trading days, so the output is visible immediately. The account source reads the trading deals of the current account (profit + swap + commission + fee) and groups them by magic number, or by magic number and symbol. Deals closed by hand (magic 0) are assigned to the magic of the deal that opened the position. The CSV source reads a file from MQL5\Files with the header Date,Config,Profit and one row per closing deal or per day. The separator (comma or semicolon) is detected from the header, and numbers with spaces, a decimal comma, or accounting brackets are accepted.

Parameters. InpMinDays sets the minimum sample. InpReduceRatio and InpImproveMin control the REDUCE verdict, and InpMaxWindowShare controls the worst-drawdown alert. InpCompTarget, InpNeffTarget, InpDragTol, and InpRetDDTarget scale the four score dimensions. The four weights and the five grade boundaries are inputs too.

GDS Renko Trade Manager — MetaTrader 5 GDS Renko Trade Manager — MetaTrader 5

A manual-trade manager for MetaTrader 5: completed Renko bricks, configurable break-even and trailing Stop Loss, plus an on-chart Renko dashboard. No automatic entries.

CLiveTradeInfo - CHistoryTradeInfo CLiveTradeInfo - CHistoryTradeInfo

The library reconstructs a complete MQL4-style order model on top of the native MQL5 Position, Order, Deal, and History APIs. This design allows legacy MQL4 Expert Advisors to operate with minimal code changes while preserving MQL5.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.