Robust MQL code...
Results 1 to 3 of 3

Thread: Robust MQL code...

  1. #1
    It is one thing to have an EA that backtests well in the simulator....

    It is another to get one that can handle data feed drops, slippage, etc....

    Is there a book that outlines how to write powerful MQL code? How can you seasoned MQL coders learn the principles?

    Thanks,
    Tom

  2. #2
    The ideal thing to learn is good app structure, but that applies to programming (breaking down code into functions that do only 1 thing and minimising global variables). Beyond that it is just trial and error with MQL (and attempting to decrypt the shite documentation), there's absolutely no debugger and the compiler seems to take any old toss, this makes locate errors hard for even experienced programmers. Errors in MQL seem to revolve around opening and closing trades, so having a robust set of functions that are reusable such matters is a fantastic beginning. There are a few articles on the MQL site.

    On the upside, it is free!

  3. #3
    Everything Craig said is spot on. I'll add some ideas of my own.


    There are really three types of errors that have to be controlled in an EA or script.

    Logic or syntax mistakes
    All these are items like divide by zero, incorrect pruning or casting, etc.. Lots of testing and logging are the very best strategies.

    Order entry mistakes
    These errors happen when the order server sends a response stating that something has happened other than the order being placed/modified/deleted as wanted. Don't presume that OrderSend always works, you have to know what you want the code to perform when the server says Sorry, no can do.

    Many of these errors can be avoided by code that is carefully written. For example, error 130 means your stop price isn't valid, this error can frequently be avoided by assessing MarketInfo(Symbol,MODE_STOPLEVEL) and insuring the order pricing is permitted by the broker.

    State mistakes
    This is when your EA or script becomes closed down/restarted and doesn't correctly remember what it's supposed to be doing. For most EAs that work with one order or a single pair, this frequently isn't a concern. When you begin dealing with complex EAs then insuring it may recuperate begins to be a problem. Making use of Global Variables serializing data to file so state isn't an issue, or writing the EA are your options.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information