Writing to the file on a new line - page 4

 

On top of the lines it seems to be possible to write, at least writing a new line in place of the first line is possible without any special difficulties.


//Открываем файл 
   int h1=FileOpen("Copy.txt",FILE_WRITE | FILE_READ,";");
   FileSeek(h1, 0, SEEK_SET);
   FileWrite(h1,Symbol(),OP_BUYSTOP,OrderLots()*Koof,OrderStopLoss(),Slippage,0,0,IntegerToString(OrderTicket()));
   FileClose(h1);
// закрываем файл
 
Now you have options, it's up to you to decide how you want to proceed
 
EfremovSergey:

It seems to be possible to write on top of the lines, or at least to write a new line in place of the first line without any special difficulties.


That's brilliant! In a pinch, in a nickel...

If you have to write something down, you have to write it down. Where, when, how, why and to whom, we don't give a shit. Our job is to write it down, and whoever needs to read it, let them do it themselves...

 
Maxim Kuznetsov:

That's brilliant! Spot on, spot on...

if there's something to be written down, it has to be written down. Where, when, how, why and who, we don't give a shit. Our job is to write it down, and who needs to read it - let them do it themselves...

Well, yes, that's not much of an option...

You can write new information or just trash in a line, but for some reason you can't delete it at all... strange story...

 

Figured out how to work with the file, thank you very much and thank you very much.

Such a question, a bit of an off-topic.

As a result of reading the line

string s=FileReadString(h)

we get the value of s which implies the data to open the order, e.g. EURUSD,5,0.02,1.17808,70,0,0,302090516

Is it possible to somehow substitute this value as a whole into the OrderSend operation without extracting each constituent descriptive part of the order to be opened separately?

OrderSend(s)

Of course it doesn't work

OrderSend - Торговые функции - Справочник MQL4
OrderSend - Торговые функции - Справочник MQL4
  • docs.mql4.com
[in]  Цвет открывающей стрелки на графике. Если параметр отсутствует или его значение равно CLR_NONE, то открывающая стрелка не отображается на графике. При открытии рыночного ордера (OP_SELL или OP_BUY) в качестве цены открытия могут использоваться только самые последние цены Bid (для продажи) или Ask (для покупки). Если операция проводится по...
 
The function takes values of several variables of different types, and you have a string.
 
EfremovSergey:

In my view, if you don't get rid of the information that has already been processed, then you will have to spend resources on re-analysing it.

Information if within a single EA does not need to be written to a file if it does not need to be read itself. if from the outside, then write an empty file to the file after reading it.

 
Aleksei Stepanenko:
The function takes values of several variables of different types, and you have a string.

That's the question... how to "painlessly" make a variable enumeration from a string. Using the StringSubstr function results in a very non versatile solution. StringSplit doesn't quite understand how it works... Maybe some conversions can be done?

 
Valeriy Yastremskiy:

The information, if within one EA, does not need to be written to the file, if you do not need to read it yourself. if from the outside, then write an empty file to the file after reading it.

If we want to make a separate EA that will open orders for any pair and the EA of a particular pair will already intercept the open order into the control, then this will probably work, but if each EA of a particular pair will need to work with the file individually, then synchronisation in this way will be impossible.

 

Let me try again to convey the idea of the convenience of using an array

struct MyData
   {
   string   symbol;              // символ
   int      operation;           // торговая операция
   double   lot;                 // количество лотов
   double   stoploss;            // stop loss
   double   takeprofit;          // take profit
   int      magic;               // идентификатор
   } my[];

for(int i=0; i<ArraySize(my); i++)
   {
   if(my[i].magic==MagicNumber)
      {
      eTicket=OrderSend(my[i].symbol,my[i].operation,my[i].lot,ePrice,(int)SymbolInfoInteger(my[i].symbol,SYMBOL_SPREAD),
			my[i].stoploss,my[i].takeprofit,NULL,my[i].magic,0,eColor);
      }
   }

I've already written how to save this array to a file.

Or parse your string.