PositionOpen = IIf(BarsSince(Buy==1) < BarsSince(Sell==1),1,-1); // using 1 for Long and -1 for short
BarsOpen = IIf(PositionOpen==1,BarsSince(Buy==1),IIf(PositionOpen==-1,BarsSince(Sell==1),0));
title=EncodeColor(colorOrange)+ "Bars Since Sig : " + NumtoSTR(Barsopen,1.0)+"\n";