Hello Funyoo and other programmers here better than I.

I have an ea I'm working on that closes a trade based upon an algorithm, instead of a hard take profit.

I am trying to get it so only one action occurs, whether it be opening or closing a trade, per bar. I have tried to adapt pieces of code that allow one trade per bar, but have not been successful in creating one ACTION per bar.

Can anyone help me, please?