Loading…

History Pool Types Decoder

OrderType() in the history pool is not "buy or sell" the way a lot of sample code treats it. Six real order-type codes (0-5: two market types plus four pending types) share the same pool as broker-generated balance and credit entries (6 and 7), which have no order side, no symbol and no lot size. A common "sum OrderProfit() over every history entry" loop silently counts a deposit or a bonus credit as if it were a winning trade, inflating the reported result with money that never came from trading at all. This script walks the pool once and classifies every entry independently: executed market trades (OP_BUY/OP_SELL), pending orders that reached history without ever filling (cancelled or expired - a triggered pending's type flips to OP_BUY/OP_SELL at fill time, so a pending code in history can only mean it never went live), balance operations (deposits/withdrawals) and credit operations (bonus/adjustments). Each category is totalled on its own, and the script prints both the blended total a naive loop would have reported and the correct trading-only figure side by side, so the size of the mistake is visible rather than asserted. Notes and limitations OrdersHistoryTotal() only covers whatever the terminal's Account History tab has currently loaded, not necessarily the account's entire lifetime history - this is a platform limitation, not something the script can see past. Codes 6 and 7 (balance and credit) are not documented MQL4 constants; they are the values MetaQuotes' own long-standing sample code has used for the platform's balance-tab operations. Any code value above 7 encountered on an unusual broker is reported as UNRECOGNISED rather than guessed at.

Script · MT5 · v1.0 · Free

About History Pool Types Decoder

History Pool Types Decoder is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 1 setting, such as List every entry. MQL source code included.

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

Settings

SettingDefaultWhat it does
List every entrytruePrint one line per history entry (false = summary only)

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: Risk & Lot Size · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria