[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 337

 

I found the file. I had to give the program administrator rights so that it could save to the file.

Now I have another question.

How to determine the last operation number to insert in OrderSelect()?

I'm doing this

 int total=OrdersHistoryTotal();

Print("total " + total);
OrderSelect(total,SELECT_BY_POS,MODE_HISTORY);
FileWrite(handle,"OrderTicket : " + OrderTicket(),", OrderLots : " + OrderLots(),", OrderType : " + OrderType(),", OrderClosePrice : " + OrderClosePrice());

It says that total = 322

But there are zeros in the file

 

I did the following

OrderSelect(total-1,SELECT_BY_POS,MODE_HISTORY);

And everything worked )))

Is this correct or it may cause an error in time?

I.e., may it accidentally return the value not of the last order in the history but of some other one?

 
overrun orders site:mql4.com
 

Can you tell me if it makes a difference if you write

if(условие)
{
   if(условие)
   {
      if(условие)
      {
         ...
      }
   }
}

or

if(условие && условие && условие)
{
   ...
}
 
speed of complex conditions site:mql4.com
 

Why does this "trawl" get the error "OrderModify error 1" in the tester every second and in large quantities? Logs just swell to gigabytes... What needs to be fixed?

void Stop() {

 int    i, o=OrdersTotal();
 for (i=0; i<o; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
     if (OrderType()==OP_BUY) {
        if (OrderOpenPrice()>OrderStopLoss()&&OrderOpenPrice()-OrderStopLoss()>StopLoss*Point) {
           OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point,OrderTakeProfit(),0,CLR_NONE);
          }
         }
      if (OrderType()==OP_SELL) {
         if (OrderOpenPrice()<OrderStopLoss()&&OrderStopLoss()-OrderOpenPrice()>StopLoss*Point) {
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+StopLoss*Point,OrderTakeProfit(),0,CLR_NONE);
          }
      }
      }
      }
 
  return(0);
}
 
Google:
the speed of complex conditions site:mql4.com
Of course, there is some common sense in hints about search, but you could have just written: yes, there is. And explain in a nutshell that the use of logical comparison in 4 is not organized optimally.
 
artmedia70:
There is, of course, some common sense in the search hints, but you could have just written: yes, there is. And explain in a nutshell that the use of logical comparison in 4 is not organised optimally.
Or maybe Google wants to become a moderator?
 
Shniperson:

Why does this "trawl" get the error "OrderModify error 1" in the tester every second and in large quantities? Logs just swell to gigabytes... What needs to be fixed?

You should not try to modify the same value. If, for example, Stop is at 1.2300 and you modify it to 1.2300, you'll make a mistake - there is nothing to modify. Check for the equality of modified values
 
snail09:
Does Google want to be a moderator?
Or president of All Russia? :)
Reason: