DinexSpace Tick Feed Health Library
- librerie
- Versione: 1.0
DinexSpace Tick Feed Health Library is a library for MetaTrader 5 (MT5) that watches the tick feed of one symbol for your indicator or Expert Advisor: how old the last tick is, how many ticks arrive per minute, the longest silent gap of the day and whether the terminal is connected. Silence while the trading session of the symbol is closed (the daily break, the weekend) is not counted as a gap and a tick is not called stale then.
How it works
- Call DxThCreate with the symbol, the age above which a tick is stale, the minutes of the rate window and the length of a gap to count. You get a handle.
- Call DxThUpdate from OnTick or from OnTimer. It reads the last tick of the symbol.
- Read DxThAge and DxThStale for the age, DxThTicksPerMinute for the rate, DxThLongestGapMs and DxThGapCount for the gaps of the day, DxThConnected for the connection.
- DxThFeed lets you give the library ticks and times yourself, for tests or to replay ticks.
What you get
- Age of the last tick and a stale flag that only counts while the session of the symbol is open.
- Ticks per minute over a window of 1 to 60 minutes.
- Longest silent gap of the day in milliseconds, and the number of gaps of at least the length you choose.
- Sessions: a gap that contains a closed minute is not counted.
- Connection: one call for the connection state of the terminal.
- Checked: the example EA follows every tick with a separate tracker and compares the counts, the gaps and the rate, on real ticks and on generated ticks, and runs scripted ticks with known answers.
- Status codes with plain-English texts: bad setting, bad handle, unknown symbol, no tick, tick out of order.
- Light: each program has its own monitors. No DLLs, no web requests, no Sleep. The library places no orders.
How to use it
- Copy DinexTickFeedHealth.ex5 to MQL5\Libraries.
- Add the import block with the functions you use (shown in the images and in the example EA).
- Open a monitor, call update on each tick, read the result.
Definitions (server time)
- Age: server time now − time of the last tick, in seconds. Stale: age above the limit while the session of the symbol is open at that time.
- Gap: the time between two ticks in a row when the session was open at both ends and at every minute between them; gaps over two days and gaps under one second are not looked at. A gap belongs to the day of the later tick.
- Rate: ticks in the last window minutes before the last tick, divided by the window. Up to 200000 ticks are kept; DxThRateSaturated tells when the window held more.
- Two ticks with the same millisecond, bid and ask count as one.
Example EA (included in the description images)
The example gives every tick of the chart symbol to the library and to a separate tracker written in the example, and compares the totals, the longest gap, the number of long gaps, the last tick and the rate. At start it also runs scripted ticks with answers worked out by hand. It prints the number of checks and the number of failed checks.
Notes
- The library reports facts about the feed. It gives no entries or exits and does not predict any move.
- The Strategy Tester is always connected and its ticks have almost no age, so the connection and stale rules cannot be tested there beyond the functions that take a time you choose. Check them on a demo account before you rely on them.
- Session times come from the symbol specification of your broker.
Requirements
- MetaTrader 5, any symbol and timeframe.
