Articles by: David Williams

Top 6 Reasons Your Expert Advisor Does Not Trade

Help! My Expert Advisor Does Not Trade

1. Did you enable trading on your MetaTrader platform?

The icon should be green, not red. This shows Expert Advisors as disabled:

This is what it looks like when Expert Advisors are enabled:

Expert Advisors enabled

 

 

 

2. Have you enabled Live Trading on the Expert Advisor input tab? 

If you don’t see a smiley face in the top right corner of the chart, no trades will be placed.

Check the Live Trading box when you attach your EA to a price chart.

EA input tab

 

3. Are there any error messages in the MetaTrader platform Experts tab:

MetaTrader Platform experts tab

Some error messages you may see are:

  • Error code 130 (ERR_INVALID_STOPS): This means your StopLoss or TakeProfit value is not valid. Check them and make sure they are large enough. The actual minimum or maximum value varies from broker to broker.
  • Error code 131 (ERR_INVALID_TRADE_VOLUME): This means your Lot value is not valid. The allowable values vary according to account type (micro, mini or standard).
  • Error code 133 (ERR_TRADE_DISABLED): Use the instructions above to learn how to enable trading on your MT platform.

If you see an error number that you do not understand, use the Navigator in the MetaEditor to search for the error number. See this post for using the MetaEditor for help.

 

4. Is one of the VTS System Managers preventing a trade from opening?

  • Check the Trade Time Manager and the Trade Signal Manager and make sure they are not configured to prevent trades from opening.
  • Check the values of the Input Variables MaxTrade, MaxBuys and MaxSells and make sure they are not set to 0 (zero).

 

5. Have you ever successfully open a trade using an Expert Advisor on this MetaTrader account?

Use the Test Wizard to create a simple EA that opens a trade. (The Test Wizard only allows EAs to run on a DEMO account.)

VTS Test Wizard

Make sure you can open a trade using a Test Wiizard EA before attempting to open trades using a more complex EA.

6. Is your Expert Advisor generating a Trade Signal? Is the EA not even trying to open a trade because the trade Logic is never true?

If you think your EA should be generating a valid signal to open a trade, and it appears that it is not, then see this post for debugging an Expert Advisor.

 

 

 

How to Resolve an MQL Syntax Error

How to Resolve an MQL Syntax Error

Inspect the Error message, then locate & fix the problem

The VTS output tab will show the exact MQL syntax error:

Although this shows the exact location of the error in the MQL file, this information may not be very helpful, especially with a large system.

To find out more, click the Editor button to launch the MetaEditor. Then press F7 in the MeteEditor – this will build the EA.  The same error message is shown in the MetaEditor’s Error tab:

When you double-click the error, it will bring you to the exact location of the error in the MQL file.

In this case the error is associated with the MQL Variable named Variable1

Now you can inspect that Element on your VTS drawing:

The assignment field of the Variable1 Element contains a semi-colon (;). This is not valid MQL syntax, so it causes the MQL build to fail.  Changing the semi-colon to 0 (zero), or some other value will fix the error.

Every error is a little different , but the objective is the same: find the general location of the error and then make changes to see if the error is resolved.

 

Important Note: The first time you click the Editor button in VTS, the MetaEditor is launched and the Expert Advisor for the current VTS system is  loaded into the MetaEditor.  But, and this is significant, if you make changes to your VTS drawings and rebuild by clicking the Build button, the MQL file in the MetaEditor will not be refreshed. You need to close the file in the MetaEditor and then reopen it to see the latest changes. There is simply no facility that VTS can use to instruct the MetaEditor to reload a file.  We had a sloppy work-around in a previous version of VTS, but changes were made to the MT platform (around build 400) that caused the work-around to break.

Final points:

  • This is a  handy trick:  If an Element is not connected (using a link) on the VTS drawing pad, it will not be included in the MQL code and therefore will not be built. So you can temporarily remove the links to/from an Element and re-build.  If the error is gone, then the problem was caused by the excluded Element.  Also, you can remove all links – just connect the Start Element to an End Element, and rebuild as you add each Element back to the drawing one at a time.
  •  You can get more information about the MetaEditor in this post.
  • We offer a free email MQL course. Through a series of emails, it teaches you how to program MetaTrader4 Expert Advisors. No strings attached, just a bunch of emails spaced out over a few weeks.
  • I’ve written an ebook on how to learn MQL: MQL For Traders