Errors, bugs, questions - page 42

 
Kos:
What's the point of compiling such a construction if it will lead to inability to load the MQL5 program?

Thanks for the post. The NULL parsing error forthe condit operator has been fixed.
 

What is the maximum number of dynamic arrays in an indicator?

Документация по MQL5: Основы языка / Типы данных / Объект динамического массива
Документация по MQL5: Основы языка / Типы данных / Объект динамического массива
  • www.mql5.com
Основы языка / Типы данных / Объект динамического массива - Документация по MQL5
 
dentraf:

What is the maximum number of dynamic arrays in an indicator?

Limitations are dictated by your hardware resources.

How much memory is available.

 
dentraf:

What is the maximum number of dynamic arrays in an indicator?

There are no more than 512 indicator arrays. In general any arrays - as many as there is enough memory
 

wrote this script to check the function

OrderCalcMargin()

it returns error 4002, what did I do wrong?

void OnStart()
  {
   int total=SymbolsTotal(false);
   double marginbay;
   double marginsell;
   MqlTick pr;
   for(int i=0;i<=total;i++)
     {
      if(OrderCalcMargin(ORDER_TYPE_BUY,SymbolName(i,false),1.0,pr.ask,marginbay))
         Print("Маржа для покупки "+SymbolName(i,false)+" = ",DoubleToString(marginbay));
      else Print("Ошибка  № - ",GetLastError());

      if(OrderCalcMargin(ORDER_TYPE_SELL,SymbolName(i,false),1.0,pr.bid,marginsell))
         Print("Маржа для продажи "+SymbolName(i,false)+" = ",DoubleToString(marginsell));
      else Print("Ошибка  № - ",GetLastError());

     }
  }
 

it is strange if you do not use the structure of the request for current prices then everything is calculated except for instruments like #AA in this case it returns zero, I wonder why? how then to calculate the margin for such instruments

void OnStart()
  {
   int total=SymbolsTotal(false);
   double marginbay;
   double marginsell;
   //MqlTick pr;
   for(int i=0;i<=total;i++)
     {
      if(OrderCalcMargin(ORDER_TYPE_BUY,SymbolName(i,false),1.0,SymbolInfoDouble(SymbolName(i,false),SYMBOL_ASK),marginbay))
         Print("Маржа для покупки "+SymbolName(i,false)+" = ",DoubleToString(marginbay));
      else Print("Ошибка  № - ",GetLastError());

      if(OrderCalcMargin(ORDER_TYPE_SELL,SymbolName(i,false),1.0,SymbolInfoDouble(SymbolName(i,false),SYMBOL_BID),marginsell))
         Print("Маржа для продажи "+SymbolName(i,false)+" = ",DoubleToString(marginsell));
      else Print("Ошибка  № - ",GetLastError());

     }
  }
Документация по MQL5: Получение рыночной информации / SymbolInfoTick
Документация по MQL5: Получение рыночной информации / SymbolInfoTick
  • www.mql5.com
Получение рыночной информации / SymbolInfoTick - Документация по MQL5
 
I figured out why the first option didn't work, I should have written the function
SymbolInfoTick(SymbolName(i,false),pr);
in the loop body to get the quote for the requested symbol.
void OnStart()
  {
   int total=SymbolsTotal(false);
   double marginbay;
   double marginsell;
   MqlTick pr;
   for(int i=0;i<=total;i++)
     {
      SymbolInfoTick(SymbolName(i,false),pr);
      if(OrderCalcMargin(ORDER_TYPE_BUY,SymbolName(i,false),1.0,pr.ask,marginbay))
         Print("Маржа для покупки "+SymbolName(i,false)+" = ",DoubleToString(marginbay));
      else Print("Ошибка  № - ",GetLastError());

      if(OrderCalcMargin(ORDER_TYPE_SELL,SymbolName(i,false),1.0,pr.bid,marginsell))
         Print("Маржа для продажи "+SymbolName(i,false)+" = ",DoubleToString(marginsell));
      else Print("Ошибка  № - ",GetLastError());

     }
  }
The question about null values of instruments of type #AA is still relevant
 
sergey1294:

wrote this script to check the function

Returns error 4002, what did I do wrong?


sergey1294:
I figured out why the first version didn't work, I should have written the function in the loop body to get the quotes for the requested symbol.

You just decide to help... :)

PS

I don't know about others, but the market is kind of closed for #AA...

 
Do I understand correctly that a code of the following type
AccountInfoDouble(ACCOUNT_FREEMARGIN) - OrderCalcMargin();
is an analogue of the MT4 function
AccountFreeMarginCheck()
 
sergey1294:
I also have a question, do I understand correctly, that this type of code is an analogue of the MT4 function?

If there are no open positions the statement will probably be correct, if there are open positions the picture is a bit different...