how to use the applystop in my simple code, please help

////////////////////////////////////////////////chart & back ground color//////////////////////////////////////////////////
SetChartBkGradientFill(colorBlack,colorBlack,colorBlack);
//Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Plot( Close, "C", colorWhite, styleCandle); 
separator = Day() != Ref( Day(), -1 );
Plot( separator, "", colorDarkBlue, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 5 );
GraphXSpace=85;
//////////////////////////////////////////////////////////////////
Plot(EMA(Close,5),"",colorGreen,styleThick);
Plot(EMA(Close,13),"",colorRed,styleThick);

Buyst = EMA(Close,5) > EMA(Close,13);
Shortst = EMA(Close,5) < EMA(Close,13);
Session= (TimeNum() > 093000) AND (TimeNum() < 151500);
Buy =     Buyst  AND Session;
Short =    Shortst  AND Session;
Sell =Shortst OR (TimeNum() > 151500);   
Cover = Buyst OR(TimeNum() > 151500); 
 
BUY=ExRem(BUY,SELL);
SELL=ExRem(SELL,BUY);	
COVER=ExRem(COVER,SHORT);
SHORT=ExRem(SHORT,COVER);

BuyPrice=ValueWhen(Buy,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);
SellPrice=ValueWhen(Sell,C);
////////////////////////////////////////////////////////////////////////////////////////////////

Signalshape=Buy*shapeUpArrow + Short*shapeDownArrow;
PlotShapes( Signalshape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );

pos = 2*ATR(15);
for( i = 0; i < BarCount; i++ ) {
       if( Buy[i] ) PlotText( "" + Close[i], i, Low[i] - pos[i], colorGreen );
       if( Short[i] ) PlotText( "" + Close[i], i, Low[i] + pos[i], colorRed );
	}
	
Signalshape=Cover*shapeHollowUpArrow + Sell*shapeHollowDownArrow;
PlotShapes( Signalshape, IIf( Cover, colorGreen, colorRed ),0, IIf( Cover, Low, High ) );
pos = 2*ATR(15);
for( i = 0; i < BarCount; i++ ) {
      if( Cover[i] ) PlotText( "" + Close[i], i, Low[i] - pos[i], colorGreen );
      if( Sell[i] ) PlotText( "" + Close[i], i, Low[i] + pos[i], colorRed );
	}

once buy or sell is executed after 9:30am that means once we are either in long or short trade after 9:30am in stead of sell and cover statergy I want to implement the applystop coding concept to come out of the trade before 3:15 pm by using trailing stoploss when the trade is in profit and by using stoploss when the trade is in loss.

is the above idea possible?

I tried to code with applystop, but did not get success.

please advise/help.