How do you calculate the margin? - page 3

 
Mislaid:

In order for the leverage to change, a trade has to be made. I once deleted a forgotten and unpromising pending order. Put things in order, so to speak. As a result, the account leverage was reduced from 500 to 100.

No. You need a re-connect or a trade to make the terminal see this update. And the leverage applies without that, it just affects you not necessarily immediately.

 
Andrey Khatimlianskii:

Yes, it is.

Only, most likely, the leverage changes not for an individual trade, but for the instrument as a whole, but it doesn't change the essence.

I'll add an alert to my informer for this case...

I have it as a must in every program

moreover

if the leverage has changed, then the trading is banned

leverage is a very serious thing and you better not let them get away with it ;)

 
Andrey Khatimlianskii:

Yes, it is.

This is very unfortunate. I somehow thought it was obvious that such information should be readily available along with other properties of an open position. Apparently, we will have to regularly compare the calculated value of the total margin for all orders with the actual one and in case of a significant difference suspend trades and inform the trader.

Andrey Khatimlianskii:

The leverage is likely to change not for an individual order but for the symbol as a whole, but it doesn't change the essence.

Mislaid:

The AccountLeverage() function hints that the leverage changes for the account. For individual symbols, the leverage may differ from the account leverage depending on the exotics of the symbol (Fx Minors, Fx Exotics, Fx Rub) and the volume of the position.

I may have forgotten to write this, but in my case the leverage changes not for an instrument (symbol) and not for the account as a whole, but for an individual position. This is stipulated in the regulations and confirmed by the broker's technical support reply and my real-time experiment. For this reason, all formulas that contain in one form or another such parameters of the account and symbol as ACCOUNT_LEVERAGE or MARGIN_REQUIRED become useless. This was the reasoning behind my question.

 
Janis Ozols:

I probably forgot to mention this, but in my case, the leverage changes not for an instrument (symbol) and not for the account as a whole, but for a single position. This is stipulated in the regulations, confirmed by the broker's tech support response and my real-time experiment.

They said several times.
Only I still doubt it.

How did you test it? Were you able to find a formula in which the margin is equal to the displayed one, something like "lot1*common leverage + lot2*common leverage + lot3*extended leverage"?

 
Andrey Khatimlianskii:

How did you check? Were you able to find a formula that would make the margin match the displayed one, something like "lot1*leverage_usual + lot2*leverage_usual + lot3*leverage_expanded"?

No, it didn't work that way. The case was on a real account and my main task was to identify toxic positions as soon as possible and close them before the irreparable happened. There turned out to be two of them. I don't think it's possible in principle to create a formula for identifying such positions with 100% accuracy. So far I have simply gone through all open positions to calculate the calculated margin and then compare it with the actual margin. In case of a discrepancy, trades are suspended and a notification is sent to the trader. I should probably add closing the last open position in case of a critical Margin Level.

 
Janis Ozols:

No, that's exactly how it failed. The case was in a real account and my main concern was to identify toxic positions as soon as possible and close them before the irreparable happened. There turned out to be two of them. I don't think it's possible in principle to create a formula for identifying such positions with 100% accuracy. So far I have simply gone through all open positions to calculate the calculated margin and then compare it with the actual margin. In case of a discrepancy, trades are suspended and a notification is sent to the trader. I should probably add closing of the most recently opened position in case of a critical Margin Level.

toxic?

this may be a joke.

your advice is simple - recalculate the margin 1 to 100 if this is the minimum leverage.

I think your case is 1 to 33.

and you won't have to worry about defining risk, it'll be more or less a constant.

The sudden increase in risk freaked you out, didn't it?

 
Janis Ozols:

No, that's exactly how it failed. The case was in a real account and my main concern was to identify toxic positions as soon as possible and close them before the irreparable happened. There turned out to be two of them.

Well, it's just that when you increase the total lot, the leverage for the instrument changes.

It's not about specific positions.

 
Renat Akhtyamov:

Your advice is simple - recalculate the margin 1 to 100 if that is the minimum leverage

I think your case is 1 in 33.

and you won't have to worry about defining risk, it'll be more or less a constant.

The sudden increase in risk freaked you out, didn't it?

Yes, that's what's bugging me. Expert Advisor that works in this account determines the lot size when opening a position based also on the amount of margin, which is directly related to the leverage. Naturally, it was a complete surprise to him that the margin requirement increased 30 times after the position was opened. Your recommendation to reduce the calculated risk in this situation seems quite reasonable. Unfortunately, it will also decrease the profitability by a multiple...

 
Andrey Khatimlianskii:

Well, it's just that as the total lot increases, the leverage for the instrument changes.

It's not about specific positions.

You may be right. But the broker's regulations talk about specific positions. And the Technical Support employee wrote me about the same thing.

In addition, while I was waiting for an answer, I repeatedly requested the amount of margin for this instrument using the MarketInfo(_Symbol, MODE_MARGINREQUIRED) function and made requests of AccountFreeMarginCheck for a specific symbol, position direction and lot. In all cases the margin requirement for the instrument exactly matched the leverage set in the account settings (1:1000). But the amount of margin on open positions exceeded it many times over. Until I closed the last open position and then the penultimate one.

If the leverage for an instrument changed due to an increase in the total lot or some other reason, it would be logical to expect that these requests should have returned an increased amount of margin, no?
 
Janis Ozols:

Yes, that's exactly what's bugging me. The Expert Advisor that runs on this account determines the lot size when opening a position, including the amount of margin, which is directly related to the leverage. Naturally, it was a complete surprise to him that the margin requirement increased 30 times after the position was opened. Your recommendation to reduce the calculated risk in this situation seems quite reasonable. Unfortunately, it would also reduce the return by a multiple...

nobody wants to lose profits in a moment and regret wasted time, among other things.

time is money

there will be stability, there will be something to think about

Reason: