Download MetaTrader 5

Adding positions

To add comments, please log in or register
Do you know that MQL5 has structures?
Ingvar Engelbrecht
Ingvar Engelbrecht 2014.10.04 13:00 

In MT4 it is straightforward to use a technique with a trailing stop and add new trades when the previous trade(s) has passed break even.

Each trade is processed  separately by the broker. Each trade can be sent with all needed information in one go. No real complications.

I have made some attempts to implement this in MT5.  In principle it is possible using pending orders for SL and TP.

In practice it is a real hassle and I have given up on it. I am considering using the MT5 EA to create signals and send to MT4 to execute orders

Why is it a hassle?  You have to place 3 orders for each trade. If anything goes wrong you must backtrack all 3. If anything goes wrong

you end up with a unknown pending order ("loose cannon") so you better have periodic checks for these "loose cannons" to.

Just thinking on how to keep track of 3 added positions, cleaning up pending orders (no OCO!) and calculate if they all have passed their  break even make my head spin

So why not rewrite it all in MT4?  Lots of code. Multi currency EA.

And of course. What is the future of  MT4. How long will MT4 be around? How long will it function in the current manner?

Stuart Browne
Stuart Browne 2014.10.04 13:09  

And of course. What is the future of  MT4. How long will MT4 be around? How long will it function in the current manner?

Whilst not addressing your MT5 issues, I can say that I think the future of MT4 is solid. They are two very different beasts. There is no way that brokers with customers in countries outside the US would support only MT5 over MT4. And for me, as a trader outside the stupid US rules, there is no way I could run my strategies using only MT5. And i think the fact that MQ are continuing to update MT4 speaks volumes.


p.s. Oh. and I would LOVE a simple OCO too!! :) 

Alain Verleyen
Alain Verleyen 2014.10.04 13:36  

Nothing is indicating that MT4 can be stopped. It's the success product of Metaquotes and they will not, they can not, lose it.

About your issue, a possibility is to manage your trades locally, inside your EA, exactly in the same way it's done by MT4 at server side. Of course, it implied some works too, and there is the problem to lose connection with the server. But with the solution of pending orders, withtout OCO possibilities, the risk is similar.

About OCO orders, this has been discussed on Russian forum, and we can't expect to have it, it's reject by the CEO (I never understand why, probably because it will become too easy to use MT5 ).

Ingvar Engelbrecht
Ingvar Engelbrecht 2014.10.04 17:12  

Thanks Filter and angevoyageur.

As we say in Sweden. I have to  bite the sour apple.

Back to MT4. Maybe it is not to bad. Will move the code, libraries and classes to a MT4 environment and start from there.

Catch you later. Much later :-)

I will miss the Strategy tester in MT5, that is for sure

Ingvar Engelbrecht
Ingvar Engelbrecht 2014.10.05 12:02  

Been thinking. 2 things came up

- I really do not want to get back to the strategy tester in MT4

- The amount of code to rewrite. quite a lot and also a lot of testing

I am running my own VM server 24/7 running 2 separate Windows 7 and one of them has MySQL installed

So, I have a MySQL database on my server, I have code to read and write both in MQL4 and MQL5. It is actually mostly the same code with some differences

that are implemented with compiler directives

It will be an 2-part EA.

 -  Signal provider in MT5 where also the basic profitability can be tested with the Strategy Tester. No add ons, no trailing SL.

 -  All signals, including possible addons will be stored in the MySQL database

 -  Trade executor in MT4, reading the MySQL database and execute actual trades. can make add on and do trailing stops

A lot less coding and I can keep the Strategy Tester in MT5

The current solution keeps the parameters for the different pairs in a file. Will move that too to the MySQL database

Adding a MySQL database will also make analysis of performance simpler.

To add comments, please log in or register