Loading…

Order Comment Survival Tester

OrderSend() accepts a comment string, but nothing guarantees the broker keeps it. Some back ends silently cap it at 31 characters, some rewrite it on execution (a common one: prepending "tp" or "sl" text, or the dealer's own routing note), and a few strip characters they consider unsafe. None of this is documented per broker, and by the time a trader notices their own comment came back mangled, it is usually because a reconciliation report already depended on it. This script tests it directly rather than guessing. It sends several small demo trades, each carrying a different probe comment: a short one, one exactly at the historical 31-character MetaTrader comment limit, one a character past it, and a few carrying punctuation, slashes, quotes and non-ASCII text that some servers are known to touch. Immediately after each order fills it reads the comment back with OrderComment() - this is "as accepted". After closing every test order it reads the comment again from the same ticket, now sitting in history - this is "as history". The two readings can differ even when the fill reading looked fine, because some brokers only rewrite a comment once the trade settles into their permanent record. Every opened test order is closed before the script finishes, and the closing step is written to run again unconditionally at the very end of OnStart regardless of what happened earlier in the run - a probe script has one job it cannot fail at, which is not leaving trades open behind it. Notes and limitations - Tests only what this broker's server does to a comment on THIS account type and THIS symbol; results are not guaranteed to generalise to other account types (ECN vs standard) or other symbols on the same broker. - The "as history" reading happens moments after close, in the same terminal session. It cannot detect a rewrite that only happens on a server-side end-of-day batch job or a statement export, since neither is observable from inside a running script. - Refuses to run on a live account by design (IsDemo() check) - there is no way to bypass this from the input dialog, and none should be added. - Opens real (if minimal) demo trades. A demo account with trading disabled, or a symbol with no minimum-lot market orders allowed, will show every test as FAILED TO OPEN. - If InpConfirmRunOnDemo is left false, the script exits immediately after printing a reminder - this is expected, not an error.

Script · MT5 · v1.0 · Free

About Order Comment Survival Tester

Order Comment Survival Tester is an expert advisor (trading robot) for MetaTrader 5. It has 3 settings, such as Confirm run on demo, Number of test trades and Seconds between trades. MQL source code included.

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

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Confirm run on demofalseMust be set TRUE to actually open test trades
Number of test trades4How many marker comments to test (max 8)
Seconds between trades1Pause between opening each test trade

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 → Experts.
  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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria