forked from nique_372/TSNStd
21 lines
1.1 KiB
Markdown
21 lines
1.1 KiB
Markdown
[← 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`).
| |
- A hash-based jump table (seeds + final table) for fast lookups instead of linear search (generated via SimPHash).
| |
| |
## Basic usage
| |
```mql5
| |
// 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);
| |
```
|