Series Indexing Visualiser
Close[], Time[], High[] and Low[] are SERIES arrays: index 0 is always the current, rightmost, newest bar, and the index climbs going back in time. That is the opposite of how a beginner naturally builds their own array - loop forward through the requested range and fill index 0 first - which puts the OLDEST bar at index 0 and climbs the index FORWARD toward the present, the exact reverse direction. Both are, to the compiler, just "an array of doubles". Mixing the two conventions in the same calculation compiles cleanly and runs without error; it just quietly computes the wrong bar. This script makes the mapping visible rather than describing it. It reads the last N bars (a small default, kept readable), builds a genuine plain array by looping forward and filling index 0 with the oldest close in the range exactly the way a beginner's helper function typically does, and then labels every bar on the chart twice: a blue label above showing its series index (Close[shift]'s own numbering), and an orange label below showing where the identical bar sits in the plain array. The full mapping is also printed to the log as a table. Standing the two labels side by side on the same physical bar makes the direction reversal obvious in a way that reading the index formula in isolation does not. Notes and limitations - This is a read-only visual/teaching script - it draws chart objects and prints to the log only, sending no orders and needing no trading account. - The drawn labels persist on the chart after the script finishes running, by design - a script's OnDeinit fires immediately once OnStart returns, so deleting the objects there would erase the very visualisation the script exists to show. Run the script again with InpCleanupFirst left on to refresh the labels, or delete them manually (they are all prefixed "sidx_") when finished studying them. - If fewer than InpBarsToShow bars of history are loaded, the script uses whatever is available rather than refusing outright, and reports the actual count used in the log.
Script · MT4 · v1.0 · Free
About Series Indexing Visualiser
Series Indexing Visualiser is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Bars to show, Series color and Array color. MQL source code included.
Files in the download: SeriesIndexingVisualiser.mq4, SeriesIndexingVisualiser.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Bars to show | 12 | How many recent bars to label (kept small to stay readable) |
| Series color | clrDodgerBlue | Label colour for the series index (above the bar) |
| Array color | clrOrange | Label colour for the plain array index (below the bar) |
| Label font size | 8 | Label font size |
| Cleanup first | true | Delete this script's previous labels first |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code