Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 487

 
igrok333:

How can I read line 8 of a file?

Question relates to file operations

https://docs.mql4.com/ru/files


Everything in mql is done by brute force, as someone once told me?


You can't do it any other way?

All data types have a certain size of occupied memory in bytes. Accordingly, when writing code, you can use it and shift the file pointer to the number of bytes occupied by the data of one string.

If a line contains 4 values of double type, it takes 4*8 = 32 bytes. Accordingly, to read the 9th line of file, we need to shift the file pointer to 256 bytes.

bool  FileSeek(
   int                  file_handle,     // handle файла
   long                 offset,          // в байтах 
   ENUM_FILE_POSITION   origin           // позиция для отсчета
   );
bool  FileSeek(file_handle, 265, SEEK_SET);

If shifted from the end of the file, then the value must be negative.

But, it's not all that smooth. Some time ago, I dealt with this issue and found out that .txt and .csv files don't work correctly with this, but .bin files don't make mistakes. Perhaps this problem has already been fixed and you might get lucky.

 
Alexey Viktorov:

If there are 4 values of type double

aren't all values in a csv file string?


I have a word for each line in the file.
So I have string values with a size of 12 bytes.
So, to get to line 8, I need to shift the carriage by 84 bytes.

bool  FileSeek(file_handle, 84, SEEK_SET);

Thanks for the info.

 
How do I loop through all open positions in mql 5?
 
Roman Sharanov:
How in mql 5 to make a loop on all open positions?
this is the mql4 topic
 
igrok333:
this is the mql4 topic

No, this topic is both mql4 and mql5

 
Roni Iron:

Good afternoon!

Question: how to speed up the tester in the terminal?

I have it using only 1 CPU thread out of 4, and only 150mb of RAM. (i.e. it doesn't use all the power of my PC).

What are the options?

If this has already been discussed, drop the links Please!

If MT4 then only CPU frequency plays a role here. Uses one thread ? You can launch simultaneously 4 MT4 terminals with different testing or optimization tasks. You will get the same CPU load as on one terminal.

 
Roman Sharanov:
How can I loop through all open positions in mql5?

mql5 distinguishes between positions and orders. A position is the result of a trade. And a trade is the result of triggering of an order.

First of all, a trade request is sent to the server, and either a pending order (if the request was to set one) or a market order (if the request was to open a position) appears.

If the market order triggered (a trade occurred), a position appears (or an existing position is modified) as a result of this trade.

On a hedge account there can be many separate positions (including multidirectional), on a netting account there can be only one position.

So, to loop through all positions, you need to organize the loop by their number - respectively, use PositionsTotal() instead of usual for mql4 OrdersTotal().

If we want to loop through all orders in mql5, then (in mql5) we use the usual for mql4 OrdersTotal().

 
igrok333:

but aren't all values in csv file string?


I have a word for every line in the file.
So I have string values with a size of 12 bytes.
So I need to move the carriage to line 8 by 84 bytes.


Thanks for the info.

The text file has to be read only line by line. There is no other way to calculate the line number. So - yes, only by consecutive reading in loop using FileReadString.

 

I create Fibonacci levels in the chart using ObjectCreate(name,OBJ_FIBO, ...) and then ObjectSetFiboDescription(name,0,"...") and set description of levels but names should be moved away from the right edge. I added white space, but it not only moves text away but also covers lines. Also, if you add more spaces, the text stops moving back.
Question: Can I add an "invisible" symbol to the text, so it won't cover the line below it?


 
Maxim Khrolenko:

I create Fibonacci levels in the chart using ObjectCreate(name,OBJ_FIBO, ...) and then ObjectSetFiboDescription(name,0,"...") and set description of levels but names should be moved away from the right edge. I added white space, but it not only moves text away but also covers lines. Also, if you add more spaces, the text stops moving back.
Question: Can I add an "invisible" symbol to the text, so it doesn't cover the line under it?

try dots and a character with code 0

Reason: