MQL / Using VTS

Running an Alert-Only Expert Advisor

Running an “Alert-Only” Expert Advisor on your MetaTrader Platform

There are several ways to build and run an Alert-Only Expert Advisor on your MetaTrader platform.

An Alert-Only Expert Advisor is an EA that does not open or close trades when a trade signal is detected, but instead generates an alert.

This is what an alert looks like on the MT platform:

MetaTrader Alert Window

MetaTrader Alert Window

This first method is a bit of a hack, but it does the job. When you attach your Expert Advisor to a price chart, select these options on the Common tab:

  • Allow live trading
  • Ask manual confirmation
MetaTrader EA Common Tab

MetaTrader EA Common Tab

Now, when your EA attempts to open a trade, the MT order confirmation window will appear.

MetaTrader Trade Confirmation Window

MetaTrader Trade Confirmation Window

You can simply cancel the order by clicking the X in the top right corner of the window.

This does not generate an actual alert, but it does prompt you when your trade signal is generated.  It’s not a great solution, but since it requires no work, aside from checking a check-box, I think it’s worth mentioning.

MQL Method for Alert-Only Expert Advisor

If you want to show an actual Alert message from your EA, it’s pretty easy to do in MQL.  The MetaTrader MQL function Alert is easy to use:

Alert(“hello from my EA!”);

Now, if you want to show Alerts instead of opening trades, you would need to manually replace all of the OrderSend MQL function calls with the Alert function call.  This is definitely not an ideal solution.  A better solution would be to add an if/else clause to the EA so your EA can open trades or show alerts.

if( ShowAlerts == true )
      Alert(“hello from my EA!”);
else 
     OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,”My order #2″,16384,0,Green);

If the Boolean variable ShowAlerts is declared as an extern type, then it will appear on the Inputs tab each time you run your EA. This way you can make the choice to show alerts or open trades each time you run your EA – without having to modify the MQL code.

MetaTrader EA Inputs Window

MetaTrader EA Inputs Window

 

Using VTS to build an Alert-Only Expert Advisor

Every Element on a VTS drawing has the ability to generate an Alert. This is found on the Message tab, where you can also set the Element to:

  • Write to the Expert tab on the MetaTrader platform
  • Show an Alert
  • Play a sound
  • Send an email
  • Write a message on the price chart

One easy way to create an Alert-Only EA is to set the True End Element on the Open Trade drawing to generate an alert.  This the End Element to configure:

VTS EA Builder Open Buy Drawing

VTS EA Builder Open Buy Drawing

Click on the (+) button to open the configuration window:

  • select the Message tab.
  • check Send Message
  • check Show Alert
VTS End Element Configuration Window

VTS End Element Configuration Window

This will generate an Alert each time the Trade Logic is True.

Important final step.

To run this EA as an Alert-Only EA, simply un-check the Allow live trading check box when the EA is attached to a chart (Just like in the first example above, except un-check the box).

MetaTrader Expert Advisor Common Window

MetaTrader Expert Advisor Common Window

 

Now when you run your EA and the Trade logic is true, you will see this Alert:

MetaTrader Expert Advisor Alert Window

MetaTrader Expert Advisor Alert Window

 

  iExpertAdvisor - MetaTrader Expert Advisor Builders
Tags: /

Leave a Reply

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

*