fxDreema

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

    auto lot sizing issue

    Questions & Answers
    3
    8
    1425
    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.
    • W
      wolamen last edited by

      i want to use auto lot sizing like this :
      balance 1000 - 1999 lot 0.01
      balance 2000 - 2999 lot 0.02
      balance 3000 - 3999 lot 0.03

      i am already used " % of balance => lot 100% "
      and it gives me lot 0.01 on balance 1000 .. but when the balance exceed 1500 the lot becomes 0.02
      and when balance becomes 2500 the lot turns to 0.03
      but this is not what i want .. as i said .. i want the auto lot like that :

      balance 1000 - 1999 lot 0.01
      balance 2000 - 2999 lot 0.02
      balance 3000 - 3999 lot 0.03
      and so on ....

      any help ???

      1 Reply Last reply Reply Quote 0
      • roar
        roar last edited by

        Try putting this to your lot field:

        MathFloor(AccountBalance()/1000)*0.01

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        W 1 Reply Last reply Reply Quote 0
        • W
          wolamen @roar last edited by

          @roar said in auto lot sizing issue:

          MathFloor(AccountBalance()/1000)*0.01

          should i put this equation into lot field under " % of balance => lot 100% " ??

          roar 1 Reply Last reply Reply Quote 0
          • roar
            roar @wolamen last edited by

            @wolamen No, just "custom value"

            Need small help? Tag me in your post
            Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

            W 2 Replies Last reply Reply Quote 0
            • W
              wolamen @roar last edited by

              @roar it is worked .. great .. thanks

              1 Reply Last reply Reply Quote 0
              • W
                wolamen @roar last edited by

                @roar thanks for the last help .. now another issue
                how could i do the same with condition of take profit ?
                what i mean that :
                if balance is 1000$ so the TP is 10$
                but if the balance becomes 2000$ so the TP turns to 20$

                any help?

                roar 1 Reply Last reply Reply Quote 0
                • roar
                  roar @wolamen last edited by

                  @wolamen
                  Your lot size already grows linearly with balance, so couldn't you just use a fixed pip TP, like 10 pips?
                  Anyway, there is no fast way to use $ stops, you must calculate it with your lot size and TP pips. You should be able to do the math yourself, I'll help only with the "coding" part 😄

                  Need small help? Tag me in your post
                  Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                  1 Reply Last reply Reply Quote 0
                  • fxDreema
                    fxDreema last edited by

                    So there is something called lot step. For example, if the lot step is 0.01, you can open 0.01, 0.02, 0.03... lots. If the lot step is 0.1, you can open 0.1, 0.2, 0.3 and so on. Lot step is the difference between two possible lot sizes. If you try some middle value, for example 0.012345, it will give you an error. So the EA that is generated would always use possible values. If your balance is 2641 and the lot size is calculated as 0.02641, this value is then rounded to the nearest possible. I guess that I used MathRound(). But as roar wrote, you can always write your own function. Some functions that you can use are AccountBalance(), AccountEquity(), MathFloor(), MathCeil() and MarketInfo() if you want to get the lot step. Take a look at their description in the documentation for MQL4 in MetaEditor (Help -> MQL4 Reference)

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

                    Online Users

                    N
                    S
                    T
                    A
                    Y

                    18
                    Online

                    146.7k
                    Users

                    22.4k
                    Topics

                    122.6k
                    Posts

                    Powered by NodeBB Forums | Contributors