fxDreema

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

    Delete pending orders issue

    Questions & Answers
    4
    9
    3325
    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.
    • A
      Adminasde @rafaelgrecco last edited by

      @rafaelgrecco
      Please make a sample file and share with us.

      1 Reply Last reply Reply Quote 0
      • C
        cfabian last edited by

        Hi,
        I've been experiencing an issue with closing pending orders after open trades hit SL or basket of trades close due BE.

        I have connected the delete pending orders AFTER the trailing money loss block, but the problem I encounter is that it always passes, causing all pending trades to delete right after openning. My guess is that this block should pass ONLY AFTER it closes the trades it is managing. But as it is not, now I can't find the way to delete pending orders right after trades in its group are closed?

        Can you please help?

        Many thanks

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

          Delete pending orders is not supposed to always delete pending orders. I mean, it deletes them if there are orders to be deleted and it always passes, so other similar blocks can be connected below this one. Blue blocks like this one behave like this - they are there, they do what they are supposed to do if there is need to, otherwise they don't break the flow for other blocks.

          This is how it works from the beginning. I did it like this for whatever reason, but now I can't change this behaviour only because one person wants it. If I do that, the projects of other people may break and they will not know it, because they don't expect it.

          1 Reply Last reply Reply Quote 0
          • C
            cfabian last edited by

            __Delete pending orders is not supposed to always delete pending orders. I mean, it deletes them if there are orders to be deleted and it always passes, so other similar blocks can be connected below this one. Blue blocks like this one behave like this - they are there, they do what they are supposed to do if there is need to, otherwise they don't break the flow for other blocks.

            This is how it works from the beginning. I did it like this for whatever reason, but now I can't change this behaviour only because one person wants it. If I do that, the projects of other people may break and they will not know it, because they don't expect it.[/quote:3icssz49]

            I'm not expecting you to change this behaviour... I want to find a way to delete pending orders of a group of trades when trailing stops or SL close active trades.

            I also tried using "check type last closed" so that if is a valid condition it deletes buys, otherwise deletes sells, but is not working either as it keeps closing those pending orders in the last direction, no matter are new trades, and no matter I use "pass once per trade".

            So, how can I build such condition? Please help as undeleted pending orders at the right time are killing me.

            Also want to ask how offset price for pending buys and sells work in terms of negative and positive input? If current price is 50, and I use -5 as offset price, will this mean that for buys it will place at 45, and for sells at 55? Or sells at 45 as well?

            Thanks for your help

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

              Maybe "on Trade" event.

              For sells it works in the opposite way. 5 pips offset actually means -5 pips on the chart.

              1 Reply Last reply Reply Quote 0
              • C
                cfabian last edited by

                __Maybe "on Trade" event.

                For sells it works in the opposite way. 5 pips offset actually means -5 pips on the chart.[/quote:34f75s41]

                I don't get how "on trade" can help to delete pending orders after active trades are closed. Can you please be more specific?

                Ok, so for offset if want to put a pending order BELOW current price I have to use opposite sign to the direction of the trade, is this correct? Using negative for sells will move the entry further down passed current price.

                Thanks

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

                  I wrote these things times and times before, but I will wrote them here again. There are few ways to do something:

                  • In "on Tick". In "on Tick" if you use blocks to check something, you check the current state. This is the best way to do things. You check how many trades there are, how many orders there are and stuff like that. Even if the EA is restarted, everything is still valid, because you check the current state. No trades? - Delete orders. No orders? - Delete trades. No problem at all.

                  • In "on Trade". In "on Trade" you detect events. The event when a trade/order is opened/closed/modified. This is not a state, but an event. A trade is closed? - Do something when that happens. This is how things work here. The downside is that if the EA is down for some time, when it's up again, it would miss some events.

                  Of course, if you don't like how blue blocks work, there are pink blocks and with them you can do almost everything. The downside is that each of them does something small and you will need many of them. Here is how Trailing Stop is done with them - https://fxdreema.com/demo/mt4-loop-trailing-stop

                  For buys and sells... try it! It does not hurt and you will see the result much, much faster than if you wait for me to respond. Pending orders are opened at the open price that is defined. Below or above the current price - it doesn't matter. The specific for "Price offset" in "Sell pending order" is that it works in the opposite way compared to "Buy pending order". Positive offset = direction down. Negative offset = direction up.

                  1 Reply Last reply Reply Quote 0
                  • C
                    cfabian last edited by

                    __I wrote these things times and times before, but I will wrote them here again. There are few ways to do something:

                    • In "on Tick". In "on Tick" if you use blocks to check something, you check the current state. This is the best way to do things. You check how many trades there are, how many orders there are and stuff like that. Even if the EA is restarted, everything is still valid, because you check the current state. No trades? - Delete orders. No orders? - Delete trades. No problem at all.

                    • In "on Trade". In "on Trade" you detect events. The event when a trade/order is opened/closed/modified. This is not a state, but an event. A trade is closed? - Do something when that happens. This is how things work here. The downside is that if the EA is down for some time, when it's up again, it would miss some events.

                    Of course, if you don't like how blue blocks work, there are pink blocks and with them you can do almost everything. The downside is that each of them does something small and you will need many of them. Here is how Trailing Stop is done with them - https://fxdreema.com/demo/mt4-loop-trailing-stop

                    For buys and sells... try it! It does not hurt and you will see the result much, much faster than if you wait for me to respond. Pending orders are opened at the open price that is defined. Below or above the current price - it doesn't matter. The specific for "Price offset" in "Sell pending order" is that it works in the opposite way compared to "Buy pending order". Positive offset = direction down. Negative offset = direction up.[/quote:3it1vdkc]

                    But in "on tick" if I check current state of trades, and none pending order is active yet (hasn't been hit), this will pass as there is no trade active and close right away the pending orders. Same thing will happen if use "no trade". So the thing is detecting a recently closed trade to make it pass. Would like to know your opinion on this.

                    Will experiment with "on trade", but don't like the downside you mention in case the EA goes down for a moment.

                    Thanks

                    1 Reply Last reply Reply Quote 0
                    • R
                      rafaelgrecco last edited by

                      What I like to do is use Variables to control stuff like this.

                      Create a Variable "STOPLOSS" with value "0".

                      Then you use pink blocks "For Each Closed Position" -> "Check How it Was Closed" and then the gray block "Modify Variables" to change your variable to "1".

                      So when a trade is closed as a Stop Loss, your Variable "STOPLOSS" that was "0" is now "1". This is your Flag.

                      Then you can have another set of blocks like a simple "Pass" -> "Condition" -> "Delete pending orders", where you check if you variable "STOPLOSS" is "1", if it is, your pending orders are deleted. Then you connect another "Modify Variable" after "Delete pending orders" to change your "STOPLOSS" back to "0", so you reset your logic.

                      It sounds kind of complicated, but after you get the hang of if, you can do a LOT of stuff using this strategy. Here is a quick example:

                      https://fxdreema.com/shared/2vqEYLMte

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

                      Online Users

                      H
                      B
                      K
                      A
                      S

                      17
                      Online

                      146.7k
                      Users

                      22.4k
                      Topics

                      122.6k
                      Posts

                      Powered by NodeBB Forums | Contributors