Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1454

 
JRandomTrader #:

Alas, not quite so. I have already shown here how I received code 10012, zero order ticket, but the order was executed. MQ are silent on this matter.

I wrote a crutch for it, but it will be possible to check it only after receiving 10012 again ).

This is an exception to the rules, and a person cannot understand the difference between orders, deals and positions. And you also confuse him with exceptions))))))

When he understands how it works, he will be able to write a check for his own needs.

 
Aleksandr Slavskii #:

... and a person can't understand the difference between orders, trades and positions . ..

When he understands how it works, he will be able to write a check for his own needs.

Everything is described in detail here.

Regards, Vladimir.

 

thanks, seems to have it figured out!!!!


//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction&    trans,     // структура торговой транзакции
                        const MqlTradeRequest&        request,   // структура запроса
                        const MqlTradeResult&         result)    // структура ответа
  {
//--- результат выполнения торгового запроса
 ulong            lastOrderID   =trans.order; 

//--- тип транзакции
   ENUM_TRADE_TRANSACTION_TYPE  trans_type=trans.type;
   switch(trans.type)
     {
      case  TRADE_TRANSACTION_POSITION:   // изменение позиции
        {

        }
      break;
      //---
      case TRADE_TRANSACTION_ORDER_ADD:    // добавление нового действующего ордера
        {
         fix_position_open(lastOrderID);
        }
      break;
      case TRADE_TRANSACTION_REQUEST:    // добавление нового действующего ордера
        {

        }
      break;
     }
//---
  }
//--- Фиксируем если позиция открыта --------------------------------+
void fix_position_open(ulong lastOrderID)
  {
//--- Фиксируем если позиция открыта
   for(int i=0; i<ArraySize(position_buff); i++)
      if(position_buff[i].timeOp==1)
         if(!match_open_orders(lastOrderID))
           {
            position_buff[i].timeOp= 0;     // Фиксировать время
            Print("Метод OnTrade() по рынку не выполнен. Код возврата=",m_trade.ResultRetcode(),
                  " (",m_trade.ResultRetcodeDescription(),")"+position_buff[i].comment+" lot "+DoubleToString(position_buff[i].lot));//
           }
         else
           {
            position_buff[i].timeOp= TimeCurrent();
            Print("Метод OnTrade() по рынку выполнен успешно. Код возврата=",m_trade.ResultRetcode(),
                  " (",m_trade.ResultRetcodeDescription(),")"+position_buff[i].comment+" lot "+DoubleToString(position_buff[i].lot));//
           }
  }
//--- Соответствие открытых ордеров ---------------------------------+
bool match_open_orders(long lastOrderID)
  {
//---
   for(int i=PositionsTotal()-1; i>=0; i--)
      if(m_position.SelectByIndex(i))
         if(m_position.Identifier()==lastOrderID)
            return(true);
   for(int i=OrdersTotal()-1; i>=0; i--)
      if(m_order.SelectByIndex(i))
         if(m_order.Ticket()==lastOrderID)
            return(true);
   return(false);
  }
 
Mikhail Toptunov #:

thanks, seems to have it figured out!!!!

A position is opened when an order is executed, i.e. a deal is made and the order goes into history.

 
What to do if not all functions are available in MQL5
 
Baruandreas #:
What to do if not all functions are available in MQL5

Forget mql4 altogether and constantly read mql5 documentation.

 
Baruandreas #:
What to do if not all functions are available in MQL5

Your question is not clear. First clarify your question:

  1. Are we talking about already existing functions in MQL5?
  2. Is there a function in the set of ready-made functions in MQL5, but it does not work?
  3. Do you need a certain function, but there is no such function in the set of ready-made MQL5 functions?
Regards, Vladimir.
 
MrBrooklin #:

Your question is not clear. First, clarify your question:

  1. Are we talking about already existing functions in MQL5?
  2. Is there a function in the set of ready-made M QL5, but it does not work?
  3. Do you need a certain function, but there is no such function in the set of ready-made MQL5?
Regards, Vladimir.

As it was found out later, this is one of those who pollutes the whole forum with his question. He even created a separate topic...

 
Alexey Viktorov #:

As it was later found out, it's one of those people who clogs up the whole forum with his question. He even created a separate topic...

Hi Alexey, now everything is clear.

Regards, Vladimir.

 
Hi all.
This situation - there are indicator values in csv file, recorded from a single tester run - indicator values are calculated on each tick.
I want to use this data for optimisation in OHLC mode - to check for coincidence of the condition in a particular minute of trading. Optimisation on ticks is better not to propose - such a test will grow multiple times and is unnecessary for such optimisation.
The problem is that the file is large - about a million lines, and it is labour-intensive to correlate the pair "date, time - value" at each minute.

Here and think how to do - so far here are the following thoughts: creating a custom symbol and comparing values with it; use of a database. Can you tell me what solution would be optimal, maybe someone who has solved such a problem?
Reason: