Errors, bugs, questions - page 2634

 

Hello!

I want to run some MT4 with a batch file.

Can you please tell me how to do this and why my code doesn't work:

SET MY_PATH=C:\"Program Files (x86)"
%MY_PATH%\001\terminal.exe
TIMEOUT /T 160
%MY_PATH%\002\terminal.exe
TIMEOUT /T 160
%MY_PATH%\003\terminal.exe
TIMEOUT /T 160
%MY_PATH%\004\terminal.exe
TIMEOUT /T 160
%MY_PATH%\005\terminal.exe
TIMEOUT /T 160
%MY_PATH%\006\terminal.exe
TIMEOUT /T 160
%MY_PATH%\007\terminal.exe
TIMEOUT /T 160
%MY_PATH%\008\terminal.exe
TIMEOUT /T 160
%MY_PATH%\009\terminal.exe
TIMEOUT /T 160
%MY_PATH%\010\terminal.exe
TIMEOUT /T 160
%MY_PATH%\011\terminal.exe
TIMEOUT /T 160
%MY_PATH%\012\terminal.exe
TIMEOUT /T 160

At best it runs a few MT4s, then hangs.

Of course there is no shortage of RAM.

Besides, I've tried it on different computers

 
Igor Zakharov:

no, it doesn't.

the server time, by the way, does not stop on Saturday. here is the opposite: in the terminal, the server time is updated with the arrival of a new quote. For example, you have only one symbol open in the market overview (not only in the tester, but also in reality). and there are no ticks for five seconds - all this time the server time timer will not move. this is true for Saturday: the server time is running, but the terminal does not know about it, because there are no ticks. the tester will simply miss this period.

I have already checked. In the tester,TimeLocal works on weekends,TimeTradeServer does too, butTimeCurrent of course doesn't. There are no ticks, but the server time is still there.

