fxDreema

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

    Close each trade if certain conditions?

    Questions & Answers
    4
    12
    5099
    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.
    • B
      BlueMoon last edited by

      On every tick, I want to check every open trade and close it if it has Loss of 100 pips or if it has profit of 50 pips.

      What is the best/quickest way to do this?

      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • B
        BlueMoon last edited by

        I also would like to open a new trade in this loop when it closes due to Loss with twice the lot of the closed trade (opposite trade, if closed trade was Buy then open Sell, if closed trade was Sell then open Buy trade)

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

          Hi @yalgaar

          I think that the easiest way is to set for each position a TP = 50 and SL = 100. Like this

          0_1523299151656_0130ff91-1523-49ee-99fe-cb0f6b1f18b7-image.png

          Or by using a constant to allow those values can be modified.

          Regards

          1 Reply Last reply Reply Quote 0
          • B
            BlueMoon last edited by BlueMoon

            Thanks for your reply but I really do not want to set this. I want the EA to do this when the TP or SL is reached.

            The SL and TP should be hidden from the broker.

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

              So for that case you could use the "Condition Block". Like this

              0_1523306340103_47479d60-d27a-40ac-b2df-dac51d53d375-image.png

              Regards

              L 1 Reply Last reply Reply Quote 0
              • B
                BlueMoon last edited by

                Thanks. That's what I was looking for. I was not aware you had "Trade/Order Loop" options in Condition block!
                This is sweet!

                1 Reply Last reply Reply Quote 0
                • B
                  BlueMoon last edited by

                  Is your "Close Position" block same as "Close Trades" block?

                  I that case, how should I set it? I want it to close only the trades that meet the condition.

                  1 Reply Last reply Reply Quote 0
                  • B
                    BlueMoon last edited by

                    The blue "Close Trades" block has no idea about the loop of trades...so this will not work. It will close all open Trades with its own filter conditions. Unfortunately it does not have the conditions I need.

                    I am thinking the Pink "Close" block might help. I am not sure I will have to test this. Let me know your thoughts?

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

                      "Close Position" block is MQL5 and it is equal to "Close Trades" MQL4 block.

                      I am pretty sure that a better way exists to do it but this is how it might be work.

                      • Set a Group# for each position to be opened

                      0_1523309448446_c5572a75-1173-494b-a13f-3157ba234a8b-image.png

                      • Each position should have 2 condition blocks in order to close the position if one of them is met.

                      0_1523309896674_6f0ec20c-3a34-4730-b22c-da051cb0562f-image.png

                      You can copy those blocks for each position.

                      The goal can be achieved with different ways in fxDreema.

                      Hope this helps you.

                      Regards

                      1 Reply Last reply Reply Quote 0
                      • B
                        BlueMoon last edited by

                        I appreciate all your help but this is still not helping me.

                        I do not have control over how and when the trades are taken. So I am unable to set the Group numbers.

                        I just want a loop that will go over every single open trade ( these trades may or may not be opened by me or my EA) and check its current profit/loss. If loss is over 100pips then close it and open another position with 2 times the lots in opposite direction......if profit is over 50pip, then just close that trade.

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

                          Maybe something like this works... Try measuring the profit and loss with the Check distance block. So you will need two blocks of those, both in a loop that goes through all trades.
                          0_1523372688747_c794ca75-8095-4ee5-adf6-00d1b8d1f588-image.png

                          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
                          • L
                            len 1 @josecortesllobat last edited by

                            @josecortesllobat @l-andorrĂ  Hi Jose, thank you, but I was wondering if this was good by itself,... or does this (the Condition for TP or Condition for SL) go under a purple For each position or For each Trade Block? Please advise

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

                            Online Users

                            S
                            M
                            2
                            M
                            M
                            N
                            B
                            A
                            B
                            S
                            E

                            38
                            Online

                            146.6k
                            Users

                            22.4k
                            Topics

                            122.6k
                            Posts

                            Powered by NodeBB Forums | Contributors