Education

What’s the difference between an Expert Advisor and an MQL Script?

Expert Advisor vs. MQL Script

What’s the difference between an Expert Advisor and a Script?  I get this question a lot.

Both are written in MQL, so they both have access to the library of MQL functions for opening and closing trades, finding indicator values and even sending emails.

One difference is that Scripts are located in their own folder underneath the “experts” folder on your computer.

Also, Scripts appear under their own menu in the MetaTrader platform.

But, the biggest difference is that a Script executes just once, while an Expert Advisor executes each time a new price value is received.

Yeah, I know that last part is a mouthful:  “executes each time a new price value is received”.

This is how it works:  Your Expert Advisor, physically located on your computer, waits for new price data to be sent from the broker’s server.

metatrader-tick

When new price data is received, your Expert Advisor executes.  If there isn’t any new price data, your EA does not execute.

You might have noticed that when the market is slow your EA does not run.  This behavior is correct!

EA’s are designed to execute their logic based on changes in price.  (Remember, a change in price will usually lead to a change in an indicator value.) If there is no change in price, there is no reason for the EA to execute.

But there’s a subtle by-product of this behavior that you should be aware of.

If your EA contains logic that is solely based on time, it may not execute exactly the way you planned.

Suppose your EA is designed to open a trade at 8:00, but the market is slow and there is no price movement at that time.  Well, it ain’t gonna happen.  Not at 8:00.

Because your EA will not even execute if there is not a change in price.

But, if your EA is written correctly,  it will execute on the next price change after 8:00.

Honestly, this is usually not a big deal.  That trade scheduled for 8:00 will normally be opened within a few seconds of 8:00.

Still, it’s good to be aware of these nuances. You should understand the behavior of your EA under any market condition.

If you’re interested in more of this kind of information, I’ve put together a free email course that spoon-feeds MQL .

You can sign up here:

http://www.iexpertadvisor.com/free-metatrader4-mql-course.html 

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

− 1 = 1