Difference in backtest and actual code execution

while executing the below mentioned code, the backtest is showing the result as per my expectation, the profit target and stop loss are getting executed properly, but in actual implementation the profit target and stop loss are not getting executed. Please guide me what is the fault?


SetOption( "ReverseSignalForcesExit", True);

/*
tn = TimeNum();
end_time = 151000;
is_session_end = tn > end_time;
is_session = tn >= 091500 AND tn <= end_time;
*/
// Moving Average
SHORT_MA_PERIOD = Param("Short term moving average period", 20, 1, 200, 2);
LONG_MA_PERIOD = Param("Long term moving average period", 50, 1, 200, 2);


/* Exponential Moving averages */
EMA1 = EMA( C, SHORT_MA_PERIOD); 
EMA2 = EMA( C, LONG_MA_PERIOD);

/* Buy and Sell Condition */
Buy_sig = Cross(Ref(EMA1,-1),Ref(EMA2,-1));
Sell_sig = Cross(Ref(EMA2,-1),Ref(EMA1,-1));

Buy = Buy_sig; 
Sell = Sell_sig; 

ApplyStop(stopTypeProfit,stopModePoint,13);
ApplyStop(stopTypeLoss,stopModePoint,7);

//Short = Sell_sig; 
//Cover = Buy_sig; //OR is_session_end;// Short exit

/* Plot Buy and Sell Signal Arrows */
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
GraphXSpace = 5; 

/* Plot EMA lines and Candles */
Plot(EMA1,"EMA", colorRed);
Plot(EMA2,"EMA2", colorGreen);
Plot(C, "Close", colorRed, styleCandle);

This is duplicate query. Quoting Tomasz from How to use this site :