Questions from Beginners MQL5 MT5 MetaTrader 5 - page 522

 
toni_stark:
Can you please tell me the code: EA opens one order per day, how to close these orders at the end of the day, e.g. 23:50?
if(TimeCurrent()>=D'23:50') close_all();
 
Vasyl Nosal:
if(TimeCurrent()>=D'23:50') close_all();
In this case, will all orders be closed or only the ones opened by the EA?
 
toni_stark:
Will this option close all orders or only those which have been opened by the EA?
It depends on the closing function.
 
toni_stark:
In this case, will all orders be closed or only those opened by the Expert Advisor?

:)))

What you write in the close_all() function

 
which parameter or function will help to shift the indicator up or down by n-points?
Files:
 
Vasyl Nosal:

:)))

What you write in close_all()

It's not completely clear with the close_all() function, it's not in the metaiditor. Maybe the OrderClose() function is meant?
 
toni_stark:
It's not entirely clear about the close_all() function, it's not in the metadvisor. Maybe the OrderClose() function is meant?

he means something like this

//+------------------------------------------------------------------+
void сlose_all()
  {
   double price=0;
   bool error;
   int total=OrdersTotal();

   for(int i=total-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS))
        {
         //Print(__FUNCTION__);

         if(OrderType()==OP_BUY)
           {
            RefreshRates();
            price=NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),(int)MarketInfo(OrderSymbol(),MODE_DIGITS));
            error=OrderClose(OrderTicket(),OrderLots(),price,10000,clrBlue);
            if(!error) PrintFormat("Error № %d closing the order. Ticket: %d",GetLastError(),OrderTicket());
           }
         if(OrderType()==OP_SELL)
           {
            RefreshRates();
            price=NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),(int)MarketInfo(OrderSymbol(),MODE_DIGITS));
            error=OrderClose(OrderTicket(),OrderLots(),price,10000,clrBlue);
            if(!error) PrintFormat("Error № %d closing the order. Ticket: %d",GetLastError(),OrderTicket());

           }
         if(OrderType()>1)
           {
            error=OrderDelete(OrderTicket());
            if(!error) PrintFormat("Error № %d delete the order. Ticket: %d",GetLastError(),OrderTicket());
           }

        }

     }
  }
//+------------------------------------------------------------------+
 
Sergey Gritsay:

he means something like this

Got it, a custom function.
 
Dear programmers. Can you help? I have to "tighten" an EA (I am laying it out) to set the number of open orders. I do not know if it will help. I put these owls on several pairs and only one order is opened. If I open an order on one of the pairs the signals on the other pair are not ignored. I do not know what to do with it.
Files:
 
Sorry...my mistake (And when an order is open on one pair, the signals on the other pair are INVOIDED)
Reason: