TsnPerfectHashGenerator

SimPHash is a free script that automatically generates ultra-fast conversion functions from a string to a value: it can be a simple type (integer, double, ulong, etc.) or an index into your own array or struct when the value you need is more complex.

Instead of using a HashMap, a linear array with a search, or an endless chain of if / switch, SimPHash builds a Perfect Hash table at design time: a function that resolves each known key in a handful of arithmetic operations and a single array access, with no collisions and nothing to loop through.

This is especially useful when you need to:

  • Convert strings into your own identifier, for example mapping economic calendar events to a ulong without relying on text comparisons on every tick.
  • Simulate string to enum, something the language does not offer natively.
  • Resolve symbols, codes, or any fixed set of known keys into a value or into an index of your own array, at the lowest possible runtime cost.

How it works

  • You write your keys (and optionally their values) in a YAML file.
  • You run the script once, pointing it to that YAML file.
  • The script generates a .mqh file ready to include in your project, with the tables and the lookup function already written.
  • You include that .mqh in your EA or indicator and call the generated function. There's no need to write hash tables by hand or understand the algorithm's internal details.

Main advantages

  • Requires no extra code on your part: just the YAML configuration file.
  • Two combinable hash stages, suited to different key set sizes.
  • Two output modes: a function that returns the final value directly, or a function that returns an index into your own array.
  • Automatically generates both variants of the lookup function: one that takes the string directly, and one that takes an already-computed hash, useful if your code computed it earlier.
  • Optional binary export, in case you'd rather load the table at runtime instead of compiling it in.

Installation and usage

Check the following post for a step-by-step guide and usage instructions for this utility.

https://www.mql5.com/en/blogs/post/775444

 

Mais do autor
The SMC ICT Indicator integrates the key concepts of Smart Money Concepts and Inner Circle Trader into a practical and precise tool. It displays essential levels and patterns on the chart for clear analysis according to the ICT approach. Optimized for agile processing, it allows smooth backtesting with no repainting, freezes, or delays—ensuring precision and efficiency in your trading. Included Concepts It includes Fair Value Gap (FVG), Order Blocks, Imbalance, Gap, Equal High and Equal Low, a
This library allows you to automatically filter events by symbol. Additionally, it requires the use of "flags" to classify events based on their importance (high, low, etc.). Properties: Our library is simple and only requires the export of four functions to work properly. Requirements: The library uses OnTimer , so it is not compatible with programs that also use this event. If your bot utilizes OnTimer , this may interfere with the library’s functionality and prevent event filtering. We recomm
FREE
The Multi Strategy Ranges Indicator MT5 is a powerful tool designed to detect and visualize price consolidation zones in the market. This indicator identifies ranges and draws them on the chart, providing clear signals for efficient trading. Key Features Our indicator incorporates three essential strategies for trading within consolidation ranges: Range Breakout Strategy: A classic range breakout strategy. When the price breaks the upper or lower boundary of the range, a buy or sell signal i
FREE
CSV News File Generator MT5 is a script specifically designed for the MQL5 platform. It enables the automated generation of CSV files containing economic calendar news, making it ideal for use in strategy simulators or as data for training artificial intelligence models. How Does It Work? The script gathers economic news directly from the MQL5 calendar, organizes the data into arrays, and converts it into CSV files for later use. Steps to Generate News Identify Event Codes: Find the event code
FREE
Our Silver Bullet indicator is designed to help you conduct clearer and more effective analysis based on ICT's popular Silver Bullet Strategy. With advanced tools and customizable features, this indicator enhances your ability to identify trading opportunities. Key Features: Information Panel: Provides key data for your market analysis: DOL (Daily Objective Level): The target price for the session, where you should focus your trading strategy. DOL Price: The target value of the DOL for the sess
Filtro:
Sem comentários
Responder ao comentário