fxDreema

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

    check free-margin before placing order

    Questions & Answers
    4
    17
    1030
    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.
    • K
      kalifx last edited by kalifx

      I suspect that the buy/sell pending order block is missing the check free-margin function before placing order. otherwise it think the block should print a message like "not enough money"

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

        Add blocks to give you this information.

        Learn fxDreema Without the Wait!

        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

        Don’t miss out

        Click here➡️ https://mybook.to/fxDreema to get your copy today!

        Enjoy! 😊

        1 Reply Last reply Reply Quote 0
        • S
          s00071609 last edited by

          Hi, I was trying to calculate how much lot can the Free Margin can buy but having bit of issue. I want this formula to work in all instrument, FX, indices etc which have different lot sizes. This formula is part of total Open SL calculation for different purpose, but i am trying to use that to get total lot margin can buy,

          For 50 lots, its giving 0.50 lot. Something is missing that I am not able to determine. Any advice would be great

          image.png

          S 1 Reply Last reply Reply Quote 0
          • jstap
            jstap last edited by

            I see what you mean, the message in the journal tab. This will show it, add this GetLastError() to text code input in a comment

            Learn fxDreema Without the Wait!

            My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

            The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

            Don’t miss out

            Click here➡️ https://mybook.to/fxDreema to get your copy today!

            Enjoy! 😊

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

              It is possible that the developer of the buy/sell pending order block simply overlooked the need to check for free margin before placing an order. Also, the developer may have assumed that the user would always have sufficient margin to place an order and therefore did not include a check. If you have access to the source code for the block, check if it includes a function to check free margin before placing an order. If necessary, you can modify the block yourself to include a free margin check. This will require some coding knowledge.

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

                I don't think he saw the need, if you do not have enough it won't trade

                Learn fxDreema Without the Wait!

                My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                Don’t miss out

                Click here➡️ https://mybook.to/fxDreema to get your copy today!

                Enjoy! 😊

                1 Reply Last reply Reply Quote 0
                • S
                  s00071609 @s00071609 last edited by

                  @s00071609 This isn't giving any error. I am a bit confused about the calculation. THe margin_Available is a variable that contains margin available as asigned variabile. The above formula for Max_lot_margin is giving me 1/10th of the correct size.

                  I am sure its a small fix thats needed. Any suggestion would be really helpful.

                  thanks

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

                    Add a shard link to look at.

                    Learn fxDreema Without the Wait!

                    My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                    The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                    Don’t miss out

                    Click here➡️ https://mybook.to/fxDreema to get your copy today!

                    Enjoy! 😊

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      s00071609 @jstap last edited by s00071609

                      @jstap Here is the link - its one of your buy button project + another project + some of my customization, so it can look messy. The purpose is to have x% of open position based on SL distance of all open position - this is working correctly.

                      What is not working is the margin part. Lets say I am at 120% available margin percent, when I hit the buy button, it should never go under 100% margin. So the position size being calculated should consider all Open risk (1%), margin (>100%), and (Position SIze always<max lot size).

                      Sometimes what we are trying to do does not make sense to others so, let me explain why:

                      With lot of prop firms collapsing, they are resorting to checking how much margin you are using and many have max lot size limit - so if you are under 100% margin, they can flag you as gambler and deny you payout. If you go over Max Lot- you are breached. So this EA keeps the open risk constant, takes care of max lot limit, and margin utilization no matter how many positions are opened.

                      https://fxdreema.com/shared/Pu2CnDDzc

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

                        Does this c::MaxOpenRisk work in mql4 language? Under a if testing block I would copy from on chart so I could backtest all. Tell me what blocks are not doing what you want

                        Learn fxDreema Without the Wait!

                        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                        Don’t miss out

                        Click here➡️ https://mybook.to/fxDreema to get your copy today!

                        Enjoy! 😊

                        S 2 Replies Last reply Reply Quote 0
                        • S
                          s00071609 @jstap last edited by

                          @jstap I am not sure about mq4, i never use it. It works in mq5. The logic of the whole thing is working fine, all blocks work. The only issue is the calculation in custom block:

                          double tickvalue = SymbolInfoDouble(tradesymbol,SYMBOL_TRADE_TICK_VALUE);
                          double digitF = MathPow(10,SymbolInfoInteger(tradesymbol, SYMBOL_DIGITS));
                          Max_lot_margin =Margin_Available*tickvalue/(ask_price*digitF);
                          

                          It does not throw error but the calcuation is missing something, it gives 1/10th of position. If this is fixed, i think it will work. At least there is no major problem that i am aware of.

                          The onchart section does not have much, its all your code + condition check that uses values from ontick.

                          This is a new shared link - https://fxdreema.com/shared/rwg1G2uNd

                          This is working correctly i think. I have isolated the bocks that calculates margin. Blocks 302 and 303, there are giving wrong values.
                          https://fxdreema.com/shared/rwg1G2uNd

                          1 Reply Last reply Reply Quote 0
                          • S
                            s00071609 @jstap last edited by s00071609

                            @jstap This is from the chart. It won't exceed max risk defined, also will not exceed max lot defined, it auto sets the SL to Low of H [1] and based on this the lots to be opened are calculated. There is also a min size that can be opened to avoid 0.01 type positions.

                            If buy button is presses now, it will do nothing as max parameters are met by open positions.

                            d98fb8eb-d06e-452c-b5b2-d1d39e3227ee-image.png

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

                              C:: is used in something like AutoHotkey scripting language, so probably better to delete that. In 302 delete the type, create in the variable list, then put variable into a comment and check it you are getting the relevant value

                              Learn fxDreema Without the Wait!

                              My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                              The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                              Don’t miss out

                              Click here➡️ https://mybook.to/fxDreema to get your copy today!

                              Enjoy! 😊

                              S 2 Replies Last reply Reply Quote 0
                              • S
                                s00071609 @jstap last edited by

                                @jstap Actually C:: is not something I typed (*c::MaxOpenRisk). When I want to multiply a value with a variable - this gets created. For example, *Variable Select in adjust field. Then C:: gets created itself by fxdreema. I have used this in lot of projects and this does not cause any issue, works like normal calculation.

                                I will try the suggestion you have given

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

                                  Interesting, has never happened to me, maybe this is an MT5 thing, if it works it is all good

                                  Learn fxDreema Without the Wait!

                                  My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                                  The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                                  Don’t miss out

                                  Click here➡️ https://mybook.to/fxDreema to get your copy today!

                                  Enjoy! 😊

                                  1 Reply Last reply Reply Quote 0
                                  • S
                                    s00071609 @jstap last edited by

                                    @jstap I think the problem is that I don't have the value for Symbol Leverage. Different symbols and broker have different leverage. I can't find any function to get value for leverage for symbol. It does have leverage function but not symbol specific. May be it also needs a custom block

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

                                      I am unsure how you would get a specific symbol leverage

                                      Learn fxDreema Without the Wait!

                                      My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                                      The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                                      Don’t miss out

                                      Click here➡️ https://mybook.to/fxDreema to get your copy today!

                                      Enjoy! 😊

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

                                      Online Users

                                      A
                                      F

                                      9
                                      Online

                                      146.7k
                                      Users

                                      22.4k
                                      Topics

                                      122.6k
                                      Posts

                                      Powered by NodeBB Forums | Contributors