
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
New article Creating an EA that works automatically (Part 05): Manual triggers (II) has been published:
Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode. At the end of the previous article, I suggested that it would be appropriate to allow manual use of the EA, at least for a while.
Since many may be using articles published in this community to start learning programming, I see this as an opportunity to share some of my experience, based on years of programming in C/C++ and to show how to implement some things in MQL5 which is very similar to C/C++. I want to show, that programming is nothing mythical, it's all real.
Well, to make the use of our EA in the manual mode more comfortable, we need to do a few things. This work is simple and easy for programmers, so we can get straight to the point. Namely, we will create lines indicating the location of order limits for the orders that we send to the trading server.
These limits are more appropriate to be viewed when we are using the mouse to place order, i.e., when we are creating a pending order. Once the order is already on the server, the indication is managed by the MetaTrader 5 platform. But before this actually happens, we need to show the user where the order limits are most likely to be placed. This is done by us, the programmers. The only support we receive from MetaTrader 5 is the possibility to use horizontal lines on the chart. Except for that, all the work must be implemented via EA programming.
To do this, we simply need to write the code that will place these lines at the right positions of the chart. But we don't want to do this in some random way. This should be properly controlled, since we don't want to compromise the code that we have already created, and we don't want to add work in case we have to remove the C_Mouse class and the OnChartEvent event handler from the EA in the future. This is because an automated EA does not need these things, but a manual EA needs them. We need to make sure that these things are minimally usable.
Author: Daniel Jose