+ Reply to Thread
Results 1 to 7 of 7

Thread: Getting Started With MQL5

  1. #1
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383

    Getting Started With MQL5

    MetaQuotes have published a tutorial on how to write both an expert advisor and an indicator in MQL5 over on MQL5.com.

    It's translated from the original Russian, so the English is a little weird in places. Nevertheless I guess the best place to start is with instructions "straight from the horse's mouth".

    For an introduction to the C++ language (on which MQL5 is based) you might also want to take a look at this online tutorial (By all means read the risk warnings, but otherwise try to ignore all those forex broker ads!). You can also download an eBook version.

    Finally if having looked at both of those you're still completely confused by object-oriented programming it will probably be worth your while to read "C# for Sharp Kids". It talks about a different programming language of course, but it's still the most approachable introduction to OOP that I've yet come across.
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  2. #2
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383

    New MetaQuotes Example of an Object Oriented Expert Advisor

    MetaQuotes have just published a new article on MQL5.com which includes an example expert advisor written using the new object-oriented features of MQL5. It also includes a brief tutorial on some object-oriented programming basics such as creating a class, deriving a new class using inheritance. It even explains what an "object" actually is!

    Take a look at "Writing an Expert Advisor using the MQL5 Object-Oriented Programming approach"
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  3. #3
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383

    New MetaQuotes Example on Testing and Optimizing of MQL5 Expert Advisors

    MetaQuotes have just published a new article on MQL5.com taking you through the steps involved in debugging, testing and optimizing an MQL5 expert advisor. It also includes an example EA based around the Commodity Channel Index (CCI).

    Take a look at the new "Guide to Testing and Optimizing of Expert Advisors in MQL5"

    Personally I'm not too wild about the author's suggestions regarding how best to analyze optimization results, but the article does at least take you through the mechanics of how to successfully run compilations, backtests and optimizations.
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  4. #4
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383

    Orders, Positions and Deals in MetaTrader 5

    At long last MetaQuotes have provided a tutorial on what I know has proved to be a difficult issue for many people moving from the MQL4 way of doing things to MQL5. What exactly is the difference between an order, a deal and a position?

    Approximately, and in brief, an order is what MT4 used to call a pending order. A deal is what used to be called an open order, except that it needs another deal to close that order, and partial fills may mean that a single order can end up as several deals. A position is an unfamiliar concept to MetaTrader 4 users, and is what you get left with after all your deals are netted together. One lot long followed by 2 lots short results in a net position of one lot short.

    If that brief overview doesn't make a whole lot of sense yet take a good look at MetaQuotes very own article on Orders, Positions, and Deals in MetaTrader 5, which also comes complete with several code examples for you to download.
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  5. #5
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383

    How to Use the MetaTrader 5 OnTrade() Event

    Following on from their description of the difference between orders, deals and positions, MetaQuotes have finally published their official version of how to use the OnTrade() event to try and keep track of changes in those three fundamental components of MetaTrader 5 trading operations. I have gone on record as describing the MT5 OnTrade() functionality as "almost completely useless", and asked MetaQuotes to fix it but so far without success. The amount of code required to perform what ought to be a straightforward task hasn't caused me to change my view!

    However if you want to write an even slightly sophisticated MT5 expert advisor you'll need to get to grips with this stuff. If that's the case I recommend you read Trade Events in MetaTrader 5 very carefully! Once you've digested all that, you might also want to take a look at another article from MQL5.com that addresses the same issue.
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  6. #6
    Junior Member
    Join Date
    Oct 2011
    Posts
    6

    trade order tickets

    I have just read this article (http://www.mql5.com/en/articles/232) and although it makes sense it seems to say that the only sure way of selecting the last trade info is through this long winded, convoluted process of search for orders from x to x times, and compare them to the servers list, and then we can select the latest. Is this for real? Does this only apply for when you need to know the order info straight away? How long does the server take to give that info? There must be an easier way to select the ticket number of the current positions or last trade surely? So then you can just use OrderSelect(ticket); to track or manipulate it.

    Another qn. I cannot find, except for mql5.com, and a bit here and there, much interest in metatrader 5. Metatrader 4 yes but pickup of metatrader 5 seems sparse to say the least? Should I be using something else?

    Thoughts Jim?

    Awesome,

    Jed
    Last edited by lwclasses; 12-14-2011 at 10:50 PM.

  7. #7
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383
    Hi Jed,

    Quote Originally Posted by lwclasses View Post
    The only sure way of selecting the last trade info is through this long winded, convoluted process of search for orders from x to x times, and compare them to the servers list, and then we can select the latest. Is this for real?
    There isn't an easy way of dealing with individual orders and/or deals I'm afraid. With MT5 it's even more complicated than it was in MT4. Using positions is easier, but if you do need to look at individual deals one way of doing so is demonstrated by Ray the Random Robot!

    Another qn. I cannot find, except for mql5.com, and a bit here and there, much interest in metatrader 5. Metatrader 4 yes but pickup of metatrader 5 seems sparse to say the least? Should I be using something else?
    Very few brokers have offered MetaTrader 5 live accounts yet. If you want to automate your real money trading today then you will need to look at alternatives to MT5.

    Cheers,

    Jim
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts