Loading…

Input Registry Emulator

A real `input` is fixed at compile time - the input dialog and .set file support come free, but nothing in the program can list "what parameters do I have and what are their current values" at runtime, because MQL4 has no reflection API at all. Anything that wants a dynamic, named, typed parameter list - a config panel built from a loaded preset, a generic .set-file-style dumper, a parameter set swapped between named profiles - has to build that bookkeeping by hand, every time, from scratch. This header is that bookkeeping, done once. CInputRegistry holds one parallel set of fixed-size arrays per concrete type (int, double, bool, string - MQL4 has no variant type to unify them), looked up by name with a linear scan, since that is the only kind of "find a field by name" MQL4 can do at all. Numeric entries can carry an optional min/max range supplied at registration time; SetInt/SetDouble clamp silently to that range rather than rejecting an out-of-range value outright, which suits a config-panel use case where a slider or typed field should just settle at the boundary. A duplicate registration or a type-mismatched set/get is rejected and logged rather than silently overwriting or coercing, so a copy-paste mistake in a long list of Register calls shows up in the journal immediately instead of producing a quietly wrong value later. This does not replace real `input` declarations, and is not trying to - it is for parameters a program builds or receives dynamically, after compile time, where a real `input` cannot apply. Notes and limitations - Capped at 64 entries (INPUT_REGISTRY_MAX_ENTRIES), fixed at compile time. Registration past the cap is rejected and logged, not silently dropped. - Lookup is a linear scan by name - fine for tens of entries in a config panel, not intended as a general-purpose associative container for thousands of keys. - The min/max range on a numeric entry only applies through SetInt/ SetDouble; setting the default value directly at RegisterInt/ RegisterDouble time is never clamped, since that value is the registration call's own explicit choice. - A min==max pair (including the 0/0 default) is treated as "no bound", matching the convenience of not having to pass a range for an unrestricted field. - This is an in-memory registry only - it does not persist to or load from a .set file itself; EntryToString's "name=value" shape is chosen to make pasting into one by hand straightforward.

Script · MT5 · v1.0 · Free

About Input Registry Emulator

Input Registry Emulator is a script for MetaTrader 5. It has 1 setting, such as Out of range attempt. MQL source code included.

Files in the download: InputRegistryEmulator.mq5.mqh, InputRegistryEmulator.txt, InputRegistryEmulatorDemo.ex5, InputRegistryEmulatorDemo.mq5.

Settings

SettingDefaultWhat it does
Out of range attempt500Value deliberately outside RiskPercent's registered 1..20 range, to show clamping

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

MQL4 & MQL5 scripts · PolyMaria