Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1280

 
Tango_X:
Hello! What does the number of activations mean when you buy the program in the marketplace ? Can I use this program on different computers and different accounts at the same time? The point is that we want to buy one program for two people and use each of them separately

it is better to order from freelancers - the type of programme and it will be yours with open source code.

 
Fergert Фергерт:
Please tell me how to check if an order of a certain type (in this case ORDER_TYPE_BUY_LIMIT ) or magic number is there and if it is closed, the EA will continue its work... I would be very grateful...

Example of counting four types of pending orders in Min Max for N Bars Martingale 2 code

//--- вызов функции
   int count_buy_limits=0,count_sell_limits=0,count_buy_stops=0,count_sell_stops=0;
   CalculateAllPendingOrders(count_buy_limits,count_sell_limits,count_buy_stops,count_sell_stops);
//--- сама функция
//+------------------------------------------------------------------+
//| Calculate all pending orders                                     |
//+------------------------------------------------------------------+
void CalculateAllPendingOrders(int &count_buy_limits,int &count_sell_limits,int &count_buy_stops,int &count_sell_stops)
  {
   count_buy_limits  = 0;
   count_sell_limits = 0;
   count_buy_stops   = 0;
   count_sell_stops  = 0;
   for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of current orders
      if(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its properties
         if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==InpMagic)
           {
            if(m_order.OrderType()==ORDER_TYPE_BUY_LIMIT)
               count_buy_limits++;
            else
               if(m_order.OrderType()==ORDER_TYPE_SELL_LIMIT)
                  count_sell_limits++;
               else
                  if(m_order.OrderType()==ORDER_TYPE_BUY_STOP)
                     count_buy_stops++;
                  else
                     if(m_order.OrderType()==ORDER_TYPE_SELL_STOP)
                        count_sell_stops++;
           }
  }

Min Max for N Bars Martingale 2
Min Max for N Bars Martingale 2
  • www.mql5.com
Поиск Минимальных и Максимальных цен на заданном количестве баров. Выставление отложенных ордеров
 

Good afternoon.

I want to close a position after Time has elapsed, I do this, but it doesn't work

if((TimeCurrent()-m_position.Time())>Time*3600)  {CloseOrders=true; ClosePositions(POSITION_TYPE_BUY); break;} //  если прошло много времени, закрываем !!!
               
 
Roman Kutemov:

Good afternoon.

I want to close a position after Time has elapsed, I do this, for some reason it doesn't work

Who is'ClosePositions'?

And how do you select the position?

 
Vladimir Karputov:

Who is'ClosePositions'?

And how do you select the position?

//| Close positions       по типу                                    |
//+------------------------------------------------------------------+
void ClosePositions(const ENUM_POSITION_TYPE pos_type)
  {
   for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of current positions
      if(m_position.SelectByIndex(i))     // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==InpMagic)
            if(m_position.PositionType()==pos_type) // gets the position type
               m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol
  }
 for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==InpMagic)
           {
            if(m_position.PositionType()==POSITION_TYPE_BUY)
              {
 
Roman Kutemov:

Who is'Time'? Set a breakpoint before issuing an order. Check if you hit a breakpoint at all?

(And yes: don't write multiple statements in one line)

 
Vladimir Karputov:

Who is'Time'? Set a breakpoint before issuing an order. Check if you hit a breakpoint at all?

(And yes: don't write multiple statements in one line)

Time - in external settings time in hours. For example, 7 hours after opening a position, if it has not closed at stop or take, I want to close it.
 
Roman Kutemov:
Time - in external settings time in hours. For example, 7 hours after opening position, if it has not closed at stop or take, I want to close it.

Forum on Trading, Automated Trading Systems and Strategy Tests

FAQ from Beginners MQL5 MT5 MetaTrader 5

Vladimir Karputov, 2021.01.27 17:49

*** Placea breakpoint before you issue an order. Do you ever check if you hit a breakpoint?

(And yes: do not write multiple operators in one line)


 
Vladimir Karputov:

Yes, you didn't.

Corrected. Thank you.

 
What does pythoon give that R cannot give ?
Reason: