Need help to solve error in intraday AFL

This is intraday trading strategy AFL,which open 4 trades at opening bell based on ROC and position score. (I am using 15 min. time frame)

It seems that there is error in reversetrade code,When freshbuy signal generate and trade get open ..the SL is buycandle's where i want to go short if sl triggers.. else will close the trade at closing bell..

Error: under portfolio backtesting, i am facing 3 problem

-Reversetrade signals generates by considering any previous fresh trade's low/high crossover.while valid crossover is fresh buy/short must be in current day.

-How to code this afl so that under portfolio backtest,Reverse trade take place only in those stock are selected and traded current day with fresh buy/fresh short signal.

-at closing bell i need to close all active trade,But this AFL open new 4 trade at a time of closing bell and close the trade next day.not getting where m i making mistake.

it would be great help if someone can guide me to solve errors

FreshTradeTime=TimeNum() >= 091500 AND TimeNum() <= 094500 ;
ReverseTradeTime=TimeNum() >= 091500 AND TimeNum() <= 144500;
CloseALL = TimeNum() >=152500;	

FreshBuy=ROC(C,1)> 1;
FreshShort=ROC(C,1)< -1;
ReverseBuy=  Cross(C,ValueWhen(FreshShort,H));

Buy = FreshBuy OR ReverseBuy;
BuyStop=IIf(FreshBuy, Cross(ValueWhen(FreshBuy,L),C),Cross(ValueWhen(FreshShort,L),C)); 
Sell= BuyStop==1 OR CloseALL;

Short=  FreshShort OR ReverseShort ;
ShortStop=IIf(FreshShort, Cross(C,ValueWhen(FreshShort,H)),Cross(C,ValueWhen(FreshBuy,H)));
Cover= ShortStop==1 OR CloseALL ;



e= 100000;
PositionSize= -25;
SetOption("MaxOpenPositions", 4 );