How to remove forward looking error from this basic BTST system

#1
hi
I was trying to test a very basic BTST system.
it has a buy condition (say if 1 day ROC > 2%),then buy at today's CLOSE & sell tomorrows OPEN.

BuyPrice = Close;
SellPrice = Open;
Buy=ROC(C,1)>2;
sell = barssince(Buy)==1 ; works fine
but when buy condition is true for many consecutive days , system do not sell the next day, But the day next to day buy was true last time.

which makes it a forward looking system, hence useless.
How can this be avoided.
I tried exrem/Flip/for loop , but with little success, as of now.

Thanks in advance.

Best regards,
 
#3
Thanks colion for your reply
There is no other future looking functions in the system.

The future looking part creeps in when original buy condition (ROC(C,1)>2)is true for many consecutive days .
System do not sell next day if that days ROC(C,1)>2 {amibroker considers Buy as true for this day}
But practically trader cannot know at the open if closing ROC will be greater than 2.
AB keeps the position open for these days & shows profits for these days which trader will never get in real life , since he has already sold in the open.

Best Regards,