Sunday, July 11, 2010

Is it hard to write your own EA?

If you are already familiar with programming then you are all set. First of all you need to get a broker with MetaTrader software. Then you need to decide what strategy you want to automate. Writing program in MetaTrader is as easy as ABC. The language is called MQL.

First of all you need to understand how OrderSend and OrderClose works. These functions open and closes positions. Then look at the core of a program. There are 3 main functions: init, deinit and start.

init - is automatically called when program first started.
deinit - is called when EA has been stopped.
start - is called every time the currency rate has changed.

In fact start() is the main function here. If during execution of start() new tick occurs then it will be ignored. Keep that in mind. If you need to catch all currency rate changes you have to make this function to execute as fast as possible.

It is worth to mention that MQL4 has built-in most of the indicators available in MetaTrader. Surely this would help you to write your own EA's and its also keeps your code clean from unnecessary stuff.

The language syntax is similar to "C" language but it's more like its lite version. Even a "Basic" programmer can deal with MQL.

No comments:

Post a Comment