Discussion of article "EA remote control methods"

 

New article EA remote control methods has been published:

The main advantage of trading robots lies in the ability to work 24 hours a day on a remote VPS server. But sometimes it is necessary to intervene in their work, while there may be no direct access to the server. Is it possible to manage EAs remotely? The article proposes one of the options for controlling EAs via external commands.

Various automated systems for trading in financial markets have become quite common in our digital age. The main advantages of electronic Expert Advisors (EAs) are considered to be flawless algorithm execution and working 24 hours a day. The virtual hosting allows using EAs autonomously around the clock.

Unfortunately, not all EAs work equally well in any market situations. In these cases, traders often need to enable and disable them manually. This is easy when a user has direct access to the terminal. But what if you do not have quick access to the terminal with a working EA? In such cases, it would be good to be able to remotely control the EA operation. Let's consider one of the possible methods of EA remote control in the terminal.


Author: Dmitriy Gizlyk

 

Thanks for the article. Special thanks for the link to the library of changing states of the Expert Advisor. Working through templates is a very original solution indeed.

But to be honest, when I saw the title I thought it would be something about client server or sockets....

If you have several accounts, you will get tired of putting pending orders everywhere.

Somewhere on the forum there was a library for interaction via telegram. There are more possibilities there, and all commands can be set by pressing pre-prepared buttons in the bot.

 
Sergey Likho:

Thanks for the article. Special thanks for the link to the library of changing states of the Expert Advisor. Working through templates is a very original solution indeed.

But honestly speaking, having seen the title I thought it would be something about client server or sockets....

If you have several accounts, you will get tired of putting pending orders everywhere.

Somewhere on the forum there was a library for interaction via telegram. There are more possibilities there, and all commands can be set by pressing pre-prepared buttons in the bot.

As far as I know, there are plans to prepare an article on management via telegram and even an author has been appointed. Perhaps the new article will be more useful to you.

 
for convenience of our use let's make all methods of the library public.
We can use this trick not to change the original source code
#define private public
  #include <fxsaber\Expert.mqh> // https://www.mql5.com/en/code/19003
#undef private

#define  STRING_END "\r\n"
#define  EXPERT_BEGIN ("<expert>" + STRING_END)
#define  EXPERT_END ("</expert>" + STRING_END)
#define  EXPERT_NAME "name="


Thus, to enable/disable the Expert Advisor, we only need to rewrite the template file, changing the expertmode flag to the value we need and removing hidden objects.

I did not know about this flag, as well as did not think about the subtleties of working with objects, Thank you!


This code

      string temp=EXPERT::TemplateToString(i_chart,true);
      if(temp==NULL)
        {
         i_chart=ChartNext(i_chart);
         continue;
        }
//---
      temp=EXPERT::StringBetween(temp,EXPERT_BEGIN,EXPERT_END);
      if(temp==NULL)
        {
         i_chart=ChartNext(i_chart);
         continue;
        }

will catch not only EAs, but also scripts. That's why it's probably better like this

      if(!EXPERT::Is(i_chart))
        {
         i_chart=ChartNext(i_chart);
         continue;
        }
      
      
      string temp=EXPERT::TemplateToString(i_chart,true);

In this case, templates will be saved only where they are needed.


ZY I didn't intentionally make FileDelete so that you could always see the last generated template.

 
fxsaber:
You can use such a technique to not change the original source material

Interesting technique, never thought of this way before. Thank you.

 
fxsaber:

This code


will catch not only EAs, but also scripts. That's why it's probably better like this

In this case, templates will be saved only where they are needed.

In the code, TemplateToString was intentionally called with the flag true. Perhaps you have forgotten, but in the body of the function with the true flag, the presence of the Expert Advisor on the chart is checked by calling the Is method.

 static string TemplateToString( const long Chart_ID = 0, const bool CheckExpert = false )
  {
    short Data[];

    return(((!CheckExpert || EXPERT::Is(Chart_ID)) && ::ChartSaveTemplate((ulong)Chart_ID, PATH + FILENAME) && (::FileLoad(FILENAME, Data) > 0)) ?
           ::ShortArrayToString(Data) : NULL);
  }

That's why both codes should work the same way.

In general, thank you for the library and your comments.
Regards,
Dmitry.

 
Dmitriy Gizlyk:

In the code, TemplateToString was intentionally called with the true flag. Perhaps you have forgotten, but the presence of an Expert Advisor on the chart is checked by calling the Is method in the body of the function with the true flag.

Indeed, I forgot.

In general, thank you for the library and your comments.

I'm glad that you have understood it and added substantially. Indeed, it wouldn't hurt to correct it taking into account the nuances you mentioned.

 
It is certainly good, programming to remember and so on, the article is even interesting.
But I have one question in my head, am I the only one who is so lazy that the terminal is running on a PC at home, and I work with it from my phone via TimWeaver? Or has no one heard of such an opportunity?
I see only pluses, namely:
-no need for a dedicated IP
-cross-platform nature of this programme (for Windows, Mac, Android, iOS)
-free
-convenience of work, as if you were sitting at your PC at home ...
-no need for a bunch of templates, mountains of code.
You always see everything on the mobile terminal, if something needs to be corrected, you can open the application and correct what you need, whether it's switching off an Expert Advisor or launching another one, or just correcting something in the settings. Even to the point of switching off or restarting the PC completely....
 
sic20101:
But I have one question in my head, am I the only one who is so lazy that the terminal is running on a PC at home, and I work with it from my phone via TimWeaver? Or no one has heard of this possibility?

It happens that VPS (or your PC at home) with the Expert Advisor is offline for some time for technical reasons. It is unknown when it will be back online, but you need, for example, not to trade, because you know that there may be more interruptions. In this case, the proposed remote control allows much more than your variant.


There are also VPS from MetaQuotes. It's only like that there.

 
fxsaber:
This will not happen for one reason, there is no internet - no trading, and you probably have not noticed that account control is visible from your phone or tablet. If the internet is out, we just close all trades with our hands, and then either wait for the internet to appear or be at home for further actions on the PC.
Just analysing my method, which I have been using for more than a year, access to the network is the only bottleneck. And this problem is only in the choice of provider, as the service TimWeaver works not the first year, and even if it and fall off you can always leave google chrome, which also has such a function, they certainly will not soon die....
 
sic20101:
This will not happen for one reason, there is no internet - no trading, and you probably have not noticed that account control is visible from your phone or tablet. If the internet is out, we just close all trades with our hands, and then either wait for the internet to appear or be at home for further actions on the PC.

Terminal on your computer without internet, you are far away. You have access to your account, but not to the terminal with the Expert Advisor. How to make the Expert Advisor not to trade, when it will be connected to the trading server (internet will work)?