Guarda come scaricare robot di trading gratuitamente
Ci trovi su Twitter!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Script

Trade History in R - script per MetaTrader 5

Visualizzazioni:
73
Valutazioni:
(1)
Pubblicato:
Freelance MQL5 Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

Profit in money does not tell you much about a trading method: a 100 dollar profit can be a great trade with a small stop or a lucky one with a huge stop. Measuring every trade in R (the result divided by the money that was at risk at entry) makes trades with different volumes, symbols and stops comparable. An expectancy of +0.2 R per trade means the same thing on a 1 000 and on a 100 000 account.

This script reads the closed positions of the account, finds the initial stop loss of every position and shows the statistics in R in a panel on the chart. It is read only: it does not open, modify or close anything.

Report of 369 random trades (stop 1 ATR, target 2 ATR) in the Strategy Tester, XAUUSD H1

What is shown

  • Number of closed positions, how many had a stop loss and how many were skipped (no stop loss, so the risk is unknown).
  • Net result of all positions in the account currency.
  • Total R, expectancy (average R per trade), win rate, profit factor, best and worst trade.
  • Maximum drawdown in R and the longest losing streak.
  • The same per symbol.

Input parameters

  • Days back (0 = whole history).
  • Magic number (-1 = all trades, 0 = manual trades only, or the magic number of one Expert Advisor).
  • Symbol (empty = all).
  • Export to CSV: every position with its initial stop, risk, net result and R is saved to MQL5\Files\TradeHistoryInR.csv.
  • Show the panel on the chart (run the script again to refresh it).

How R is calculated

The initial stop loss is taken from the opening deal (DEAL_SL) or, if it is empty, from the order that opened the position. Moving the stop later (breakeven, trailing) does not change the risk: R is always measured against the risk at entry. The money at risk is the loss at the initial stop for the opening volume, calculated with OrderCalcProfit (tick value as a fallback). The result includes swap, commission and fees. For cross-currency symbols OrderCalcProfit uses current rates, so the risk of old trades is approximate.

How it was checked

In the Strategy Tester an Expert Advisor opened 369 random trades on XAUUSD H1 with a stop of 1 ATR and a target of 2 ATR. The script reported the trades closed at the stop as -1.00 R (median) and the trades closed at the target as +2.00 R (median), as expected. The picture shows the report of that run.

Risk Lot From Stop Line Risk Lot From Stop Line

Drag a stop line on the chart and see the volume for a given risk, the real risk after rounding, and a warning when even the minimum volume risks too much.

HTF EMA No Lookahead HTF EMA No Lookahead

Higher-timeframe EMA (fast and slow) on a lower-timeframe chart, using only higher-timeframe bars that are already closed. Values never change after the bar closes.

Prop Firm Equity Guard daily loss and max drawdown protector Prop Firm Equity Guard daily loss and max drawdown protector

Prop Firm Equity Guard protects prop-firm challenges and funded accounts. It monitors live equity against your daily loss and max drawdown limits, then closes all positions, deletes pending orders and locks trading before the firm's limit is hit. A safety buffer makes it act early, and anything opened while locked is closed instantly. It supports static and trailing drawdown, an optional profit target lock and alerts, saves its state through restarts, and shows an on-chart dashboard with room left and a reset countdown. It works alongside manual trading and other EAs.

History Gaps: find missing bars before you backtest History Gaps: find missing bars before you backtest

Checks the chart's history against the symbol's trading sessions and separates real holes from holiday short sessions and days without bars. Marks the holes on the chart, shows coverage and the largest hole, warns when the history stops short of now, and can write a CSV report.