Slawa or other programmer - 'Close profit/loss' code help please

 
Hi Slawa

I have attempted a few lines of code in order to close trades when either n% in profit or loss. I am met with partial success because i think I am messing up on the 'persistent command' to broker.

What I mean by this is - If I have set EA to close all trades at either 5% profit or 10% loss, the EA might achieve 5% profit after which it begins to close all open trades (AND pending orders). However, if the broker is a little slow with requote etc, and the market moves AGAINST positions which remain open, causing the profit to read 4.9% (or less), then the EA will cease attempt at closure.

Can someone post the code which would successfully overcome this issue and conquer the function above?

Many thanks

FxNorth
Reason: