Discussion of article "Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs"

 

New article Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs has been published:

These are some tips from a professional programmer about methods, techniques and auxiliary tools which can make programming easier. We will discuss parameters which can be restored after terminal restart (shutdown). All examples are real working code segments from my Cayman project.

The SetTradeLevel script allows setting the parameters of a trading level. One object (straight line, trend line or rectangle) is selected on the chart. The SetTradeLevel script finds the selected object (trading level) and sets its parameters.

SetTradeLevel script parameters

Next, the script saves the parameters to Files\Cayman\Params\128968168864101576\exp_05_Lev607A160E_H4.txt and sends the command and the path to the file via the SendCommand function.

Author: Malik Arykov

 

Why do I need third-party services to send a message to my smartphone? Are they any better? There is Push messages in the terminal.

If you need to transfer information at once (i.e. script created something and EA immediately accepted it) - ok. If EA needs, for example, to load and get information about trading (martin level at the moment, order groups, etc., which is not in the orders themselves), then it is better to somehow manage without files and local storage as much as possible. Most users will forget that there is a file somewhere and will get a surprise when transferring the Expert Advisor to another terminal.

Also, in addition to the comment in the orders (positions) there is also a magik, in which you can also encrypt information.

I would also pay attention to the performance and the number of checks on the arrival of information.

 
Sofiia Butenko:

Why do I need third-party services to send a message to my smartphone? Are they any better? There's Push messages in the terminal.

If you need to transfer information at once (i.e. script created something and EA immediately accepted it) - ok. If EA needs, for example, to load and get information about trading (martin level at the moment, order groups, etc., which is not in the orders themselves), then it is better to somehow manage without files and local storage as much as possible. Most users will forget that there is a file somewhere and will get a surprise when transferring the Expert Advisor to another terminal.

Also, in addition to the comment in the orders (positions) there is also a magik, in which you can also encrypt information.

I would also pay attention to the performance and the number of checks on the arrival of information.

1) A sound for each type of notification.

2) The user does not need to know about the files. This is the logic of programmes. If there is a file - restore parameters, if there is no file - use default values.

3) I can see order comments in the terminal and can immediately tell what was wrong with a losing deal. Since I can see the situation before opening an order at once.

4) Sorry, I don't understand about performance and number of checks. Can you show me with your finger

 
Malik Arykov:

1) A different sound for each type of notification.

2) The user does not need to know about the files. This is the logic of the software. If there is a file - restore parameters, if there is no file - use default values

3) I can see order comments in the terminal on the history and I can immediately tell what was wrong with a losing deal. Since I can immediately see the situation before opening an order

4) Sorry, I don't understand about performance and number of checks. Can you show me with your finger

1) ok, although there has never been such a request from users. There were requests for SMS long time ago and for that third-party services were needed.

2) Obligatory if the file is necessary to load the EA and it should be transferred together with the EA. You did not understand my point.

3) And what was wrong with the losing trade? Sometimes you need hundreds of orders from real or history to restore the full picture of trading. Selecting each one stretches the resource, and in MT4 there may be no history (if it is not selected by the user), so all the search operations should be reduced to a minimum. I am not talking about simple cases.

4) How do you know that the second programme has created a graphical object? By constantly enumerating all objects and checking the name of each tick? And then the user will run a couple of dozens, or even a hundred versions and say "Do something I'm hanging". There were really such cases...

-------

All my opinion is based on my experience in freelancing - how to do that the user did not break anything and then did not complain.

 
Sofiia Butenko:

4) How do you know that the second programme has created a graphical object? By constantly going through all the objects and checking the name of each tick? And then the user will run a couple of dozens, or even a hundred versions and say "Do something I'm hanging". There were really such cases...

-------

All my opinion is based on my experience in freelancing - how to do that the user did not break anything and then did not complain.

4) The name of the graphical object with parameters is one and constant. I ran the script. I set the parameters and saved them in the graphical object. Every tick the Expert Advisor checks if there is only one object. If there is an object, it reads the parameters and immediately deletes it. The script and the Expert Advisor are on one chart. Experts on other charts do not know anything about it.

 
Sofiia Butenko:

2) Mandatory if the file is necessary to load the EA and it must be transferred together with the EA. You have not understood my point.

When launching an Expert Advisor or script, I get "No file PATH/AppSettings.txt. Please read the installation instructions"

 
Complicated about the simple... or what's more pathos to call an article about nothing.
 
Sofiia Butenko:

Why do I need third-party services to send a message to my smartphone? Are they any better? There's Push messages in the terminal.

From the help: "The SendNotification() function has strict usage limits: no more than 2 calls per second and no more than 10 calls per minute. The frequency of use is controlled dynamically, and the function can be blocked if violated."

These are serious restrictions, for example, if the Expert Advisor performs trading operations at the candle opening.

I use sending messages in Telegram.

 

Я пользуюсь отправкой сообщений в Телеграм.

I used to do something like that too, now I am not interested in sending anything or anywhere, the service built into the terminal is quite enough and I rarely look at it,

and in general I think that you can't slow down a trading robot by sending messages..... which for one reason or another can suspend the trading robot itself,

but about Telegram and the solution proposed here I have to say that this article offers an order of magnitude simpler solution ..... thanks to the author

 
Boris Egorov:

In general, I believe that you should not slow down a trading robot by sending .... messages. which for one reason or another can suspend the trading robot itself,

WebRequest has a timeout parameter. For interest you can check the speed of WebRequest for WirePusher service by inserting Print(TimeCurrent()) before and after sending the request. As a rule, it is negligible. Well, if you still get an error code by timeout, you can make a request processing queue. The message didn't leave on the next tick, so it will leave on the next tick. The main thing is to remove them from the queue after successful sending ;-)

 
Aleksey Mavrin:
Difficult about the simple... or what's more pathetic to call an article about nothing.

+