Download MetaTrader 5

How to deal with multiple MT4 logins?

To add comments, please log in or register
Doerk Hilger
1189
Doerk Hilger  

Hey there,

on the one hand, it´s quite comfortable that MT4 allows for multiple logins, but it´s also a matter of security and can be a big problem, especially when we talk about EAs, Scripts etc. for support of manual trading. If a user has a VPS and a local system and if he uses both from time to time, it may happen that the same EA is loaded with the same symbol on the same account twice. And if such an EA cares about SL or TP for example, both instances are competitors. If one instance wants the SL at 10 points, and the other at 20, it´s going to be an endless ping pong.

Of course one can tell the users: Don´t. But all users are human and make mistakes, and any good program deals with mistakes of users. The problem is: How can this be done here somehow smart?

Is there a switch in MT4 or MQL which I do not know to avoid exactly this or does someone know another smart solution? 

Thank you in advance

Doerk 

Fernando Carreiro
2321
Fernando Carreiro  

Have the EA track it's own orders (in an Array or Class) and than have it scan the currently open orders at regular intervals or in a tick stepped loop (explained toward the end).

When it detects an Order Ticket that has the same magic number but is not part of the tracked list, it then knows that another EA is working with the same magic number (be that the same EA or another completely different one).

When such a situation is detected, you can have a Warning message sent to the User or an Alert go up about the conflict (or correct the issue in some other way).

Be careful however about EA recovery protocols you may have in place when an EA initialises.

Tick Stepped Loop:

Normally you see EAs scan the entire Open History on every tick event, which can contain just one order or many, depending on the situations and number of EAs running. So if you have 10 open orders, it loops over all 10 on every tick.

A tick stepped looped (or whatever name you want to give it) is a way I come up to lessen the EAs load on every tick event. Instead of looping over the entire Open History, it only advances one position of the loop per tick event. So if you have 10 open orders, it will require 10 tick events to loop over the entire history. If you require a code sample, let me know and I will post it.

Doerk Hilger
1189
Doerk Hilger  

Thank you for your reply.

My system deals with classes, every order is represented by an object, and the pool class contains and manages these objects. Looping etc. is not the problem, the system detects also orders which have been placed or closed by the mobile app or via the normal order panel instead of the panels of the system. That´s all fine so far.

The main problem is VPS and the main-main problem is, for example, when the local instance has a fix SL and the VPS instance starts to trail, then there is an unavoidable conflict. There is no communication between these both instances which means, I have to detect such influences and deactivate that instance, which was influenced and have to keep alive that one, which initiated it. It works somehow, yes, but this is tricky stuff and for my understanding of programming not proper at all.   

Fernando Carreiro
2321
Fernando Carreiro  

Well, if you already have a sophisticated order management system, then it is trivial to be able to detect orders that were not opened by that instance and when it detects orders outside of that, then you just issue the warning or alert or place all instances of the EA (except the first) on standby.

EDIT: PS! Alternatively, use the equivalent of a centralised multitasking locking semaphore.

Doerk Hilger
1189
Doerk Hilger  
You mean by WebRequest() ? I considered that, but there weare again at the f...ing restrictions of the MQL market place. 
Fernando Carreiro
2321
Fernando Carreiro  
Doerk:
You mean by WebRequest() ? I considered that, but there weare again at the f...ing restrictions of the MQL market place. 

You could call Win32 functions to circumvent Web restrictions, but then again you need DLL imports be enabled. However, that is easy to resolve, by having the OnInit() function test for that and tell the user the EA will not run until it is activated.

EDIT: Sorry, did read your post properly. Yes, you are right, WebRequest are restricted and DLL calls are not allowed on the MarketPlace.

EDIT2: The only alternative I can think of is placing a "fake" pending order, at a price that will never trigger and use that as the locking semaphore (for example, a SELL STOP order at the "_Point" price, i.e. 0.00001, etc.). Then during the OnDeinit() you can delete the order.

peter.MT4Web
157
peter.MT4Web  

Check the order SL before you modify it. The EA modifies the SL only if the risc will be less or the fix profit will be more as before.

If you do that, your EA will also recognize a manually changed SL (eg set to BE in front of an event).

Fernando Carreiro
2321
Fernando Carreiro  
eddie:

Check the order SL before you modify it. The EA modifies the SL only if the risc will be less or the fix profit will be more as before.

If you do that, your EA will also recognize a manually changed SL (eg set to BE in front of an event).

That is only a very specific example that Doerk gave. It does not mean that it is that exact situation and it could also affect trailing stops or other properties.

Your solution won't resolve the issue for general use on different EA's. That is why he is in search of a more general purpose solution.

Gordon Gekko
622
Gordon Gekko  

I did not think carefully about it, but:

maybe the EA instances can be identified by Chart_ID, which it runs on.

Same account, same symbol, same EA, different Chart_ID.

Fernando Carreiro
2321
Fernando Carreiro  
ggekko:

I did not think carefully about it, but:

maybe the EA instances can be identified by Chart_ID, which it runs on.

Same account, same symbol, same EA, different Chart_ID.

I don't think you are quite getting the scenario - the EAs are running on different machines and there is no communication between them, other than standard protocol to the broker.

Gordon Gekko
622
Gordon Gekko  
FMIC:

I don't think you are quite getting the scenario - the EAs are running on different machines and there is no communication between them, other than standard protocol to the broker.

Maybe you are right, but not sure. There is a common point ("communication-channel"), the account itself.
12
To add comments, please log in or register