New EA help please

 

Hello all,

I have attempted my first EA and amazingly enough it actualy works,sort of.

The idea behind it is that when the price ,Hourly candle, closes below the 26 EMA it opens a short position and when the price closes above the 26 EMA it closes the short and opens a long position.

The problem I have, however, is that as the EA opens a new trade on the open of the next candle if either the profit target is hit or the trailing stop is hit on the previous candle, which I dont want it to do.I only want one trade in any direction.

The other thing I would like it to do is open 2 positions, when conditions are met, one with a "take profit" and another with a trailing stop.

Can anyone help or post a bit of code that may help?

Files:
Reason: