fxDreema

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

    Check if last closed position was stop loss

    Questions & Answers
    2
    11
    2138
    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.
    • M
      Marc last edited by

      Hi,

      I'm trying to check if last closed position was stop loss, and if positive do something. I already tried a lot of pink blocks composition but none of them did work. I've been started with "for each closed position" block and after that "check how it was closed" block, but with no success. I think that I just can't understand how the pink blocks works.

      Thanks for your help,
      Marc

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

        What project is this? For "For each closed position" you also need to specify how many positions to loop. By default this is 10, but in your case this needs to be 1.

        Many people have problems understanding these blocks, but it's not hard at all. Every "For each... " block checks how many... let's say orders there are, then for each one of them causes the next blocks connected to it to run. A little bit of imagination is needed.

        1 Reply Last reply Reply Quote 0
        • M
          Marc last edited by

          Hi fxdreema,

          Thanks for your response. The project is Teste1. I put "print message" just to know if it is working. Actually I want to know if last position was stopped and if yes I change the flow of blocks (if it say buy, I sell)

          Marc

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

            Having nothing here is incorrect in any case. I'm not sure if this means 0 and the block does nothing at all (this will be the better behaviour) or it runs through a;; history positions. Imagine if you have 500 closed positions in the history and checking them all for something on each tick...

            In MT5 you can have 1 position per symbol. If a running position is stopped, then you just end up with no running position. You are actually using "No position is running" in this project, so I think I don't understand what you want to do

            1 Reply Last reply Reply Quote 0
            • M
              Marc last edited by

              This is the logic:

              1. If there are no position (block 9 is true) and the last price (close) is above the open price, it opens a position (block 6)
              2. If position is running (block 9 is false) and the price goes below the open price, it close the position (block 14),
              3. after that no position is running and it opens another position (block 4)

              But if the bar opens up and the market continues goes up on item 2), the position will be stopped and after that will be open an another position at the same direction (block 6). in this case (trade was stopped), what I want is to open a position in another direction (block 4).

              If you check the Teste1 again I just changed the project to what I supposed to work. But it didn't work.

              PS: I'm sorry if I can't make my self clear, but English is not my native language.

              Marc

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

                For some reason my post is broken, I don't know why 😮

                Anyway. I think you want to do it in this model:

                No Buy => Condition to Buy => Close positions => Buy
                No Sell => Condition to Sell => Close positions => Sell

                These are 2 chains of blocks, almost the same, but one of them is for buys and the other is for sells.

                Now from what I see you open a new position and on the very next moment it will be closed because of the opposite condition. I didn't checked it, but I'm pretty sure that this is the case.

                1 Reply Last reply Reply Quote 0
                • M
                  Marc last edited by

                  Yes, is almost it:

                  No position => condition to buy => buy => condition to close buy => close buy
                  No position => condition to sell => sell => condition to close sell => close sell

                  But if the last closed position was "stop loss", then:

                  No position => condition to buy => sell => condition to close buy => close sell
                  No position => condition to sell => buy => condition to close sell => close buy

                  and yes, it open a new position and probably close a few minutes later.

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

                    No, no... it's not "No position" with all default settings, it's "No position" that is set to work only with Buys, and another blocks like this set to work for Sells.

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

                      This is my idea:
                      https://fxdreema.com/demo/mt4-buy-sell- ... conditions
                      http://prntscr.com/86a6c2

                      1 Reply Last reply Reply Quote 0
                      • M
                        Marc last edited by

                        Actually, is like the attached file.

                        ......
                        EA_OpenUpSell.PNG

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

                          Now this is what happens and is wrong or this is how it should be?

                          Note that I am not sure what you really want and I'm guessing, that's why I'm proposing what I think you want to achieve 🙂

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

                          Online Users

                          V
                          O
                          J
                          B

                          19
                          Online

                          146.7k
                          Users

                          22.4k
                          Topics

                          122.6k
                          Posts

                          Powered by NodeBB Forums | Contributors