Is metatrader itself well optimized?

 

Is it written with for example branchless programming and bit twiddling? Or is it written in an academic software programmer way?

I have been reading https://johnnysswlab.com/  and started wondering how much performance can be squeezed out from an ea if the platform is not well optimized? Is it well optimized?

Also metaeditor's limited debugging/profiling capabilities, and using an unknown subset of C/C++ makes it difficult to evaluate what can be done and what can't.


Anybody with knowledge on this topic?

Welcome to Johnny’s Software Lab!
  • 2023.06.26
  • johnnysswlab.com
Welcome to Johnny’s Software Lab, a blog for all interested in fast software written in C and C++. If your project is struggling to deliver because of performance issues, check out the Consulting page on the ways we can help you. Featured posts C++ Performance Posts related to better usage of C++ language features: Excessive… Read
 

The microseconds that the EA takes to run is nothing compared to the 50 milliseconds the network takes. Optimization there is irrelevant.

In the tester/optimizer, adjust your code.

  1. EAs : Don't do per tick what you can do per bar, or on open.
    If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts, and you recalculate.)
    If you are waiting for an order to close, only look when OrdersTotal (or MT5 equivalent) has changed.
              How to get backtesting faster ? - MT4 - MQL4 programming forum (2017)

  2. Indicators: Code it properly so it only recomputes bar zero (after the initial run).
              How to do your lookbacks correctly. (2016)
              3 Methods of Indicators Acceleration by the Example of the Linear Regression - MQL5 Articles. (2011)
    Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)