Feedback on MQL5 - page 4

 

There is no way to make pads

No multiple inheritance in any form

Unclear pointers

No references

Unclear policy of copying structures. And classes as well.

There are no proper descriptions of errors and compiler-generated warnings with examples.

Problems with typification of integer types (and enums, I think).

This is just a quick glance.

It's just that everyone is used to it. It is possible to code, but the MQL5 language certainly can't be called fine and miraculous.

 
Developers can only be sympathetic, some are looking for simplicity and simplicity, others want all the features of high-level languages and need to please both of them and make everything work )
 
Renat Fatkhullin:

Take a look here, please: https://www.mql5.com/ru/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_double

Generally speaking, margin cannot be calculated on the basis of a single instrument because it is the resultant superposition of different positions/instruments. Also, in exchange execution, the margin calculation can be transferred (the exchange requires so) to the exchange itself, which, based on its complex and closed logic, generates the final margin.

For integral estimation "will I have enough margin if I make this transaction" there is a standard function OrderCalcMargin: https://www.mql5.com/ru/docs/trading/ordercalcmargin

Here is the code

string txt=NULL;
double GetMarginInitial=0,GetMarginMain=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(!SymbolInfoDouble(Symbol(),SYMBOL_MARGIN_INITIAL,GetMarginInitial))
     {
      Print(" SYMBOL_MARGIN_INITIAL ",GetLastError());
      return(false);
     }
   txt+="\n"+(string)(GetMarginInitial*SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN));

   if(!SymbolInfoDouble(Symbol(),SYMBOL_MARGIN_MAINTENANCE,GetMarginMain))
     {
      Print(" SYMBOL_MARGIN_MAINTENANCE ",GetLastError());
      return(false);
     }
   txt+="\n"+(string)GetMarginMain;
   
   Comment(txt);
   
   return(INIT_SUCCEEDED);
  }

On futures shows the initial margin requirement for one lot 5800 rubles, but when you use this code on the forex says 0 ...

In the help it says

SYMBOL_MARGIN_INITIAL

Initial (initiating) margin indicates the amount of margin required to open a position of one lot. It is used to verify client's funds when entering the market.


And nothing else .... How do I calculate margin for currencies? The only way out I see is to determine the type of instrument, and then calculate by formulas...

 
Vladimir Pastushak:

Here is the code

On futures it shows the initial margin requirement for one lot of 5800 rur, but when using this code on forex it says 0 ...

And in the reference it says

SYMBOL_MARGIN_INITIAL

Initial (initiating) margin indicates the amount of margin required to open a position of one lot. It is used for verification of client's funds when entering the market.


And nothing else ....

Yes, this parameter is for controlling margin requirements for futures.

Although for forex we can (need to make) ourselves recalculate and give a rough (because we do not know what the trader wants to do - buy or sell) value of margin per 1 lot.

 
Фьючерсные объемы для МТ:

There is no way to make pads

No multiple inheritance in any form

We will do this a bit later. We have the usual inheritance.


Unclear pointers

No references

There are references and pointers. They are safe and controlled.


Unclear policy of copying structures. And of classes, too.

Precisely comprehensible - structures with simple (not dynamic) fields are automatically copied. For the rest, write a copy function.

We're already planning to extend the mechanism of copying structures with some (non-class) dynamic types. This will make most of the work easier.


No proper description of compiler errors and warnings with examples.

Error and warning texts are the same/similar to other compilers. No one reinvented a wheel in this case.


Typing problems with integer types (and enums like)

Type rigidity is a priority. That's why the Cish freedom of dangerous assignments and conversions is not allowed.


The language is still under development and soon we will seriously upgrade the MQL4/MQL5 compiler when the new optimizing compiler (currently enabled through Optimize=1) will be released.

 
Serhiy Dotsenko:
dac already wrote how you can edit mql code in VS, you can't compile it, but you can edit it in VS and press f7 in ME )

Interested... Where did you write it? And if I want to use the standard classes, will you find them or will you have to type from memory?

I'm used to the code, but the editor I can not get used to, after other editors, as if I just switched to Notepad :)

 
sigma7i:

Interested... Where did you write it? And if I want to use the standard classes, will you find them or will you have to type from memory?

I'm used to the code, but I can't get used to the editor, after other editors, it's like I'm using Notepad :)

We'll upgrade the editor too, just had other priorities.

Perhaps we'll open the way for plugins.

 
Renat Fatkhullin:

Yes, this parameter is to control margin requirements for futures.

Although for forex, we can (must) recalculate and give a rough (because we do not know what a trader wants to do - buy or sell) value of margin for 1 lot.

Zeros are also returned for cfd indexes ... The help has formulas which are in principle sufficient but they are not commented out ...

Maybe someone knows what is


Margin: (Lots*ContractSize*MarketPrice*Percentage)/Leverage

Profit: (close_price-open_price)*Contract_Size*Lots


Percentage- what is it ?
 
Vladimir Pastushak:


Margin: (Lots*ContractSize*MarketPrice*Percentage)/Leverage

Profit: (close_price-open_price)*Contract_Size*Lots


Percentage - no one even says a word about it anywhere in the documentation...

Look in the terminal help - https://www.metatrader5.com/ru/terminal/help/trading_advanced/margin_forex
 
You can get these coefficients with SymbolInfoMarginRate, try
Reason: