Close pending order before midnight and Reopen it after Midnight
-
Hello guys,
I am trying to create blocks that will auto delete pending order before midnight (to avoid been in a trade with large spread) and reopen it at a certain time after midnight. See shared link
https://fxdreema.com/shared/f4aiDB1cdThe challenge for me now is when I use the once per trade/order block, it reopens deleted pending order just once and once forever. if for example the blocks on the left is true 2days later, the blocks on the right does not re-open the pending order.
How do I arrange the blocks on the right such that each time a pending order is closed before midnight, it reopens it after midnight, every time and not just one-off.
Thanks
-

this might work
Logic says pending order or not,
between the hours of: 2330 to 0030 server time
Delete pending orders and turn off your buy and sell blocks, else (2330-0030) turn on buy and sell blocks.You will need to fill in the blocks yourself. This is MT5, I dont do MT4.
-
@didymario7 Do you need they to be reopened at the exact same price level? If so you will need variables to store that info.
-
quick question, whats the theory and purpose of turning them off?
-
@tipsywisdom said in Close pending order before midnight and Reopen it after Midnight:

this might work
Logic says pending order or not,
between the hours of: 2330 to 0030 server time
Delete pending orders and turn off your buy and sell blocks, else (2330-0030) turn on buy and sell blocks.You will need to fill in the blocks yourself. This is MT5, I dont do MT4.
This was helpful. I used a variation of this to get it to work. The key was the turn on/off block.
Thanks -
@l-andorrà this brings me to another question i have been battling with.. Lets say i have closed 3 previously opened pending orders..How do I
- Save the open price of each of the closed pending orders in 3 variables.
2.how do I place a pending order to reopen each of the 3 closed pending orders 2 hours or a day later.
Example blocks will be helpful.
Thanks
- Save the open price of each of the closed pending orders in 3 variables.
-
@tipsywisdom said in Close pending order before midnight and Reopen it after Midnight:
quick question, whats the theory and purpose of turning them off?
Some times at exactly midnight spread become very high. I close pending orders before midnight and reopen them after midnight when the spread normlises to avoid triggering a trade due to very high spread.
-
@didymario7 exactly what I though. Id suggest going simple with a spread filter. But glad that other iteration works as well
-
@tipsywisdom said in Close pending order before midnight and Reopen it after Midnight:

this might work
Logic says pending order or not,
between the hours of: 2330 to 0030 server time
Delete pending orders and turn off your buy and sell blocks, else (2330-0030) turn on buy and sell blocks.You will need to fill in the blocks yourself.
Lets say i have closed 3 previously opened pending orders..How do I
Save the open price of each of the closed pending orders in 3 variables.
2.how do I place a pending order to reopen each of the 3 closed pending orders 2 hours or a day later.
Example blocks will be helpful.Thanks
-
i wouldnt suggest that, i would opt back to looking for your conditions to be true again because you never know what has happened to the market in that time. Thats why I'd also suggest a spread filter. In general a spread filter is a good rule of thumb to have one. i.e., using the spread filter in place of a time filter to turn off and on blocks if thats the better way.
but as far as doing it either way, ill see if one of my group have a solution built for that.
-
@didymario7 For question 1 you can create three variables, one for each closing order and simply store the value of all closed ones via 'on trade' tab. No matter how many are closed, you'll only the get the last ones. Once hose values are stored you can reopen themwhen you want buy using time filter blocks.
-
@l-andorrà please help me with example blocks. Thanks
-
or simply check at a certain time like 23:30 which open order you have
in a first step increase the sl (double)
second step open counter positions with a group id
third step at 01:00 for example close the counter orders (close all with selected group id)
fourth step return the sl to the original value -
@bk7 said in Close pending order before midnight and Reopen it after Midnight:
or simply check at a certain time like 23:30 which open order you have
in a first step increase the sl (double)
second step open counter positions with a group id
third step at 01:00 for example close the counter orders (close all with selected group id)
fourth step return the sl to the original valueCould you please create sample blocks to illustrate this? Would be very helpful.
Thanks
-
@didymario7 the next 2 days i am super busy and hardly have time, if nobody helped you by then please send me a quick reminder in 3 days, if i forgot to make a quick draft
-
@bk7 OK, Thanks
-
@bk7 I agree this is a more effective and easier solution than mine.
-
@didymario7
i just reread the whole task and i saw it is about pending orders so the solution is even a bit easier. I recommend that you move the order away by a certain number of pips before 23:30 and move it back at a certain time like 00:25 or whichever time you choose. I recommend using a timespan and run once (23:25-23:30) because if there are no ticks at a certain time it can't run. You can also make it run at a fixed time (23:30) if that is super important for you.here is a sample for buys:
-
his largest worry is spread as he said, simplest solution would be to use a spread filter.
I wonder if you are keeping yourself out of winning trades by cutting out a portion of time.
-
Thanks guys, I really appreciate your input.