int OnInit()
{
  Print(__FUNCTION__," TimeCurrent     ",TimeCurrent());
  Print(__FUNCTION__," TimeLocal       ",TimeLocal());
  Print(__FUNCTION__," TimeTradeServer ",TimeTradeServer());

    EventSetTimer(3*3600);
 return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnTimer()
{
  Print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  Print(__FUNCTION__," TimeCurrent     ",TimeCurrent());
  Print(__FUNCTION__," TimeLocal       ",TimeLocal());
  Print(__FUNCTION__," TimeTradeServer ",TimeTradeServer());
}
 
Igor Zakharov:

https://www.mql5.com/ru/forum/328008/page2#comment_14166682

As always, bicycles.

The question here is why it doesn't pass.
After all, the variables from the parameters, have initial values.

void MxResize(int row=1, int col=1)
{
   int A[row][col];    
      
}

And if you specify the size of the measurements in numbers

void MxSize(int row=1, int col=1)
{
   int A[1][1];    
      
}

The compiler skips it, what's the trick?

Would the developer comment on this?

 
Andrey Khatimlianskii:

For what purpose? To run auto-optimisation at the weekend? Then setting a timer from OnTick at a distance of a few minutes would work. If it works, then the ticks have stopped and you can optimise.

If for other purposes, formulate them.

No, not for other purposes.

I didn't think that TimeLocal worked on weekends so I did this: I added a few hours to TimeCurrent and checked the day of the week. If it's Saturday, then start optimizing.

Of course I can't be sure about the beginning of the Saturday, because the market closes differently on Friday or on holidays.

Also, I haven't found anywhere a means to determine whether the market is closed or not.

 
Petros Shatakhtsyan:

No, not for any other purpose.

I didn't think TimeLocal worked on weekends so I did this: I added a few hours to TimeCurrent and checked the day of the week. If it's Saturday, then start optimizing.

Of course I can't be sure about the beginning of the Saturday, because the market closes differently on Friday or on holidays.

Also, I haven't found anywhere a means to determine whether the market is closed or not.

Have you tried ?

SymbolInfoSessionTrade

or

SymbolInfoInteger(SYMBOL_TRADE_MODE)

Something of them should be good

 
Aleksey Mavrin:

Have you tried it?

SymbolInfoSessionTrade

or

SymbolInfoInteger(SYMBOL_TRADE_MODE)

One of them should be good, I remember.

No, I haven't. The manual doesn't specify how to determine whether the market is opened or not.

The thing is that when the market "opens" on Monday, for example at one broker the quotes start coming in at 02:05 but transactions are not accepted for a few minutes and displays "Market closed".

I do not know if this will help or not.

SYMBOL_START_TIME

Starting date of the instrument (usually used for futures)

 
Petros Shatakhtsyan:

No, I haven't. The guide does not specifically say how to determine whether the market is open or not.

The thing is that when the market "opens" on Monday, for example at one broker the quotes start coming in at 02h.05, but no deals are accepted for a few more minutes, it gives out "Market closed".

I do not know if this will help or not.

SYMBOL_START_TIME

This is the symbol_start_time (usually used for futures)

TheSymbolInfoSessionTrade shows when trade starts andSymbolInfoSessionQuote when quotes arrive.

ap: this should help.

boolIsTradeAllowed(
const string symbol// symbol
datetimetested_time//time
);

Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
  • www.mql5.com
Получение рыночной информации / SymbolInfoSessionQuote - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Roman:

As always, bicycles.

The question here is why such an entry doesn't go through.
After all the variables from the parameters have initial values.

And if you specify the size of the measurements in numbers

then the compiler skips it, what's the catch?

Will the developer comment on this?

Roman, this is the second time you have fallen for an elementary unwillingness to read the documentation.

Only aninteger can be an array index. No more than four-dimensional arrays are allowed. Numbering of array elements begins with 0. The last element of a one-dimensional array is numbered 1 less than the array size, i.e. accessing the last element of an array of 50 integers will look like a[49]. The same is true for multidimensional arrays - one dimension is indexed from 0 to dimension size-1. The last element of the two-dimensional array in the example would look like m[6][49].

Static arrays cannot be represented as timeseries, i.e. the ArraySetAsSeries() function that sets access to array elements from the end of an array to its start is not applicable to them. If you want to provide access to an array like in timeseries, use a dynamic array object.

If you access outside the array, the executing subsystem will generate a critical error and program execution will stop.

And in the mql4 documentation, if memory serves me correctly, it was clearly stated that variables should not be used as an array size.

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Переменные должны быть объявлены перед их использованием. Для идентификации переменных используются уникальные имена. Описания переменных используются для их определения и объявления типов. Описание не является оператором. Индексом массива может быть только целое число. Допускаются не более чем четырехмерные массивы. Нумерация элементов...
 
Roman:

As always, bicycles.

The question here is why such an entry doesn't work.
After all, variables from parameters, have initial values.

And if you specify the size of the measurements in numbers

Then the compiler skips it, what's the trick?

Will the developer comment on it?

I'm not a developer, but I'll comment.

For a static array, the compiler has to allocate a certain number of bytes in memory already at compile time.

How much memory has to be allocated by the compiler if we don't know row and col at the compilation time?

Initial values are only used if parameters are omitted when calling. The actual parameters are only known at runtime.

So, no gimmicks, learn the language.

 
Aleksey Mavrin:

No, that's not it,SymbolInfoSessionTrade shows when there's trading andSymbolInfoSessionQuote when the quotes come in.

ap: this should help.

boolIsTradeAllowed(
const string symbol// symbol
datetimetested_time//time
);

I don't think it does. There's a special topic here :https://www.mql5.com/ru/forum/40295

Didn't look at it all the way through, especially since it's for MQL4.

I don't think the server should send symbol quotes if the market is closed.

My robot is not really affected by this because after the market "opens" when the ticks come in it analyses the trend, their reversals, and that takes some time. During this time the market opens.

But it gets in the way if we want to manually execute some trades during this time. If execution is market-based, the request is pending until the market opens and is naturally executed at the current price.

The direct function that receives name of the symbol and returns true/false (market open/closed) is clearly missing.

Как правильно выяснить, что рынок закрыт? (mql4)
Как правильно выяснить, что рынок закрыт? (mql4)
  • 2015.01.31
  • www.mql5.com
Перевел советника в режим работы OnTimer() теперь когда рынок закрыт он этого не понимает и пытается торговать, в общем обращается к серверу и естественно получает ошибки и забивает логи журнала.
Reason: