Warm Cache Builder
An EA or indicator that needs to precompute something expensive per symbol before it can start making real decisions - a per-symbol statistic, a correlation table across a watchlist, anything genuinely costly - usually just does it all in one long OnInit() call. For a short watchlist that is fine; for a longer one, or a genuinely slow per-item computation, that blocks the terminal for the whole duration with no visible progress and no way to spread the work across several ticks instead. CWarmCacheBuilder gives that warm-up a step-driven shape instead. Register the full list of work-item keys once with Begin(), then loop calling NextPending() to get the next not-yet-warmed key, compute that one item's value however you like, and hand it back with Complete(). ProgressReportLine()/ProgressPercent()/ElapsedSeconds() give a ready- made status line to print or show on a chart comment after each step, so a warm-up that takes a few seconds is visibly progressing rather than looking hung. MQL4 has no first-class function pointers, so this header genuinely cannot call an arbitrary "compute this item" function on the caller's behalf - that is why the API is a pull-one/report-one loop rather than a single "warm everything now" call. This is a deliberate design choice, not a missing feature: it is also what makes the same builder usable across several OnTimer()/OnTick() calls (one NextPending()/ Complete() per call) if the caller wants to spread genuinely slow work out instead of doing it all in one blocking pass. Notes and limitations - This header only manages the WORK LIST and progress bookkeeping - it does not compute anything itself, has no timer of its own, and does not decide how many items to process per call. The caller controls that entirely (all-at-once in OnInit(), or a handful per OnTimer() tick). - Values are stored as plain strings. Encode a numeric result with DoubleToString()/IntegerToString() before calling Complete(), and parse it back out with StrToDouble()/StrToInteger() after TryGetWarm() - there is no typed variant. - A second Begin() call with a different key list discards all previous progress and warmed values outright - this header manages exactly one warm-up cycle's work list at a time, not a history of past cycles. - Lookup (NextPending(), Complete(), TryGetWarm()) is a linear scan over the registered keys. Fine for the tens of watchlist-sized items this header is meant for; not intended for a work list of thousands.
Script · MT5 · v1.0 · Free
About Warm Cache Builder
Warm Cache Builder is a script for MetaTrader 5. It shows several symbols in one panel and is set up for gold (XAUUSD). MQL source code included.
Files in the download: WarmCacheBuilder.mq5.mqh, WarmCacheBuilder.txt, WarmCacheBuilderDemo.ex5, WarmCacheBuilderDemo.mq5.
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Dashboards & Scanners · Gold (XAUUSD) · MT5 Script · MQL5 Source Code