2026-09-06 11:15:27 -05:00
|
|
|
[← Utils](../README.md)
|
|
|
|
|
|
|
|
|
|
# Utils/TfI
|
|
|
|
|
|
|
|
|
|
O(1) timeframe lookup tables — avoids scattered `switch(ENUM_TIMEFRAMES)` blocks across the codebase.
|
|
|
|
|
|
|
|
|
|
## Main features
|
|
|
|
|
- Timeframe → period in seconds, via a precomputed table (`g_mqlarticles_tfi_period_s`).
|
|
|
|
|
- Timeframe → descriptive names (full enum name, short uppercase, short lowercase) (`g_mqlarticles_tfi_desc` / `MqlArticlesTfiDesc`).
|
2026-09-06 11:25:00 -05:00
|
|
|
- A hash-based jump table (seeds + final table) for fast lookups instead of linear search (generated via SimPHash).
|
2026-09-06 11:15:27 -05:00
|
|
|
|
|
|
|
|
## Basic usage
|
|
|
|
|
```mql5
|
2026-09-06 11:25:00 -05:00
|
|
|
// Example: Given a timeframe (in this case, the period current as an example; it could be a variable, etc.),
|
|
|
|
|
// you want to quickly convert that variable to a short description "M1"
|
|
|
|
|
// without using EnumToString and StringReplace + To Upper/ToLower. Instead,
|
|
|
|
|
// you use a quick access method with an alg hash (perfect hash), a single click, a mul, a
|
|
|
|
|
// nd a shift... and that's it! You now have an index with which you can query properties.
|
|
|
|
|
const string decs = g_mqlarticles_tfi_desc[MqlArticlesTfiIdx(PERIOD_CURRENT)].full_name;
|
|
|
|
|
Print(decs);
|
2026-09-06 11:15:27 -05:00
|
|
|
```
|