Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1592

 
Игорь Любченко #:
I have no such thing!

1) Read the log, directly in the terminal, as advised above.

2) Lately, communication failures along the signal route have become more frequent. Try, after switching on, to wait for some time. 3-5 minutes. The connection should be found. :-//

 
Miguel Angel Vico Alba #:

From what I can see, your main problem is that MT is not connecting to the internet, correct?

You don't need to check the log (I only provided it based on your last post).

To see what the problem might be, go to the "Log" tab in the terminal. There you will see what is happening (any error message).

This is usually related to antivirus, firewall, etc. Check all of these.

Where is the "Log" tab in the terminal?
Files:
6gty8t.JPG  288 kb
 
Игорь Любченко #:
Where is the "Log" tab in the terminal?

It's right there.

Press ctrl+t on your keyboard

 

My ATR code in MQl5 is not opening for trade after successfully  tested, any advice ? 

 

Hi everyone, I recently started using the web version of mt-5. On mobile tablets. Different manufacturers. And 1 time I did not load indicators at all. On the chart. And the web-interface itself looked strange. Compared to how it looked afterwards. I don't know what it's connected with. I guess they have simplified ones. Versions for bad internet connections or something. Because how the interface has changed in this web version of mt-5. Indicators started loading on the chart immediately. Well, and the interface itself is much more pleasant and functional. Even on android and Huawei they are more like apple.

But why did I start using the web version? It is much faster than any app with the same internet. Charts load instantly. On any timeframe. And the interface itself is more sort of clear and friendly. And 1 and the same regardless of device manufacturer. In any browser. And everything works clearly and there are no glitches. I don't know how it was with this before. I'll probably give up on apps and only use the web version. Mt-5.

 

Good evening and good mood!

The other day I needed to come up with a function that would track the "lifetime" of each open position. For example, there are five different positions open, at different times, in different directions, and I need each of them to "live" no more than 10 days. I have sketched this code:

//+------------------------------------------------------------------+
//|Test_3.mq5 |
//+------------------------------------------------------------------+
input uint Time_Close_Pos = 864000; // Time interval for closing the position (in seconds)
//+------------------------------------------------------------------+
void OnTick() {TimeClosePos();}
//+------------------------------------------------------------------+
bool TimeClosePos()
  {
   datetime date_time = TimeCurrent(); // get the last known time of the server
   MqlDateTime mql_datatime = {}; // declare and initialise the mql_datatime variable for simplified access to the MqlDateTime structure
   TimeToStruct(date_time, mql_datatime); // convert from datetime type value to a variable of MqlDateTime structure type
   uint time_close = mql_datatime.day_of_week; // declare and initialise the time_close variable
   if(time_close >= 1 && time_close <= 5) // if the current time falls during the working week
      time_close = Time_Close_Pos; // variable is equal to the value specified in the input parameters
   else // otherwise
      time_close = Time_Close_Pos + 172800; // let's add 2 days off as well.
//---
   for(int i = PositionsTotal()-1; i >= 0; i--) // go through all the positions
     {
      ulong pos_ticket = PositionGetTicket(i);  // get a position ticket
      datetime time_pos_open = (datetime)PositionGetInteger(POSITION_TIME); // get the time of position opening
      if(TimeCurrent() > time_pos_open + time_close) // if the current time is in the specified range
         return(true); // it's time to close the position
     }
   return(false);      // the time to close the position has not yet come
  }
//+------------------------------------------------------------------+

However, the code turned out to be very long in terms of execution time.

Test_3.mq5
code generated
0 errors, 0 warnings, 941 msec elapsed, cpu='X64 Regular'

Almost a second (highlighted in yellow).

My question to real programmers - please suggest some simpler and faster version.

Regards, Vladimir.

 

Vladimir, remember the date of the expected closing of the oldest position, and wait for this date. The date has come, check for the position, delete it, remember the next date

 
Aleksei Stepanenko #:

Vladimir, check not on every tick, but once an hour, a day.

It is better to remember the date of the expected closing of the oldest position, and wait for this date. The date comes, check, delete if necessary, remember the next date

Thank you, Alexey, for your advice! I will try it. About each tick - it's just a test for execution time, but in the EA itself the check goes once a minute on the timer.

Regards, Vladimir.

 
The best version I rewrote, the loop only runs once when deleting a position and finding a new date.
 
Aleksei Stepanenko #:
The best version I rewrote, the loop only runs once when a position is deleted and a new date is found.

It is clear.

Regards, Vladimir.