Skip to main content

Posts

Showing posts from June, 2018

5 Checks to Enhance your MQL4 Code

Introduction

Throughout my years as an algotrader, I gained a lot experience with writing optimized MQL4 code. In this post, I am going to share some patterns I am using in my on robots. Some check for connectivity, some for spread, some for volatility etc. Embedding these code snippets in your own, will make your robot more resilient and you will more relax, as you will add self monitoring capabilities to it as well as better trade entry rules.



Server Connectivity Check

From time to time, MetaTrader station losses connectivity with the broker's server. And when that happens, normally, the only thing which works is to restart the platform (or hopefully wait the problem will fix itself). But how can you monitor the platform and get a notification once it is happening?

That's exactly the solution I built for myself. Since the function OnTick() is not called anymore as there is no connectivity. The only solution was to place the monitoring in the OnTimer() function and check every X …