Estimating margin requirements in MQL5 - page 2

 
Renat Akhtyamov:
https://www.mql5.com/ru/docs/constants/environment_state/accountinformation#enum_account_info_integer

And what can you see there? That leverage is a property of the account, not a symbol and not a moment in time, whereas the actual contract specs of the two DCs in the above fragments indicate that it is not. What did you mean by that?

 
Vladimir:

And what can be seen there? That leverage is a property of the account, not a symbol and not a moment in time, whereas in reality, in the cited fragments of the contract specifications of the two DCs it is stated that it is not. What did you mean by that?

Then the shoulder will have to be counted.

Request margin information from the server and you will be fine

 
Alexander Laur:

Check this out: https://www.mql5.com/ru/code/12076/131935#!tab=code

That might help.

That link doesn't exist, apparently there was some particularly sensitive information there :)

I think there is no way to determine it unless there is a function to determine the actual leverage for a given symbol, i.e. a function where the name of the symbol is specified.


P.S. Maybe there is a possibility, but I haven't found it.

 
Alexander Laur:

And here is an indicator with the bail calculation including

Don't try, your links don't open.

But it doesn't matter, how can you calculate the margin level if you have no leverage for a given symbol ?

 
Petros Shatakhtsyan:

This link doesn't exist, it must have been very secret information :)

I think there is no way to determine it unless there is a function to determine the real leverage for a given symbol, i.e. a function where the name of the symbol is specified.


P.S. Maybe there is a possibility, but I haven't found it.

yeah they're all broken
 
Alexander Laur:

Then I don't know how to help. I downloaded the indicators from my computer.

What do you mean, no leverage?

Isn't it clear what we are talking about?

Let's explain in simple terms. Suppose we have a lot of open positions on different symbols. And we want to open a new position, say, on a new symbol. And we need to identify the size of a valid lot (volume) for that.

If we do not know the real (trading) leverage of a symbol, how can we determine the lot?


 
Alexander Laur:

Is leverage defined for a symbol and not for an account?


And I thought that after my explanation even a schoolboy would understand.

And the surprising thing is that there are a lot of good developers here, but for some reason this is the third year I've raised this issue on this form and more than once.

 
Alexander Laur:

Is leverage defined for a symbol and not for an account?

This command will help you find out the effective leverage for the trading account:

PS: I have corrected the link to the code, look it up.

It won't help here.

It has different leverage on different sims.

Leverage can be calculated based on margin, because the server will respond with the sum of the deposit already taking into account the leverage

 
Alexander Laur:

You don't seem to know what you are talking about.

Leverage varies from account to account: 1:100, 1:200, 1:300, etc. The leverage does NOT depend on the number of open positions, it's a constant for the account. The leverage affects the margin requirements for the account, not the symbol. What does it mean? This means that in an account you can open positions with different symbols and different volumes, as long as the total margin of open positions does not exceed the total margin allowed for the account, which is determined by the leverage!

There is a command in the MQL5 language, which shows the free margin in an account, not some symbol:

In the code I linked to, there is a calculation of margin to open a position on any instrument. The GetMarginForOpening() function calculates the deposit. Do not be lazy, take a look.

Obviously, it's difficult to discuss anything with you.

First, I've already said that your links do not open, and second, how can you calculate the margin, when the leverage changes and each symbol has its own leverage.

 
Vladimir:

An example from the contract specification of one DC where leverage is a property of the symbol, and even, as the DC writes, its rate.


A question has arisen:

How to evaluate the collateral of a trade in these conditions, more precisely, does OrderCheck() or OrderCalcMargin() take into account the features of leverage specified in the specification, which is "specified approximately".

I have also encountered such trading conditions:

"Yellow" indicates the instruments for which the margin requirements are increased.

...

For 15 minutes before and 5 minutes after the publication of economic news at the <High> level, the margin requirements
for new orders is calculated based on the maximum leverage of 1:200. Upon expiry of the specified period
After the designated period, the margin for these positions will be recalculated based on the account balance and the leverage value set.
From 19:00 GMT+0 Friday to 23:00 GMT+0 Sunday the margin requirements for newly opened positions will be calculated
From 19:00 GMT+0 Friday and 23:00 GMT+0 Sunday the margin requirements for newly opened positions will be calculated with maximum leverage of 1:200".

Increased is for example 0.5% for all allowed leverages instead of 1% for 1:200, 0.2% for 1:1000 and 0.1% for 1:2000.

Again the same question arises. Who is in the know, please advise.

I just need to check. It's not like anyone is hiding the formula for calculating the margin.

Lots*Contract_Size*price/Leverage

Hence Leverage = Lots*Contract_Size*price/Margin

And Margin can be obtained from

 double Margin = 0;
 bool calcMargin = OrderCalcMargin(orderType, symbol, Lots, price, Margin);
Then there will be clarity on whether or not it counts.
Reason: