Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 248

 
Roger:
Why are you reading from a file? You have the whole file in the ReadCBOE variable, you can use it,

No problem with it, but not all line fits in the variable! MT has its own restrictions on the length of line, while the file is written to the info from the site, and the file ends </body></html> while the line - breaks at 65k characters (or so). In any case the final file size is 69KB.

 
Integer:

Read the article. Basically there is no way in nature to read a given line of a file, you have to read all lines up to a given line... There is a function in the article for reading a text file line by line.

Wow, thanks, didn't find it myself, should have searched by HTML tag.
 
Zhunko:

That's how it works. Checked it out.


Anyway, there is an error, and here it is
if (FileWriteString(hFile, sTextWrite, 10000) < 0)
writes ALL the stringto the file, regardless of the 3 parameters of the function, which is responsible for the size of the string.
 
Integer:
You're a hero, Junko, silently fixing the code and... as if that's what happened. You're going to tell me it was like that, and I'm just bullshitting you? Yeah?

Fixed what? Checking for NULL? That's fine. What's wrong? If I find a mistake, I fix it.

You don't fix it. I saw that. Even when you pointed it out, you didn't correct it. You like making mistakes and not correcting them? Then you brag about it?

=============

I'm excused. I almost never write in MQL4. I have written everything I need. I don't work with descriptors and errors. They were written long ago, encapsulated and forgotten.

In C++, descriptors are usually compared to NULL.

mzk_3om6u:

Anyway, there is an error, and here it is
if (FileWriteString(hFile, sTextWrite, 10000) < 0)
writing ALL string to the file, regardless of 3 function parameters which are responsible for string size.
It's not. It works. It's just that this code doesn't overwrite the file. You are looking at a file that is already written. It doesn't seem to work. In fact, it was written where it should be, but the continuation of the line is still the old one.

Write something else, or delete the file, or put a write-only flag on it.

 
Zhunko:

Fixed what? Checking for NULL? That's fine. What's wrong? If I find a mistake, I fix it.

You don't fix it. I saw that. Even when you pointed it out, you didn't correct it. You like making mistakes and not correcting them? Then you brag about it?

=============

I'm excused. I almost never write in MQL4. I have written everything I need. I do not work with descriptors and errors. They were written long ago, encapsulated and forgotten.

In C++, descriptors are usually compared to NULL.

It's not. It works. It's just that this code doesn't overwrite the file. You're looking at a file that's already written. It doesn't seem to work. In fact, it was written where it should be, but the continuation of the line is still the old one.

Write something else, or delete a file or set a write-only flag.


Yep, it's working...Thanks.
 
Hello! Is MetaTrader for Windows Phone or Windows RT coming out, and when is it scheduled to come out?
 
Good time. Please help me to sort out the error.
extern int OpenHH = 14; // Время открытия ордеров (часы).
extern int OpenMM = 25; // Время открытия ордеров (минуты).

extern int CloseHH = 23; // Время закрытие/удаление ордеров (часы).
extern int CloseMM = 45; // Время закрытие/удаление ордеров (минуты).


This part of the code works and there are no complaints about it. Orders on Friday, 23:45 close normally. The DeleteOrders() function works fine.

if (DayOfWeek() == 0 || DayOfWeek() == 6 ) return(0); // В выходные не работаем.
if (!IsTradeAllowed()) return(0); // Пропустить тик, если терминал занят.
if (Close_All_Orders) // Разрешение на закрытие ордеров.
if (DayOfWeek() >= 5 && // Если пятница и закрытие ордеров разрешено, то
TimeHour(TimeCurrent()) >= CloseHH && // в назначенный час
TimeMinute(TimeCurrent()) >= CloseMM ) // в назначенные минуты -
{ DeleteOrders(); return(0); } // все ордера закрываются.


The code for opening orders is made by analogy. The code does not work at all in the specified form.
However, if we remove or comment out the line with minutes, everything works fine and orders open at 14:00. The function OpenOrders() works fine.
What may be the problem in this (or other) code line: TimeMinute(TimeCurrent()) >= OpenMM ?

if (Trade) // Разрешение на торговлю.
if (TimeHour(TimeCurrent()) >= OpenHH && // В назначенный час,
TimeMinute(TimeCurrent()) >= OpenMM ) // в назначенные минуты -
{ OpenOrders(); return(0); } // открыть ордера.


PS: Basically, there are quite a few EAs on the Internet which open and close orders by time. But, for one reason or another, they may not be satisfactory. I would like to deal with the above error...

Thank you...

 
Crosswert:
Good afternoon. Help me out with this error.


Everything seems to be correct, it should work. Tried your code in mine - it works with minutes. But only from 14:25 to 14:59, from 15:25 to 15:59 etc.

int start()
  {
  int OpenHH=14,OpenMM=25;
  bool Trade=true;
//----
if (Trade) // Разрешение на торговлю.
 if (TimeHour(TimeCurrent()) >= OpenHH && // В назначенный час
 TimeMinute(TimeCurrent()) >= OpenMM ) // в назначенные минуты - 
 { OpenOrders();Print("Время пришло ",TimeHour(TimeCurrent()),":",TimeMinute(TimeCurrent())); return(0); } // открыть ордера.   
//----
   return(0);
  }
//+------------------------------------------------------------------+
void OpenOrders(){return(0);}


 

Maybe that's better.

if ((Hour() == OpenHH && Minute() >= OpenMM) || (Hour() > OpenHH))
 
Sepulca:

Maybe that's better.

Just swap places. Hour()>OpenHH more often than hour and minutes.