Questions from Beginners MQL5 MT5 MetaTrader 5 - page 958

 

I'm really confused about pending orders and positions when accessing the deal history.

If a pending order triggered and moved to a position and was successfully closed (deal), then how is it stored in the history cache as an order or as a position?

How do I address it as a position or as an order through the status?

 
vladzeit:

I'm really confused about pending orders and positions when accessing the deal history.

If a pending order triggered and moved to a position and was successfully closed (deal), then how is it stored in the history cache as an order or as a position?

How do I address it as a position or as an order through the status?

Studying this section of the documentation should help.

First an order, it goes into a trade, then a position. Then if it is a netting account more orders and deals and at the end an order in the opposite direction with a lot equal to the existing position, from it a deal and no position. It is closed and there is no position in the history, there are only orders and deals that have created, changed and closed this position. But all of them are connected to the position ID.
Документация по MQL5: Торговые функции / HistorySelectByPosition
Документация по MQL5: Торговые функции / HistorySelectByPosition
  • www.mql5.com
Не следует путать между собой ордера из торговой истории и действующие отложенные ордера, которые отображаются на вкладке "Торговля" в панели "Инструменты". Список ордеров, которые были отменены или привели к проведению торговой операции, можно посмотреть  в закладке "История" на панели "Инструменты" клиентского терминала. Функция...
 

4758

Failed to calculate profit or margin


How can this be fixed?

 
Alexey Viktorov:

Studying this section of documentation should help.

First an order, it goes into a trade, then a position. Next, if it is a netting account more orders and deals and at the end an order in the opposite direction with a lot equal to the existing position, from it a deal and no position. It is closed and it is not in the history, there are only orders and deals that have created, changed and closed this position. But all of them are connected to the position ID.

Alexey. I have read the primer, but you have explained everything in your own words in an easier way than it was written there... Everything is clear and understandable. Thank you)

 
vladzeit:

Alexey. I have read the primer, but you have explained everything in your own words in an easier way than it was written there... Everything is clear and understandable. Thank you)

Please.




But I said "study the section", not read it. It's all there, but scattered with descriptions of various functions of this section, it's just documentation, not a beginner's book. There are other articles as well. Surely there must be one of them that talks about it.

 
Alexey Viktorov:
Please.




But I said "study the section", not read it. It's all there, but scattered with descriptions of the various functions of this section, it's just documentation, not a primer for beginners. There are other articles as well. Surely there must be one of them that talks about it.

You're right, I should be studying, not just reading, what aroused interest at the moment. But I'm following my emotions and my desire to get a quick and practical result, implemented in the form of a working algorithm.

And I'm trying to get from mql5 only what I need for solving this narrow task... As a result I have a lot of gaps in education)

I already seem to be able to recognize letters, but they don't want to form words and sentences).

It is also difficult because there is no exact textbook with examples and exercises, and the Help is designed for those, who already have some programming experience and in fact explains only their own syntax.

Of course there is a lot of information on the forum, but everything is very scattered and sometimes not reliable due to new changes in mql5.

I probably should have started my acquaintance with mql4... There are obviously more tutorials there, and then, having received the basic experience, an idea, start using mql5, studying its differences.

I'm partially doing so, looking for examples in mql4 and trying to implement them in mql5 by analogy. But sometimes because of the cardinal differences of some functions and principles it makes me even more confused)))).

Apparently all the self-taught go through this).

What you said above, I will certainly take into account, at least I will try).

 

After updating the terminal, the Expert Advisor stopped building.

Error

'INIT_FAILED' - expression not boolean  

What could be the problem?

//+------------------------------------------------------------------+
//| Lots or risk in percent for a deal from a free margin            |
//+------------------------------------------------------------------+
bool LotsOrRisk(const double lots,const double risk,const int digits_adjust)
  {
   if(lots<0.0 && risk<0.0)
     {
      Print(__FUNCTION__,",ERROR: Parameter(\"lots\" or \"risk\") can't be less than zero");
      return(false);
     }
   if(lots==0.0 && risk==0.0)
     {
      Print(__FUNCTION__,", ERROR: Trade is impossible: You have set \"lots\" == 0.0 and \"risk\" == 0.0");
      return(false);
     }
   if(lots>0.0 && risk>0.0)
     {
      Print(__FUNCTION__,", ERROR: Trade is impossible: You have set \"lots\" > 0.0 and \"risk\" > 0.0");
      return(false);
     }
   if(lots>0.0)
     {
      string err_text="";
      if(!CheckVolumeValue(lots,err_text))
        {
         Print(__FUNCTION__,", ERROR: ",err_text);
         return(false);
        }
     }
   else if(risk>0.0)
     {
      if(m_money!=NULL)
         delete m_money;
      m_money=new CMoneyFixedMargin;
      if(m_money!=NULL)
        {
         if(!m_money.Init(GetPointer(m_symbol),Period(),m_symbol.Point()*digits_adjust))
            return(INIT_FAILED);
         m_money.Percent(risk);
        }
      else
        {
         Print(__FUNCTION__,", ERROR: Object CMoneyFixedMargin is NULL");
         return(INIT_FAILED);
        }
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+

This is the function the compiler is swearing at

return(INIT_FAILED);
 
ilvic:

After updating the terminal, the Expert Advisor stopped building.

Error

What could be the problem?

This is the function the compiler is swearing at

The LotsOrRisk() function is declared as a bool. It means that it can only return true OR false.

 
Juer:

Apparently it's more my hardware's fault... and my system.

Upgraded the system to vin10, did a disk check with bit sector localisation. Well, I'll have to upgrade to SSD I guess.

The compile also took over 10 minutes. It's not normal for it to take so long to compile...

 
Good afternoon.
Is it possible for the indicator to display the input parameters on the chart? Maybe there is a ready example?