fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    How to calculate buy volume based on balance and stock price ?

    Questions & Answers
    3
    5
    1363
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fabiovilan last edited by fabiovilan

      I´m writing a EA that will work on stocks (not forex/pips) and suppose I want to buy/sell 100% of balance

      In the MT5 strategy test I set a initial deposit of 100.000 (BRL).
      Suppose the stock is at 19.20 price. So the first trade (buy)
      100.000 / 19.20 = 5208,33

      I have to buy/sell multiple of 100, so it would be 5200.

      How can I code this in the BUY option to match this exact volume dynamically ?

      Thanks

      1 Reply Last reply Reply Quote 0
      • J
        josecortesllobat last edited by

        I think you Will have to use a "Custom MQL Code" block with the next math function

        https://www.mql5.com/es/docs/math/mathround

        1 Reply Last reply Reply Quote 0
        • F
          fabiovilan last edited by

          But even ignoring the way to round the number, is there any BUY option that will give me the 100.000 / 19.20 = 5208,33 ? Tried many options but found none, seems to me that every option is designed for forex, always ignoring the price of the stock. Or am I missing something?

          1 Reply Last reply Reply Quote 0
          • F
            fabiovilan last edited by

            anyone ?

            M 1 Reply Last reply Reply Quote 0
            • M
              moreirajbn @fabiovilan last edited by

              @fabiovilan

              0_1531171437631_Screen Shot 2018-07-09 at 23.23.36.png

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              Online Users

              M
              A
              E

              12
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors