[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 487

 

Simple question, no answer found.

How to add new data to a text file (NOT on a new line!!! but on the same line!)

For example there is a file with an array of the following form: 382;1;-1;1;1;-1;1;1;-1;1;-1;1;-1;1;...;1;crlf

you need to add this : 383;1;-1;1;1;-1;1;1;-1;1;1;-1;1;...;1;crlf

FileWrite() adds extra crlf, besides I don't know how to change the first number.

 
laveosa:
Hello all, advise how to check how the last order was closed, with stop or profit. I understand that I need to use OrdersHistoryTotal, but please advise how to do this and give an example.

There is an example in the description of the functionOrdersHistoryTotal

 
kakin:

Thank you. I've been looking and thinking too.

Victor, do you know where else to find training articles on MKL by Roche?


They are on Alpari. Roche posted the links. I'm too lazy to search.
 
Lyuk:

Simple question, no answer found.

How to add new data to a text file (NOT on a new line!!! but on the same line!)

For example there is a file with an array of the following form: 382;1;-1;1;1;-1;1;1;-1;1;-1;1;-1;1;...;1;crlf

you need to add this : 383;1;-1;1;1;-1;1;1;-1;1;1;-1;1;...;1;crlf

FileWrite() adds extra crlf, besides I don't know how to change the first number.

So I don't have to bother much with splitting the file, read it into an array (string or parse), fix it, write it back.
 
Zhunko:
So you don't have to bother much with splitting up the file, read it into an array (string or parse), fix it, write it back.
Thanks, I guess I'll have to do that (overwrite with cleanup), but can you tell me how to "dissect" ?
 
Vinin:

They are on Alpari. Roche has posted links. I'm too lazy to look.
OK. Thank you. I'll look harder. Didn't find any yesterday.
 
Lyuk:
Thanks, probably will have to do so (overwrite with cleanup ), but can you still tell me how to "split up" ?

In general, these files are not intended to be edited. If the file is small, it is better to rewrite it. Larger files should be processed through mapping to make it faster.

Split up the file by indexing delimiters. Preparing indexes is long, but then it works fast.

 

I'm a bit stuck on the implementation of the order placing algorithm.

The essence is that there is a ticket, I switch on the enumeration with a condition to find the ticket:

for(int ot=0; ot<=OrdersTotal(); ot++)
 {
  if(OrderSelect(ot,SELECT_BY_POS)==true)
   {
     if(OrderMagicNumber()==magic)
      {
       if(УСЛОВИЕ МОДИФИКАЦИИ)
        {
         МОДИФИКАЦИЯ
        }
      }
   }
 }

If any of the orders corresponds to a magik, we modify it.

We have another task: if none of the orders corresponds to a Magic, we should set a new pending order. if(OrderMagicNumber()!=magic) will not work here.

How can we implement this condition without resorting to third-party custom functions?

 

I want to know the ticket numbers of the orders that were closed with stops. I want to get the order ticket numbers that were closed with stop and I've come up with -1 and that's it, can you tell me what's wrong?

for(int i=0;i<history;history=0)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
{
hi_stop=OrderStopLoss();
if(Bid<hi_stop)ticket=OrderTicket();
}
}
if(ticket_caunt!=ticket)
{
Print("___________________________________________________ticket-",ticket);
ticket_caunt=ticket;
}
 
laveosa:

I want to know the ticket numbers of the orders that were closed with stops. I want to get the order ticket numbers that were closed with stop and I've come up with -1 and that's it, can you tell me what's wrong?

for(int i=0;i<history;history=0)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
{
hi_stop=OrderStopLoss();
if(Bid<hi_stop)ticket=OrderTicket();
}
}
if(ticket_caunt!=ticket)
{
Print("___________________________________________________ticket-",ticket);
ticket_caunt=ticket;
}
Try to play (edit for your needs) f-and Kim I.V isCloseLastPosByStop - Returns flag of closing of last position by stop

and NumberOfPositions - Returns the number of positions, and maybe others will fit your question...

Reason: