Questions from Beginners MQL4 MT4 MetaTrader 4 - page 245

 

Catch for the robot

You can also put it in a script

void CloseAllPercent()
{
   bool result;
   while(OrdersTotal() > 0)
   {
      if(OrderSelect(0,SELECT_BY_POS) > 0)
      {
      if(OrderMagicNumber() == Magic)
      {
         switch (OrderType())
         {
            case OP_BUY :
            result = OrderClose(OrderTicket(),OrderLots(),Bid,5,Green);
            if(!result) Print("Ошибка закрытия ордера на покупку");
            break;

            case OP_SELL :
            result = OrderClose(OrderTicket(),OrderLots(),Ask,5,Orange);
            if(!result) Print("Ошибка закрытия ордера на продажу");
            break;
            }
         }
      }
   }
}  

 
Good evening! After 10 years, I decided to resume trading on the MetaTrader4 with Exness broker, I can't get any help with registration, and I understand that the broker is not working in Russia, I need help or can someone tell me what to do.
 
Tsaryoff5614:

Catch for the robot

You can also put it in a script

Pleaseinsert code correctly: when editing a post, click Code and paste your code in the popup window (the first time I edited your post and inserted the code correctly)
 

like this

   int i,accTotal=OrdersHistoryTotal();
   double loss_count=0;
   for(i=accTotal-1;i>=0;i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
         if(OrderMagicNumber()==MagicNumber
         &&OrderSymbol()==_Symbol
         &&OrderProfit()<0
         )loss_count++;
         else break;
   return count_entry;
 
Good afternoon, is it possible to create such an indicator to adjust the speed of the tester using the hotkeys (say ( ) with a left and (→) with a right arrow)? It is very inconvenient to adjust the speed every time manually
 
You can do it via Vinaipi. If no one writes, tomorrow or the day after tomorrow I will get to a computer and write how.
 
Good afternoon. Can you tell me how to write a Ticket Order(its unique number) to an array when you open it, for later use. mql4
 
makssub:
Good afternoon. Could you please tell me how to record a Ticket(its unique number) in an array when an order is opened for future use. mql4

OrderSend in 4 returns the ticket you want, that's when you open the order and write it down. And in 5 it returns the result of the operation, false or true. And there it should be additionally requested.

 
Valeriy Yastremskiy:

OrderSend in 4 returns the ticket you want, that's when you open the order and write it down. And in 5 it returns the result of the operation, false or true. And you have to request it additionally there.

Can you give me an example of some code?)

 
makssub:

can I have a bit of code as an example?)

Ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"",0,0,Blue);
static int it=0; // или в глобальной области обьявить  int it=0;
it=it+1;
Ticket[it]=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"",0,0,Blue);