Loading…

Risk Of Ruin Teaching Grid

"Risk of ruin" is usually quoted as a single scary or reassuring number for one specific win rate and one specific risk-per-trade setting. This script prints the whole grid instead - every combination of win rate and risk-per-trade across the chosen ranges - so a trader can see how steeply the ruin probability climbs as risk-per-trade increases, and how much a few percentage points of win rate can offset it. The formula used is the classic even-money gambler's ruin: edge = 2 x win rate - 1, then ruin probability = ((1 - edge) / (1 + edge)) raised to the power of (100 / risk-per-trade). It assumes a fixed fraction of capital is risked on every trade and that wins and losses are the same size (1:1 payout) - a simplification stated plainly in the output itself, not a claim that real systems pay 1:1. Optionally, the trader's own account win rate can be measured from closed history and printed as an extra row, so the grid includes a number the trader recognises alongside the classroom reference values. Notes and limitations - The 1:1 payout assumption means any win rate at or below 50% shows 100% ruin here, because the formula gives it no edge at all. A real system with an asymmetric payout (bigger average wins than losses) can have a genuine positive edge at a sub-50% win rate - this grid does not model that case; it needs the fuller Ralph Vince style risk-of-ruin formula, which is out of scope for this teaching tool. - Account-history mode measures win rate only (wins/total by profit sign); it does not check whether the account's real payout ratio is close to 1:1, so the "your account" row should be read as illustrative unless wins and losses really are similar sizes. - This is a probability model of an idealised repeated bet, not a prediction for any specific real strategy.

Script · MT5 · v1.0 · Free

About Risk Of Ruin Teaching Grid

Risk Of Ruin Teaching Grid is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Use account history win rate, Magic filter and Symbol filter. MQL source code included.

Files in the download: RiskOfRuinTeachingGrid.ex5, RiskOfRuinTeachingGrid.mq5, RiskOfRuinTeachingGrid.txt.

Settings

SettingDefaultWhat it does
Use account history win ratefalseIf true, also print your account's own measured win rate row
Magic filter-1Account-history mode only: magic filter (-1 = all)
Symbol filterAccount-history mode only: symbol filter ("" = all)
Grid win rate start pct30.0Grid's first win-rate row, percent
Grid win rate max pct70.0Grid's last win-rate row, percent
Grid win rate step pct5.0Increment between win-rate rows
Grid risk start pct1.0Grid's first risk-per-trade column, percent
Grid risk max pct5.0Grid's last risk-per-trade column, percent
Grid risk step pct1.0Increment between risk-per-trade columns

How to install

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

Download the PDF guide

Tags: Grid · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria