Discussion of article "Functions for Money Management in an Expert Advisor" - page 4

 
Enigma71fx:

Of course it isn't. As you can see, even the author of the article named it "Functions for Money Management (...)". So I don't see a point in you remark. 

should changed to  "support Functions for Money Management  in MQL's library "
 
Roche! I can't take it for granted! Is the GetMarginForOpening() function intended to be universal for any chip present in the terminal or only for forex chips? I understand that this function returns the margin size in the deposit currency. But, the thing is that for XAUUSD pair, for example, for one lot this function returns the size of the gold trading contract in ounces (i.e. 100 ounces), but not the number of dollars in these ounces! Is this the way it is designed?
 
GODZILLA:
But, the thing is that for the XAUUSD pair, for example, for one lot, this function returns the size of the gold trading contract in ounces (i.e. 100 ounces), but not the number of dollars in these ounces! Is this the way it is designed?
Yes, the SymbolInfoInteger(..., SYMBOL_TRADE_CONTRACT_SIZE) function is supposed to return the size of the gold trade contract in some units. For gold it can be a troy ounce, for oil it can be a barrel, etc. How to find the value of this barrel or ounce? You can try OrderCalcMargin(), I think it was not available at the time of writing.
 

Rosh:
Да, по идее функция  SymbolInfoInteger(.., SYMBOL_TRADE_CONTRACT_SIZE)  возвращает размер торгового контракта по золоту в неких единицах. Для золота это может быть тройская унция, для нефти баррели и т.д. Как найти стоимость этого самого бареля или унции? Можно попробовать OrderCalcMargin(), кажется её еще не было на момент написания статьи.

Roche! I am talking about the GetMarginForOpening() function itself. The article states that this function returns the margin amount in the deposit currency, but in this particular situation this function does not work the way it is written in the article and returns the margin amount in contract units!

 

Nikolay, write your own. Yes, this article was written before the championship and for the championship (for forex instruments). Judging by the questions, you have figured it out yourself.

If you have questions about the functionality of MQL5 for your purposes, then it is another matter, but it does not concern the article.

Документация по MQL5: Основы языка / Функции
Документация по MQL5: Основы языка / Функции
  • www.mql5.com
Основы языка / Функции - Документация по MQL5
 
Rosh:

Nikolay, write your own. Yes, this article was written before the championship and for the championship (for forex instruments). Judging by the questions, you have figured it out yourself.

If you have questions about the functionality of MQL5 for your purposes, then it is another matter, but it does not concern the article.

I thought there was no point in reinventing the wheel when everything is already done, but it turns out that it is not! In this situation, it turned out that in the current state of MQL5 it is easier to do it all over again! Okay! I have already made a more universal variant!
 
Rosh:
SYMBOL                          EURUSD    #IBM
ACCOUNT_LEVERAGE                  100       100
SYMBOL_TRADE_CONTRACT_SIZE          100000    100
SYMBOL_BID                       1.24375   199.75
-------------------------------------------------
SYMBOL_MARGIN                   1243.75   19975.0

is the raw data and what we need to get.

SYMBOL_MARGIN = SYMBOL_TRADE_CONTRACT_SIZE/ACCOUNT_LEVERAGE*SYMBOL_BID

Don't you think there's something missing for a proper calculation?

because, for example, on #IBM it doesn't add up.


 
Don't talk in riddles. Did you find out that the calculation method written for forex doesn't work here?
 

Lot's of stock 100 sherds.Adequate margin.

Or am I missing something....

Testing IBM, I could not understand at first why it does not allow to open more than 0.5 lot. Then I realised. 50 sherds at the price of about 200 - it was the whole initial depot of 10 000 for the margin.

 
Rosh:

Don't talk in riddles. Did you find out that the calculation method written for Forex does not work here?

I'm saying that the formula needs to be modified to add one more indicator, which cannot be obtained directly from MQL5.

Like how many contracts are used in 1 lot.