Post Tagged with: "tick"

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 

New Way to Get More MetaTrader Price Data

New Way to Get More MetaTrader Price Data

If you do any back testing using the Strategy Tester, you may be interested in this.

If you don’t already know, the Strategy Tester is a back tester that comes with MetaTrader (MT).  To find it in your MT platform,  go to the View tab and select Strategy Tester.

Used to be when you needed more historical data you just pressed the PageUp key on your keyboard.

Pressing the PageUp key scrolled back through time on your chart. When you hit the point where you had no more price data, your MT platform would connect to your broker’s server and load more data.

For example, suppose you opened a 1 minute EURUSD chart and pressed the PageUp key.  It might go back to about 2 weeks ago and stop.  Then you’d press the PageUp key a few times and it would load more data.

It doesn’t work like that anymore.  I’m not sure why, but it’s not a big deal.  There’s another way that’s just as easy.

In your MT platform, go to the Tools tab and select History Center.  This opens a window that shows all of your available Symbols.

Expand the Forex menu, choose your Symbol and press the Download button.

This will download all of the price data available for that Symbol and Timeframe.   The download may take a while –  it  depends on your network connection.

I’ve posted some screenshots of this on the forum.

Here is the link:

http://www.iexpertadvisor.com/forum/messages.aspx?TopicID=221#post654

Note:  If you have a live account and need more data, don’t be afraid to ask your broker.  I’ve been able to get tick data for some currencies just by asking (nicely).