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

 
alexey1979621:

Hi all, I've already asked a similar question on page 711, unfortunately no one has responded, maybe now someone...

I do this:

I bring the situation to zero cumulative position (locking), then close the lock.

Now, detailing.

1. Calculation of aggregate position:

Reverse orders

If we buy, our aggregate position is increased by the order lot.

If selling, the aggregate position is reduced by the order lot.

End of orders search cycle

2. Creating a Location:

if the aggregate position is above zero, we sell;

if the aggregate position is below zero, we will buy;

Otherwise, we do nothing.

The lot size is equal to the aggregate position.

3. Closing a lot (overlapped positions)

Endless loop ( while (true) )

Reset to zero the ticks of the buy and sell orders

loop over the orders

if (buy) commit the ticket for a buy order

if (sell) commit the sell order ticket

close the order loop

if( there is a sale and a buy) then a cross-close

otherwise exit the endless loop (break)

end of infinite loop

Now we program this algorithm in the selected language (MQL4)

 

guys, tell me if I set a closing time for a pending order

Data_1=iTime(Symbol(),PERIOD_D1,0) +86400; //the order life time

if it is already in the market (i.e. has already been executed),it will close or not

 
korobok777:

guys, tell me if I set a closing time for a pending order

Data_1=iTime(Symbol(),PERIOD_D1,0) +86400; //the order life time

if it is already in the market (i.e. has already been executed),it will close or not

no
 
artmedia70:
no
Thank you very much.
 

Hi all, I've never worked with file operations but I had to and I can't figure it out.

The task is to write data into csv file several times every day

That is today 24.09.2014 data is written in a row in different cells of the type

A B C

1 Date | value | value

if today's data has changed, we overwrite the row from 24.09.2014

if it's a new day, we rewrite the new line.

I'm smoking and I can't get a smoke...

 
VOLDEMAR:

Hi all, I've never worked with file operations but I had to and I can't figure it out.

The task is to write data into csv file several times every day

That is today 24.09.2014 data is written in a row in different cells of the type

A B C

1 Date | value | value

if today's data has changed, we overwrite the line from 24.09.2014

if it's a new day, we rewrite the new line.

I'm smoking and I can't get a smoke...

void Запись()
{
  int handle;
  string st=TimeToStr(TimeCurrent(), TIME_DATE);
  string filename = st+" Bid_Ask.csv"; // Формируем имя файла
  handle = FileOpen(filename,FILE_CSV|FILE_READ | FILE_WRITE,';');
  if(handle < 1)
  {
    Print("Не удалось создать файл. Ошибка #", GetLastError());
    return;
    //FileClose(handle);
  }
  
  FileWrite(handle,                   
            " Время ",
            " Bid ",
            " Ask ",
            " Volume "); // заголовок
  FileSeek(handle, 0, SEEK_END);
  FileWrite(handle,
            TimeToStr(TimeCurrent(),TIME_MINUTES|TIME_SECONDS),
            Bid,
            Ask,
            Volume[0]);
 
  FileClose(handle);
  return;
}
It must be something like this.
 
r772ra:
Probably something like this.

and how do I rewrite the last line if the data has changed ?

 
VOLDEMAR:

how do I rewrite the last line if the data has changed ?

FileSeek(), help.

 

If the data have changed, we should put the pointer to the place where we will overwrite it with fileseek, overwrite it with standard filewrite... method, remember the end of the file and trim it with WinApi function

Or using standard method, write position to the end of file, where useful information ends, and then read this position. (You can write the position to another file).

But anyway, you'd better trim it, and there is no standard trimming tool ((

this isZhunko12.09.2014 20:19#

It would be interesting as WinApi functions

 
ALXIMIKS:

If the data have changed, we should put the pointer to the place where we will overwrite it with fileseek, overwrite it with standard filewrite... method, remember the end of the file and trim it with WinApi function

Or using standard method, write position to the end of file, where useful information ends, and then read this position. (You can write the position to another file).

But anyway, you'd better trim it, and there is no standard trimming tool ((

this isZhunko12.09.2014 20:19#

It would be interesting to have the same WinApi functions.

How sad, it's so complicated.

Reason: