How to get the "Percentage of Margin" programmatically - page 4

 
Alexey Viktorov:

Look, I'm amazed at statements like that.

Here's the code

here's the reading. 842.13 for current. and 50 for hedged positions.


Here's the Excell table with formulas and prices from the snapshot in the previous post. Study it...


The difference of 3 kopecks due to absence of EURUSD exchange rate at the moment of position opening for gold and this bullshit, in the second line... What else to explain?

he needs a function.

but he can't find the unstated function to determine the commission of the position

The philosophy is...


 
ir0407:

Gods do not burn pots. Coders from meta-quotes are human too and can make mistakes or forget to do something. For example, to enter some values into the help. That's why I'm going to try to go in through the "backdoor" now and I'll report on the cuts a bit later.

It's these inaccuracies that I want to get away from. And with as little blood as possible. :)

I'm afraid that even with a lot of blood I can't get away from these inaccuracies. There is no way to get a quote at a certain time in the past using mql4.
 
Renat Akhtyamov:

he needs a function.

however, he will not find a timeless function by the definition of the position commission either

philosophy like this...

No, I don't need any such thing, at least if you mean the definition of position commission. Let me simplify the question:

How do you calculate the margin of one(!), placed 1000 pips back order (from the market), purely on gold using the formula:

(Lots*ContractSize*OrderOpenPrice*Percentage)/Leverage

when Percentage remains unknown?

 
K-2SO:

No, I don't need any of that, at least not if you mean the definition of the position commission. Let me simplify the question:

How do you calculate the margin of one(!), placed 1000 pips back order (from the market), purely on gold using the formula:

(Lots*ContractSize*OrderOpenPrice*Percentage)/Leverage

whenPercentage remains unknown?

of course this parameter in the formula is unnecessary

and change Lots to OrderLots()

 
Renat Akhtyamov:
Of course, this parameter is not needed in the formula, because we are looking for it.


This is the formula to calculate the margin for the placed order - this is what we're looking for. I'm looking for it )

From the documentation of the leveraged CFD calculations:

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

 
K-2SO:


This is the formula to calculate the margin for the placed order - this is what we're looking for... I'm looking for )

From the documentation of the leveraged CFD calculations:

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

Change Lots to OrderLots() ,
Change MarketPrice to OrderOpenPrice()

Leverage on AccountLeverage()

Change Percentage to 100 if you like.

 
Renat Akhtyamov:

Change Lots to OrderLots() ,
Change MarketPrice to MarketInfo("COLD",MODE_BID) ( or MODE_ASK)

Leverage to AccountLeverage()

Thanks, but it's kind of obvious. What to do with Percentage, why it's not necessary when its value can be from 1 to 100 and the necessity of taking this parameter into account is specified in the documentation?
 
K-2SO:
Thanks, but it's kind of obvious. What about Percentage, why isn't it needed when its value can be from 1 to 100 and the need to take it into account is stated in the documentation?

I corrected the post...

If you already have an order open and need a deposit for it, forget about the percentage. It will be 100

 
Renat Akhtyamov:

I tweaked the post...

if you already have an order open and need a margin on it, forget about the percentage

That's it, I'll check it out. At the moment, regarding the need for a "margin percentage" value - that's all I was interested in. Thanks!

p.s. I just wish I could find brokers with different percentages of "margin percentage"...

 
K-2SO:

That's it, I'll check it out. At the moment, regarding the need for a "margin percentage" value - that's all I was interested in. Thank you!

p.s. I just wish I could find brokers with different "margin percentage" values...

is 100, as leverage is taken into account
Reason: