
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hats off to you, you almost got it right! At all three brokers previously reviewed with different margin percentages, the calculation for gold (for orders in one direction) is correct.
But the script still fails with exotics. I have stopped at fxcm broker. The percentage margin for gold is 70000, for conventional currency pairs is 130, the currency of margin seems to be USD. And nothing is counting correctly anywhere! (. I myself have been looking for the key to it for two days, and in fact as a result of this I am now looking for an answer to the question, how come that as a result of calculations of base currencies and their rates with quotes currencies, we get margin currency... Maybe it's this, or maybe it's the fact that this broker takes into account the percentage of margin even for normal currency pairs.
You can download the terminal here ru.files.fm/u/xfezz883#_ , unzip it, run the exe file, start the demo...
I opened a demo, even two, one has no gold, the other XAUUSD with the percentage of margin 70000 and the standard lot 1. And the reason is not correct calculation in the
experiment with these lines yourself.
If I get bored, maybe I'll experiment too.
Crosses are not a problem to calculate. You just need to take a quote that translates the currency of the margin into the currency of the deposit.
For example EURJPY price
If the deposit is in USD, you should use EURUSD. CADJPY should be calculated using USDCAD. Here we should see how to add the deposit currency to the margin currency, we shouldn't just enter it in the list.
The counter ones are not so difficult having MarketInfo(symbol, MODE_MARGINHEDGED). The only problem is to find the counter first, and then to decompose part of the counter and the rest fully...
In general, I see the only benefit of this article is that the trader knows in advance what margin will be taken when the pending order is activated and removes the pending order in time if there is not enough money. I once struggled with this when placing an EA on the market.
leverage 100
I opened a demo, even two, one has no gold, the other has XAUUSD with a margin percentage of 70000 and a standard lot of 1. And the reason for the incorrect calculation is
And then in normal currency pairs in the Forex calculation method, do you have to take percentage into account?
Well, that's what this whole topic is about... and I don't think there's a one-size-fits-all calculation.)
Why not? There is a link on the first page where the formulas are available. It can be broken down into several algorithms depending on how the calculation is done. What I suggested to experiment is fundamentally wrong, don't waste your time. You have to go the other way.
I tried these formulas on the FOREX calculation method, on the last broker nothing works correctly at all, not even for EURUSD.
How come it doesn't work? In my script, the formulas are from there and seem to work for forex and cfd. But futures and indices are calculated using different formulas and I haven't used them.
I gave you screenshots above of how they work...
Right. My script calculates margin for CFD and forex, and your screenshots are for futures, the formulas for which are on the same page.
Where did you get that conclusion from?^ ^

The way to calculate margin for XAUUSD, also Forex... there profit is futures, not the one we are trying to calculate.