Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid leverage/margin calculation #44

Closed
imphocused opened this issue Jun 26, 2022 · 4 comments
Closed

Invalid leverage/margin calculation #44

imphocused opened this issue Jun 26, 2022 · 4 comments

Comments

@imphocused
Copy link

imphocused commented Jun 26, 2022

Screen Shot 2022-06-25 at 10 11 04 PM

Is it possible to adjust how the leverage is calculated? On this broker (Dominion Markets, MT5) the calculations for crypto are off.

Screen Shot 2022-06-25 at 10 18 24 PM

@EarnForex
Copy link
Owner

Hello imphocused!

The problem here is that the symbol's calculation mode is reported as SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE, while in reality it looks more like SYMBOL_CALC_MODE_CFD is used.

In SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE, margin is calculated as Lots * Contract_Size * Margin_Rate. The price of the symbol isn't taken into account or is taken care of by the Margin_Rate (reported by the broker's server).

In SYMBOL_CALC_MODE_CFD, margin is calculated as Lots * ContractSize * MarketPrice * Margin_Rate. This would yield a correct result here.

So, the broker should either fix the reported SYMBOL_TRADE_CALC_MODE or Margin_Rate on its server.

@imphocused
Copy link
Author

Hello,

Thank you for taking a look. I appreciate the feedback. I've relayed this to the broker support team, and even with screenshots there is some confusion on what I was talking about, so they may not be able/willing to resolve.

In any case, to help me better understand, I may be confused about the specification calculation. You mentioned:

"In SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE, margin is calculated as Lots * Contract_Size * Margin_Rate. The price of the symbol isn't taken into account or is taken care of by the Margin_Rate (reported by the broker's server)."

On the MT5 page:

Forex:
The margin for the Forex instruments is calculated by the following formula:
Volume in lots * Contract size / Leverage

Forex No Leverage:
This type of calculation is also used for Forex symbols. But unlike the previous one, it does not take into account the trader's leverage:
Volume in lots * Contract size

If the script is detecting the symbol as 'No Leverage', then by default shouldn't the leverage be displayed as (1:1), instead of (1:<current ask price>)? In the original screenshot, the ask price of BTC at the time was 21362.300

ea-output

@EarnForex
Copy link
Owner

Hello!

Here is what the MQL5 help file says about SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE:
Screenshot 2022-06-30 154035

And indeed, if you open a trade of 1 lot, then you'll see that it takes 1/10 of margin, which is consistent with 0.1 Margin Rate application.

So, in reality, even though it says "Forex No Leverage", it would be 1:10 real leverage.

@EarnForex
Copy link
Owner

Doesn't look like a Position Sizer issue at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants