Loading…

R Multiple Tracker

Van Tharp's R multiple framework expresses a trade's result as a multiple of what was actually risked on it, not as raw money: a $200 win on a $100 risk is 2R whether the account is $1,000 or $100,000, which is what makes expectancy in R comparable across symbols, position sizes, and even different accounts trading the same system. The naive way to compute it is to read the stop-loss distance from the order at the moment it closes and use that as "what was risked". That is wrong the instant a trailing stop, a breakeven move, or a manual adjustment has touched the order before it closed - a trade that was genuinely a 3R winner measured against its original 20-pip stop reads back as a tiny fraction of an R once the stop has since been dragged to within two pips of the exit, quietly corrupting every expectancy figure built from it. This EA fixes that by capturing each order's risk the moment it is FIRST seen open - expressed as money per point per lot so it still applies correctly even to a later partial close of any size - and storing it keyed by ticket number so it survives a terminal restart. Every later R calculation uses that frozen figure, never the stop loss as it happens to read when the trade eventually closes. Notes and limitations - A trade opened with no stop loss has no defined initial risk and cannot be expressed as an R multiple; it is logged with RiskEstimated and counted separately as "unclassified" rather than guessed at. - On MQL4, a partial close creates a new ticket in the history pool that was never itself seen as an independently open position, so that leg falls back to whatever stop loss is recorded on that history entry at the moment of the partial close, flagged "RiskEstimated=yes" - honest, but potentially less precise than the true initial risk if the stop had already moved before the partial close happened. Full, non-partial closes are always exact. This gap does not exist on MQL5 - see "MQL4 versus MQL5 differences" above. - The per-trade GlobalVariable is deleted once no further exits are possible for it (MQL4: on classification; MQL5: once no open position with that identifier remains), so the account does not accumulate one GlobalVariable per historical trade indefinitely.

Expert advisor · MT4 · v1.0 · Free

About R Multiple Tracker

R Multiple Tracker is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Magic filter, Csv file name and Global var prefix. MQL source code included.

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

Settings

SettingDefaultWhat it does
Magic filter0Only track this magic number (0 = all magic numbers)
Csv file nameRMultipleTrackerEa.csvClosed-trade R log, in MQL4\Files
Global var prefixRMT_R_Prefix for the per-ticket initial-risk GlobalVariables
Reset statsfalseSet true and re-apply inputs to clear all tracked stats and stored risk
Redraw seconds5Seconds between panel refreshes

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: Risk & Lot Size · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria