Open alternate orders

 

Hi all,

Have an issue with an Ea that I'm writing. I'm looking to open orders observing these conditions;

First open by mean of an indicator is a buy (could be a sell of course) and then a buy order is open, if price bounce down to a level under the open price from the buy order, a sell order will open, but if price goes up again no new open buy should happen. Here a new buy order should only happen when price bounces back from the sell order. All the same if a sell order is the first to happen.

I've tried to get that with the following code attached but doesn't work. Here what is working is;

say the first order to open is a buy, then and as expected a sell order will open, but from here no other orders open...

I really appreciate if one could help me here.

best regards

Luis

Files:
Reason: