Computed Series Cache
Two independent things can make a cached computed series stale, and a correct cache has to catch both, not just one. First, a new bar can arrive - the signal every indicator author remembers, usually by watching rates_total or Bars. Second, the PARAMETERS behind the computation can change - a period input edited on a running indicator, or the same function called for a different purpose with a different lookback - which most home-grown caching attempts miss entirely, because the bar count alone gives no clue that the parameters underneath it are different this time. This header asks the caller for both pieces explicitly: a bar count (rates_total in an indicator, Bars in a script or EA - whatever the caller considers authoritative) and a fingerprint string built from every parameter that affects the computation via BuildFingerprint(). A cached series is only ever served back when BOTH match exactly what was stored at the last Store() call. Either one changing - a genuinely new bar, or the same bar count under different parameters - is treated as a full invalidation, no partial reuse attempted. A bar-count match with a stale fingerprint would silently return the WRONG parameters' series - the actual bug this header exists to prevent, and the one that is hardest to notice in testing because the numbers still look plausible, just computed under the old settings. Notes and limitations - Holds exactly one cached series at a time - this is a single-slot cache, not a keyed multi-entry store. A tool that needs several independent cached series (e.g. one per symbol) needs one instance of this class per series, not one shared instance. - The caller is entirely responsible for including every parameter that affects the computation in the fingerprint - an omitted parameter is the one way this cache can still serve a stale result, and no amount of bar-count checking catches it. - Series values are double only. - No money is at risk in the demo. It caches a synthetic smoothed array only and never sends an order.
Script · MT5 · v1.0 · Free
About Computed Series Cache
Computed Series Cache is a script for MetaTrader 5. It has 1 setting, such as Period. MQL source code included.
Files in the download: ComputedSeriesCache.mq5.mqh, ComputedSeriesCache.txt, ComputedSeriesCacheDemo.ex5, ComputedSeriesCacheDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 5 | Smoothing period used by the synthetic expensive computation |
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: Buy/Sell Arrows · MT5 Script · MQL5 Source Code