Loading…

UUID Generator

Any program that logs to a file, calls a webhook, or draws chart objects across multiple symbols eventually needs a short id that will not collide with the last one. This header generates them in the standard 8-4-4-4-12 UUID shape. Say plainly what this is not: neither platform has a cryptographic random source or access to a MAC address or hardware id, the usual entropy inputs for a real RFC 4122 generator. What this header actually does is mix MathRand() with the tick count, the account login number, and a per-run counter, then stamp the version and variant bits so the output is structurally a valid v4 UUID. That is enough for "practically will not collide within one program's lifetime" - log correlation ids, chart object name prefixes, request ids for an outbound webhook. It is not enough for anything where an id must be unguessable, such as a security token or a password reset link. Do not use it for that. UuidGenerateCompact drops the dashes for the common case of building a chart object name prefix, where the dashes cost length and buy nothing. UuidIsValid checks structure only - length, hyphen positions, hex digits - so it also accepts UUIDs generated elsewhere (v1, v5, a database default) that this header did not create itself. Notes and limitations - Not cryptographically secure and not suitable for security tokens, password reset links, or anything where an attacker guessing the value matters. - Global module-level counter shared within one running program's copy of the header. Two separate programs on the same terminal do not share it, and do not need to - each has its own independent sequence. - Collision probability is not zero, only very small for the volumes a typical EA or script log would generate in a session. Do not use these as a primary database key without an additional uniqueness constraint.

Script · MT5 · v1.0 · Free

About UUID Generator

UUID Generator is a script for MetaTrader 5. It has 2 settings, such as Sample count and Unique check. MQL source code included.

Files in the download: UuidGenerator.mq5.mqh, UuidGenerator.txt, UuidGeneratorDemo.ex5, UuidGeneratorDemo.mq5.

Settings

SettingDefaultWhat it does
Sample count10How many ids to print and validate
Unique check2000How many ids to generate for the collision check

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: Bitcoin & Crypto · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria