Pending Order Adjust
-
Hi guys!
I want to create an strategy which after condition A is met, it will open a pending order in the Candle 1 Max.
In the next candle, in case of pending order was not triggered, I want to change it's entry price and stop loss level.
Just like this exemple:
https://fxdreema.com/shared/DSjb2mRBThis logic isn't working. The EA is not changing the pending order (or opening another with different price and stoplevel)
The "slide" block will not help due the need to change the stop loss level also.
Thank you!
-
What do you mean by 'Candle 1 Max'? Is it the previous closed bar's high?
-
@l-andorrà Hi!
Yes! Exactly .The same logic used by code. Candle 1= Previous.
-
@eklonsousa said in Pending Order Adjust:
@l-andorrà Hi!
Yes! Exactly .The same logic used by code. Candle 1= Previous.
And Max = Candle High. Sorry for this example. I'm using only buy to simplify the idea.
Thanks!
-
Blocks 1 and 9 are exactly the same. And blocks 6 and 9 are apparently duplicated. Could you please detail (including all MA contitions) step by step what do you exactly want? Just for buys, for example.
-
@l-andorrà Yes, sure.
In this shared example it was only to ilustrate the way i'm thinking on the logic. I didn't change the condition blocks. It's just to have an overview of the strategy.
The logic before open any pending order is working fine. I just need to change the pending order position.
Example: All the conditions for open a Buy Pending Order at Candle 1 High have been met. Then the EA will open a Buy Stop order at Candle 1 High. So far, everything is fine.
My issue is: If in the next candle we still get a pending order. I mean: The pending order was not triggered, AND the first of the two conditions is still valid, the EA should delete this pending order (that was open in previous candle, aka candle 1, and now the order is at high of the candle 2) and open another pending order at high of the candle 1 using the same "Buy Pending Order Block" . As the order wasn't triggered for the first candle, we can assume that the high of the next candle was lower than the max of the previous one and the entry price and stop level should be adapted to the previous candle.
And it keep changing until trigger the order or the first condition to open buy is no longer valid .I'm not sure if I make myself clear.
Thank you for your help!
-
I think I have a more precise idea of what you're asking for but I'm still a bit confused about that previous high condition. Could you please add a few screenshots showing what you want exactly?
-
@l-andorrà I'll try to show you:
We need two conditions to open the first pending order. But lets just call it as "condition 1" and "condition 2" .
IF condition 1 AND condition 2 is true, we'll open a buy stop order like this:

For buy, we'll need to ajust the pending order price only if we have lower highs.
Then, we've opened this Buy Stop, but it was not triggered AND one of the conditions to open it still valid. And we need to ajust like this:

Delete the first pending order as it was not triggered and open a new one related to previous candle. Always opening it at high of the previous candle.
In this case, the order was not triggered as well in the next candle:

And once more, the candle 0 (actual candle) didn't triggered the order. And we'll do the same: Verify if condition 1 is still valid, delete pending order without trigger and open a new order related to candle 1 (or previous ).

If the condition to buy is no longer valid, we will delete the pending order and starts it all over.
We'll look for the lower price to buy while the condition is valid. And the highest price to sell while the sell condition is valid.
-
Ok. Now it is much more clear. Thank you for the explanation. Now please confirm if this is correct:
-
There will be just one buy/sell pending order at any time (not two or more simultaneously).
-
Entry price and Stop loss will always be (for a buy) the high and low prices of candle 1 (not any other previous candle).
-
Yor custom indicator is a bit weird. I don't see whay the last screenshot is considered as a valid buy. As far as I can see there is no blue positive bar, but a very small red one. Are MA lines considered as a valid condition or is it the colored central bars?
-
-
Hi!
Let's point it:
1 - Correct. Just one order at any time.
2 - Correct.
3 - This case is just an example. I'm using the MACD histogram above zero and not the moving averages. You can ignore them for this case.. The arrow wasn't drawned correctly. Sorry bout that.Thank you for your time and help! I appreciate it!
-
Ok. Here you have a first step to begin with (buys only).
https://fxdreema.com/shared/Bn58PkwV
It's not tested nor complete yet. You should include your custom indicator condition on block 5.
Dou you feel brave enough to include the remaining part?

-
Thank you so much! I'll work on it!