Errors, bugs, questions - page 1233

 
Asked for a long time on 4 but never got an answer other than mockery))

returnsTimeGMT() whenStringToTime is wrong; e.g. whenStringToTime("0") - when the argument is not parsed.

And it returns normal time when the argument is parsed, e.g. whenStringToTime(" 24.10.2014") - D'2014.10.24 00:00:00'

Is this normal? WhyTimeGMT() specifically? This is -2 hours from my current time in MT4 and on my computer.

 
The question about the error 4806 was raised a long time ago " Why does the function CopyBuffer placed in a custom indicator, leads to the error 4806?

while the same function with the same parameters in the EA code works fine? "

my code works from the debugger, but does not work in normal mode (or rather, it works sometimes and I could not establish a simple pattern as to why it works and why it does not)

why do we need indicators like iXXX at all, if they cannot be used normally?

 
tyn:
The question about the error 4806 "Why does the function CopyBuffer placed in a custom indicator lead to the error 4806?

while the same function with the same parameters in the EA code works fine? "

my code works under the debugger, but it doesn't work in the normal mode (actually, it works sometimes and i couldn't establish the simple pattern why it works and why it doesn't)

What for do we need iXXX-type indicators at all if they cannot be used properly?

Afternoon. The data for the CopyBuffer is taken from the same TF in which your indicator is running?

Have you tried to use the BarsCalculated() function to solve the problem?

 
marketeer:
In MQL OOP, how do you check the type of a pointer to belong to a particular class - like instanceof in JavaScript or typeid in C++?
CObject *ob;
datetime t;

typename(ob); // CObject
typename(t);  // datetime
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Шаблоны функций
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Шаблоны функций
  • www.mql5.com
Основы языка / Объектно-ориентированное программирование / Шаблоны функций - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Can I set my own value (which is displayed) for the price tag instead of the price at which it is set? If so, how?
 
Tapochun:

Good afternoon. Is the data for CopyBuffer taken from the same TF where your indicator is running?

Have you tried to use the BarsCalculated() function to solve the problem?

Thanks for the question. I took data from iATR on D1 the main indicator is running on smaller timeframes, BarsCalculated() also returns -1 and the same error. As I'm guessing, there is a function but no indicator (in runtime). If I create an indicator in another window on the same tool, everything works. In debug mode it works too. But my question Is it a bug or I don't understand something?
 

Good afternoon.

Problem with function calls from system dll. The task is to write a simple TCP server in MQL5, which runs on a certain port and just receives messages.

Imported from ws2_32.dll functions WSAStartup(), WSAClenup(), socket(), bind(), accept(), listen(), recv(). Everything works exactly until you try to stop the server. When I try to stop server and terminate script correctly, terminal simply kicks out.

Since then the recv() function has been used as the scientific method.

In the attached file there is a line (171):

  int bytesCnt = recv(clientSocket, rcvBuffer, RCVBUFFSIZE, 0);

if it's configured to look like this:

  int bytesCnt = 10; //recv(clientSocket, rcvBuffer, RCVBUFFSIZE, 0);

then the server stops without any errors. I was looking at examples of using networking features on MSDN and did everything by analogy.

Does anyone have any idea how to solve this problem?

 
tyn:
Thanks for asking. I took data from iATR on D1 the main indicator works on smaller timeframes, BarsCalculated() also returns -1 and the same error. As I'm guessing, there is a function but no indicator (in runtime). If I create an indicator in another window on the same tool, everything works. In debug mode it works too. But my question Is it a bug or I don't understand something?

I've been struggling with this problem myself recently. I solved it, I don't know whether it was optimal, but I solved it. Only the data was taken from iFractals, but it doesn't matter. Why did I ask about the TF? According to my observations, the following thing happens. For example, the indicator works at M15. If the indicator data is requested from M1 to M15 - everything is ok, the data is available the moment it is requested (if not the first call). If data is requested from M30 (I repeat, the indicator runs on TF M15), then at the moment of request there is no data on M30 for a new candle (either we need a preliminary request, or the data is delayed by the tick). I have solved it in the following way. I remember the result of BarsCalculated() on the current candle. As soon as the next time BarsCalculated() returns value 1 more (a new candle has appeared), we remember the new valueof BarsCalculated() and copy the data. But this moment (when indicator data appears on the higher TF) does not coincide with the formation of a new candle in the current TF.

Yes,BarsCalculated() returns -1 when there is no data at all, it happens, as far as I know, only during the first run. That is, when you get the indicator handle and immediately request data. You also need to wait.

 

Immediately after the indicator handle has been created, the data cannot be queried as it is not ready. The initialisation and recalculation process is complex and depends on many factors.

The correct strategy is to create a handle in oninit and work with the data when the first tick arrives.

 
Renat:

Immediately after the indicator handle has been created, the data cannot be queried as it is not ready. The initialisation and recalculation process is complex and depends on many factors.

The correct strategy is to create a handle in oninit and work with the data when the first tick arrives.

Then this question. If the indicator is run on M15. A new candle is formed. When requesting data for M15 and M30, should they be available at the same time?