Discussion of article "Universal Expert Advisor: the Event Model and Trading Strategy Prototype (Part 2)" - page 2

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
Hi,
I tried to compile your code (Agent.mq5) and I got the following error. Build 1274
Internal compiler error Agent.mq5 1 1
There is also a little typo on line 388 of Dictionary.mqh
/| Returns previous object. The current object becomes previous|
On build 1241, the code is compiling well, so I tried to run a backtest. It doesn't take any trades.
After digging a bit
I found it's due to filling mode. The mode allowed on the broker/symbol I am using is ORDER_FILLING_IOC. Your TradeCustom class set the filling mode by default to ORDER_FILLING_FOK. And I am stick there, how can change this filling mode for the Agent.mq5 EA to take trade ? I could search, it will take me a lot of time.
That's the problem with such tools, very similar to MQL5 wizard EA from Metaquotes, it's almost unusable for anyone who doesn't know all the details of the classes. Once you face an issue which was not provided by the author it becomes a real pain to fix it or modify/add to it. I don't see any real difference between your solution and the one from Metaquotes (wizard).
Anyway, congratulations for the huge work. It is a great programming work.
Vasily, as a "guide to OOP application in trading" your works are very informative and useful, but as a "working trading engine" they are very poor. In particular, I am talking about the variety of "administrative functions".
Today, MT5 is close to MT4 in terms of accessibility and trader loyalty (hedge trading has been added). Over the years, MT4 has accumulated quite a rich administrative functionality in free access:
* partial closing of positions (I mean the control of this process by the trading engine);
* variety of STOP calculations;
* dynamic STOPs;
* virtual STOPs;
* professional MM (this is control over the distribution of funds between strategies). The final, and most importantly, sustainable trading result depends not on the correct entry and exit into the market (although it is important), but on the correct investment;
* virtual trading;
* network building. I.e. interconnection of a series of orders united by a single logic of lot size formation for each position in the series.
* leaves much to be desired and the implementation of exception handling when making trade orders (requotes, error #130 [MT4], STOPLEVEL, FREEZELEVEL, etc., etc.).
The question arises: "Will you develop your engine further in free access?".
Vasily, as a "guide to OOP application in trading" your works are very informative and useful, but as a "working trading engine" they are very poor. In particular, I am talking about the variety of "administrative functions".
Today, MT5 is close to MT4 in terms of accessibility and trader loyalty (hedge trading has been added). Over the years, MT4 has accumulated quite a rich administrative functionality in free access:
* partial closing of positions (I mean the control of this process by the trading engine);
* variety of STOP calculations;
* dynamic STOPs;
* virtual STOPs;
* professional MM (this is control over the distribution of funds between strategies). The final, and most importantly sustainable result of trading, depends not on the correct entry and exit into the market (although it is important), but on the correct investment;
* virtual trading;
* network building. I.e. interconnection of a series of orders united by a single logic of lot size formation for each position in the series.
* leaves much to be desired and the implementation of exception handling when making trade orders (requotes, error #130 [MT4], STOPLEVEL, FREEZELEVEL, etc., etc.).
The question arises: "Will you freely develop your engine further?".
Yes, the development of the engine is planned further. And it will always remain free.
About the rest of what you have listed - write your stops, MM and "administrative functions" within CStrategy. Nobody forbids it.
There has always been error control - use CTrade class and its responses to control errors.
Yes, development of the engine is planned to continue. And it will always remain free.
As for the rest of what you have listed - write your stops, MM and "administrative functions" within CStrategy. Nobody forbids it.
Error control has always been there - use CTrade class and its responses to control errors.
A simple user does not need to think about errors returned by the trade server. The trading engine should ensure that under any circumstances (except non-working hours) a trade order (opening, closing, modification) is correctly generated and then executed. Or am I demanding too much from the trading engine?
P.S. What to expect next (what functionality) in the next article?
An ordinary user does not need to think about the errors returned by the trade server. The trading engine should ensure that under all circumstances (other than out of hours) a trade order (open, close, modify) is correctly generated and then executed. Or am I demanding too much from the trading engine?
What do you think the trade engine should do if the trade opening order has the SL too close to the opening price:
- not open the trade;
- adjust the stop to the minimum permissible distance and open the trade (and if there is news and the stop leverage is 50 four-digit points, too?);
- adjust the stop as in the previous point, proportionally adjust the lot (so that the risk remains the same), and open the deal. If the lot becomes less than the minimum acceptable lot:
- cancel the entry so as not to violate risk management,
- enter with the minimum lot.
- adjust stop loss and all pending orders that are at the same level (if it is a grid);
- adjust stop loss and take profit proportionally;
- ...
Do you realise that, depending on the strategy, you need to use different options?Yes, you can make an elementary adjustment to the minimum distance (as an option), but there is no absolutely universal recipe.
An ordinary user does not need to think about the errors returned by the trade server. The trading engine should ensure that under all circumstances (other than out of hours) a trade order (open, close, modify) is correctly generated and then executed. Or am I demanding too much from the trading engine?
P.S. What should I expect (what functionality) in the next article?
The task of the trading engine is to provide a convenient environment for the strategy, as well as to ensure the integrity and consistency of the data presented. The trading engine has no other tasks. But in no case it should not "trade" for the strategy itself. So if the strategy has made a mistake, the engine will not correct its mistakes, otherwise it will be a bearish favour. Everything should be done to prevent the error. But if it has happened, it makes no sense to change the Expert Advisor's trading logic on the fly. You should just sit down and fix the strategy code. There is no other option.
An example from practice. If you request any price in CStrategy, for example, like this:
You are guaranteed to get an already normalised instrument price, which can be directly used in trade orders. The same cannot be said if you use a system query. I.e. CStrategy does everything to prevent technical errors that appear, for example, when prices are not normalised. However, it will not do the work for the user. And if you substitute this price for a pending order, it may not work.
What do you think the trading engine should do, if in the order to open a trade the SL is too close to the opening price:
- not open the trade;
- adjust the stop to the minimum permissible distance and open the trade (and if there is news and the stop leverage is 50 four-digit points, too?);
- adjust the stop as in the previous point, proportionally adjust the lot (so that the risk remains the same), and open the deal. If the lot becomes less than the minimum acceptable lot:
- cancel the entry so as not to violate risk management,
- enter with the minimum lot.
- adjust stop loss and all pending orders that are at the same level (if it is a grid);
- adjust stop loss and take profit proportionally;
- ...
Do you realise that, depending on the strategy, you need to use different options?Yes, you can make an elementary adjustment to the minimum distance (as an option), but there is no absolutely universal recipe.
The task of the trading engine is to provide a convenient environment for the strategy, as well as to ensure the integrity and consistency of the data presented. The trading engine has no other tasks. But in no case it should not "trade" for the strategy itself. So if the strategy has made a mistake, the engine will not correct its mistakes, otherwise it will be a bearish favour. Everything should be done to prevent the error. But if it has happened, it makes no sense to change the Expert Advisor's trading logic on the fly. You should just sit down and fix the strategy code. There is no other option.
An example from practice. If you request any price in CStrategy, for example, like this:
You are guaranteed to get an already normalised instrument price, which can be directly used in trade orders. The same cannot be said if you use a system query. I.e. CStrategy does everything to prevent technical errors that appear, for example, when prices are not normalised. However, it will not do the work for the user. And if you substitute this price for a pending order, it may not work.
It is useless to argue here. This is a purely personal approach. But I don't allow myself to receive such messages in the log:
The engine should take care of it.There's no use arguing here. It's a purely personal approach. But I don't allow myself to receive such messages in the log:
This is something the engine should take care of.