OPEN TRADE AT OPEN OF NEXT BAR FROM SIGNAL. Close trade on opposite signal.

 

Hi all,

 

I am trying to write an EA but I am having problems opening a trade and closing a trade on the next bar after a signal using icustom. Can someone point our my errors and how to fix them. Only one trade in any direction at any one time. Thanks in advance. 

Files:
 

You are looking at the signal at the current candle, the moment you get a signal you open, the moment you loose the signal you close.

"If you want to open on the next bar after a signal" look for the signal on the previous bar.

"If you want to open on the next bar after a signal" disappears, look at the previous bar.

Reason: