| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .. | ||
| Base.mqh | ||
| Gen.mq5 | ||
| Main.mqh | ||
| 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
// 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);