Questions from Beginners MQL5 MT5 MetaTrader 5 - page 668

 
Leo59:
And how, in my question, can OnTimer() be applied ?

Well, it's not for me to know what you'll be counting before the market opens)

For example like this:

// В Init ставим флаг connection=false;

void OnTimer() {
// Обрабатываем информацию независимо от работы рынка в функции DataProcessing
DataProcessing();

if(TimeCurrent()>starttime) { // если рынок работает
   connection=true; // ставим флаг в положение "true"
   ...             // или сразу обрабатываем весь остальной код, в основном - торгвый
  }
}

void DataProcessing() {
// что-то делаем по таймеру
}

if(connection==true) { // или здесь торговые операции и остальной код, чтоб не в таймере
  ...
}

 
Vitaly Muzichenko:

Well, it's not for me to know what you'll be counting before the market opens)


Thank you Vitaly for your sincere attempts to help!!!!
Apparently, the issue needs to "settle down". I may have to change the logic of the code architecture. "It's always better in the morning".
THANK YOU VERY MUCH again !!!!
 
Leo59:
Thank you Vitaly for your sincere attempts to help!!!!
Apparently, the issue needs to "settle down". I may have to change the logic of the code architecture. "It's always better in the morning".
Thanks a HUGE THANK YOU again !!!!

Try it this way, it will now be "0" - Sunday

TimeDayOfWeekTimeGMT() )
 
Leo59:
Artyom, the question was about how to define the day off programmatically without resorting to TimeLocal(). ))

Seen, heard, read ;)

But you said that you need to calculate everything first, and then "out into the world". And you asked how a timer would help with that - so that's what your question suggested, not about defining a day off.

 
Vitaly Muzichenko:

Try it this way, it will now be "0" - Sunday

TimeDayOfWeekTimeGMT() )

Right!!! Returns "0". THANKS!!!!

And I've been looking to see what I can get back

Return codes of the trade server


Code

Constant

Description


132

ERR_MARKET_CLOSED

Market is closed

 
I wonder what else, apart from OrderSend(), returns error 132 - market closed?
 
Leo59:
I wonder what else besides OrderSend() returns error 132 - market is closed?
nothing, just making a trade operation
 
Vitaly Muzichenko:
nothing, just making a trade transaction
)) In principle, that's quite enough!!!!
THANK YOU!!!!
 
Leo59:
)) In principle, that's quite enough!!!!
THANK YOU!!!!
Look here, there's a primitive solution at the end of the thread.
 
Vitaly Muzichenko:
Look here, at the end of the branch there is a primitive solution.
It's strange, the developers must have screwed something up. What is the difference between the functions other than Name?


Allows you to get the start time and the end time of the specified quotation session for the specified symbol and day of the week.

bool  SymbolInfoSessionQuote(
   string            name,                // имя символа
   ENUM_DAY_OF_WEEK  day_of_week,         // день недели
   uint              session_index,       // номер сессии
   datetime&         from,                // время начала сессии
   datetime&         to                   // время окончания сессии
   );

If data is received for the specified session, symbol and day of the week, returns true, otherwise returns false.

и

Allows you to get the start and end time of the specified trading session for the specified symbol and day of the week.

bool  SymbolInfoSessionTrade(
   string            name,                // имя символа
   ENUM_DAY_OF_WEEK  day_of_week,         // день недели
   uint              session_index,       // номер сессии
   datetime&         from,                // время начала сессии
   datetime&         to                   // время окончания сессии
   );

If data is received for the specified session, symbol and day of the week, returns true, otherwise returns false.