Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us
Home/ Questions/Q 4083
Next
In Process
user_mt5
user_mt5

user_mt5

  • 4 Questions
  • 7 Answers
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
user_mt5
Asked: December 26, 20202020-12-26T14:08:53+00:00 2020-12-26T14:08:53+00:00In: Forex Expert Advisors

How to correctly calculate the cost of an order with a volume of 1 lot?

  • 0

void OnStart()
   {  
   double calc_margin;  // Cost of 1 lot BUY
double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);  
   OrderCalcMargin(ORDER_TYPE_BUY, _Symbol, 1.0, ask, calc_margin);
   Print("Order value of 1 lot=", calc_margin);
   }
Here is a simple script.
On currencies calculates correctly. For example, by Eurodoll = 1171.02.
And on indexes-wrong. In particular, on CAC40 (Alpari) issues 640.73. But if you open an order, the margin is 1941.97.

Please tell me: what am I doing wrong?

  • 5 5 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    5 Answers

    • Voted
    • Oldest
    • Recent
    1. user_mt5

      user_mt5

      • 4 Questions
      • 7 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      user_mt5
      2020-12-26T14:09:26+00:00Added an answer on December 26, 2020 at 2:09 pm

      Stanislav Korotky:

      What do the SymbolInfoInteger(_Symbol, SYMBOL_TRADE_CALC_MODE) and SymbolInfoMarginRate functions return for your case? And SymbolInfoDouble(_Symbol, SYMBOL_TRADE_LIQUIDITY_RATE)?

      I need to think about all this, experiment.

      In General, it is difficult to perceive. For example, ” SYMBOL_TRADE_LIQUIDITY_RATE”

      Liquidity ratio – the share of the value of an asset that can be used as collateral.

      There are a lot of questions: what is this coefficient, why, for what and how it is necessary to use it, where does this share come from, and why in principle it is different. Etc.

      I experimented with the shoulder in a well-known firm A. the value of the lot on currencies changes in proportion to the shoulder (well, at least this). And on the indices, it grows proportionally to 1: 50, with a further increase in the leverage, it does not change. And at the same time, the broker can arbitrarily change the leverage. Well. And where to subtract these exotic formulas? What kind of rackets are there?.

      Your train of thought is clear to me. But I don’t quite agree. I still think that there are no obstacles to making a few simple functions: the cost of an order of 1 lot (so that the programmer does not calculate it based on his, of course, erroneous ideas, and the platform responds to the function request), the cost of 1 point, the maximum allowable leverage for the symbol, etc.With this approach, the customer’s opinion is not required, this should be the basic norm of the platform. If a particular customer uses exotic methods of calculation, then the developer should release an application specifically for this customer to its server part (!) of the platform, in which the customer will be able to change their coefficients (3.03 and other nonsense) as he pleases. But for the trader, the user-programmer, the contact data set should be uniform, simple and understandable for all brokers for all symbols.

      It should have been..
      At least they would already give contextual links to examples. But no, I have to guess. A very mysterious language, this MQL..

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. marketeer

      marketeer

      • 1 Question
      • 33 Answers
      • 0 Best Answers
      • 92 Points
      View Profile
      marketeer
      2020-12-26T14:09:20+00:00Added an answer on December 26, 2020 at 2:09 pm

      User_mt5:

      Vladimir, thank you for your answer.

      I think the point here (as usual in such cases) is not in brokers and not in regulatory documents, but in the platform. After all, there are no obstacles to making a trader (programmer) a simple normal set of functions that characterize the broker’s trading conditions. But these functions are not fully implemented and not in all parameters. For example, to calculate the cost of 1 point, it was necessary to put a lot of effort, and as it turned out, this was not enough, because this parameter directly depends on the cost of the order, and that still depends on the will of the broker (coef. 3.03), which cannot be obtained programmatically..

      I do not know exactly, but in my opinion, this CIS firm A. is new Zealand, i.e. it should not be subject to European and American legislation. So, in theory, for some gifted people, nothing will change.

      But the question remains. Manually entering the coefficients into the program once is not a problem, although it is disgusting. The question is whether brokers are allowed to change these coefficients in the course of trading. And if so, I don’t even know..

      Thank you again.

      What do the SymbolInfoInteger(_Symbol, SYMBOL_TRADE_CALC_MODE) and SymbolInfoMarginRate functions return for your case? And SymbolInfoDouble(_Symbol, SYMBOL_TRADE_LIQUIDITY_RATE)?

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. vlad143

      vlad143

      • 0 Questions
      • 6 Answers
      • 0 Best Answers
      • 32 Points
      View Profile
      vlad143
      2020-12-26T14:09:15+00:00Added an answer on December 26, 2020 at 2:09 pm

      User_mt5:

      Vladimir, thank you for your answer.

      I think the point here (as usual in such cases) is not in brokers and not in regulatory documents, but in the platform. After all, there are no obstacles to making a trader (programmer) a simple normal set of functions that characterize the broker’s trading conditions. But these functions are not fully implemented and not in all parameters. For example, to calculate the cost of 1 point, it was necessary to put a lot of effort, and as it turned out, this was not enough, because this parameter directly depends on the cost of the order, and that still depends on the will of the broker (coef. 3.03), which cannot be obtained programmatically..

      I do not know exactly, but in my opinion, this CIS firm A. is new Zealand, i.e. it should not be subject to European and American legislation. So, in theory, for some gifted people, nothing will change.

      But the question remains. Manually entering the coefficients into the program once is not a problem, although it is disgusting. The question is whether brokers are allowed to change these coefficients in the course of trading. And if so, I don’t even know..

      Thank you again.

      In the process of trading, most DCS change their leverage, at least for the weekend,or even for the time of news. Also, the leverage may be different for cases when the client is Polish or non-Polish Manually, unfortunately, in Your case, you will need to organize the calculation in the terminal according to the rules of Your DC, and not just take into account the coefficients. I do not know how to “make a simple normal set of functions for a programmer that characterize the broker’s trading conditions” in MQL languages. This will be an analogue of trigger procedures in the DBMS, involving such funds in the turnover, edit (lead) which should DC, the task is not easy and at the technological level, and what will happen at the organizational level? DC, unlike traders, pay for the platform, that is, ultimately, they are the customer of the work performed by MQ. There are very few customers in the world who will readily take on a new amount of work to support margin calculation procedures in the terminal. Yes, and responsible support… Perhaps this is the reason for the lack of adequate margin assessment tools in the platform.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. user_mt5

      user_mt5

      • 4 Questions
      • 7 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      user_mt5
      2020-12-26T14:09:04+00:00Added an answer on December 26, 2020 at 2:09 pm

      Vladimir:

      1941.97/640.73 = 3.03087. We look at the specification of contracts for CAC40 there: “Collateral, % 3.03”. Matched if you have a nominal leverage of 1: 100.

      It’s not about indices/currencies, in this DC in General, the calculation of collateral is very complicated, see “How to calculate collateral with floating leverage depending on the nominal value of positions?” and “Margin requirements for ASX 200, CAC 40, HSI 50, NQ 100, STOXX 50, NG”.

      Vladimir, thank you very much.

      Turns out it’s even worse than I thought.
      Now it is clear that there is some stupid coef = 3.03.Multiply 640 by 3.03 my brain is enough.
      But tell me, please, is it possible to get this 3.03 programmatically? Or do these coefficients for all similar symbols need to be entered into the program manually?

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    5. vlad143

      vlad143

      • 0 Questions
      • 6 Answers
      • 0 Best Answers
      • 32 Points
      View Profile
      vlad143
      2020-12-26T14:08:59+00:00Added an answer on December 26, 2020 at 2:08 pm

      User_mt5:

      Here is a simple script.
      On currencies calculates correctly. For example, by Eurodoll = 1171.02.
      And on indexes-wrong. In particular, on CAC40 (Alpari) issues 640.73. But if you open an order, the margin is 1941.97.

      Please tell me: what am I doing wrong?

      1941.97/640.73 = 3.03087. We look at the specification of contracts for CAC40 there: “Collateral, % 3.03”. Matched if you have a nominal leverage of 1: 100.

      It’s not about indices/currencies, in this DC in General, the calculation of collateral is very complicated, see “How to calculate collateral with floating leverage depending on the nominal value of positions?” and “Margin requirements for ASX 200, CAC 40, HSI 50, NQ 100, STOXX 50, NG”.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 504
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 677
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Related Questions

    • Brus Agell

      Правельный выбор

      • 0 Answers
    • pinupcasinoo

      Pin Up Casino

      • 0 Answers
    • c00l777

      During optimization, indicators that are not present in the robot ...

      • 2 Answers
    • c00l777

      During optimization, indicators that are not present in the robot ...

      • 0 Answers
    • c00l777

      Optimization results differ on different accounts

      • 3 Answers

    Users

    HiramJanny

    HiramJanny

    • 0 Questions
    • 0 Answers
    Geraldimaky

    Geraldimaky

    • 0 Questions
    • 0 Answers
    Jeffreytix

    Jeffreytix

    • 0 Questions
    • 0 Answers

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved