EA trailing stop not trailing and very slow when backtesting

 
 This EA trades a Candlestick reversal setup at open of Bar[0]
 BUY - Candle[1] is bullish
        - Candle[2] is bullish

        - Candle[3] is bearish

I had created a separate trailing stop EA and it works fine. 

The problem is that when i looped this trail stop EA on the Reversal setup EA, the trail is not trailing. 

May you kindly assist. Here is the code. 

#include<Trade\SymbolInfo.mqh>
#include<Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\AccountInfo.mqh>
//---
CSymbolInfo    m_symbol;                     // object of CSymbolInfo class for receiving symbol settings
CTrade         m_trade;                      // object of CTrade class for performing trade operations
CPositionInfo  m_position;                   // object of CPositionInfo class for receiving position settings
CAccountInfo   m_account;                    // object of CAccountInfo class for receiving account settings
//--- input parameters
input group             "Trading settings"
input uint                 InpStopLoss             = 200;             // Stop Loss
input uint                 InpTakeProfit           = 400;             // Take Profit
input group             "Position size management (lot calculation)"
input double               InpLots                 = 0.10;           // Lots
input group             "Additional features"
input bool                 InpPrintLog             = true;           // Print log
input ulong                InpDeviation            = 10;             // Deviation, in Points (1.00045-1.00055=10 points)
input ulong                InpMagic                = 12345;          // Magic number
//---
datetime m_prev_bars                = 0;        // "0" -> D'1970.01.01 00:00';
//---
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- set the name for the appropriate symbol
   ResetLastError();
   if(!m_symbol.Name(Symbol())) // sets symbol name
     {
      Print(__FILE__," ",__FUNCTION__,", ERROR: CSymbolInfo.Name");
      return(INIT_FAILED);
     }
   RefreshRates();
//---
   m_trade.SetExpertMagicNumber(InpMagic);            //--- set magicNumber for your orders identification
   m_trade.SetMarginMode();                           //--- set margin mode for your orders
   m_trade.SetTypeFillingBySymbol(m_symbol.Name());   //--- set order filling mode allowed by the server
   m_trade.SetDeviationInPoints(InpDeviation);        //--- set available slippage in points when buying/selling
//---
//--- receive current rates and display
   Print(m_symbol.Name()," (",m_symbol.Description(),")","  Bid=",m_symbol.Bid(),"   Ask=",m_symbol.Ask());
//--- receive minimum freeze levels for trade operations
   Print("StopsLevel=",m_symbol.StopsLevel()," points, FreezeLevel=",m_symbol.FreezeLevel()," points");
//--- receive the number of decimal places and point size
   Print("Digits=",m_symbol.Digits(),", Point=",DoubleToString(m_symbol.Point(),m_symbol.Digits()));
//--- spread info
   Print("SpreadFloat=",m_symbol.SpreadFloat(),", Spread(current)=",m_symbol.Spread()," points");
//--- request order execution type for limitations
   Print("Limitations for trade operations: ",EnumToString(m_symbol.TradeMode())," (",m_symbol.TradeModeDescription(),")");
//--- clarifying trades execution mode
   Print("Trades execution mode: ",EnumToString(m_symbol.TradeExecution())," (",m_symbol.TradeExecutionDescription(),")");
//--- clarifying contracts price calculation method
   Print("Contract price calculation: ",EnumToString(m_symbol.TradeCalcMode())," (",m_symbol.TradeCalcModeDescription(),")");
//--- sizes of contracts
   Print("Standard contract size: ",m_symbol.ContractSize()," (",m_symbol.CurrencyBase(),")");
//--- minimum and maximum volumes in trade operations
   Print("Volume info: LotsMin=",m_symbol.LotsMin(),"  LotsMax=",m_symbol.LotsMax(),"  LotsStep=",m_symbol.LotsStep());
//---
   Print(__FUNCTION__,"  completed");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- calculate the Ask price
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);  
    
//--- work only at the time of the birth of new bar
   datetime time_0=iTime(m_symbol.Name(),Period(),0);
   if(time_0==m_prev_bars)
      return;
   m_prev_bars=time_0;
   if(!RefreshRates())
     {
      m_prev_bars=0;
      return;
     }
//---
   MqlRates rates[];
   ArraySetAsSeries(rates,true);
   int start_pos=0,count=6;
   if(CopyRates(m_symbol.Name(),Period(),start_pos,count,rates)!=count)
     {
      m_prev_bars=0;
      return;
     }
//--- Condition for opening BUY position
   if(rates[1].open-rates[1].close<0.0)      // Candle[1] is bullish
      if(rates[2].open-rates[2].close<0.0)   // Candle[2] is bullish
         if(rates[3].open-rates[3].close>0.0)// Candle[3] is bearish
        {
         //--- check volume before OrderSend to avoid "not enough money" error (CTrade)
         double free_margin_check=m_account.FreeMarginCheck(m_symbol.Name(),
                             ORDER_TYPE_BUY,
                             InpLots,
                             m_symbol.Bid());
         double margin_check=m_account.MarginCheck(m_symbol.Name(),
                             ORDER_TYPE_BUY,
                             InpLots,
                             m_symbol.Bid());
         if(free_margin_check>margin_check)
         
         //if we have less than 2 open positions
         if (PositionsTotal()<2)
           {
            //---
            if(InpPrintLog)
               Print(__FILE__," ",__FUNCTION__,", OK: ","Signal BUY");
            m_trade.Buy(0.10,m_symbol.Name(),Ask,(Ask-200*_Point),(Ask+400*_Point),NULL);

            //set the trailing stop 
            CheckTrailingStop(Ask);
           }
        }
//---
  } 
//+------------------------------------------------------------------+
void CheckTrailingStop(double Ask)
   {
      //set the stop loss to 150 points
      double SL=NormalizeDouble(Ask-150*_Point,_Digits);
      
      //check all open positions for current symbo
      for(int i=PositionsTotal()-1; i>0; i--) //count all currency pair positions
      {
         string symbol=PositionGetSymbol(i); //Get position symbol
      
      if (_Symbol==symbol) //if chart symbol equal position suymbol
      {
      //get the ticket number 
      ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
      
      //calculate the current stop loss
      double CurrentStopLoss=PositionGetDouble(POSITION_SL);
      
      //if current stop loss is below 150 points from ask price
      if (CurrentStopLoss<SL)
      {
      //modify the stoploss by 50 points
      m_trade.PositionModify(PositionTicket,(CurrentStopLoss+50*_Point),0);
      }
    }//end if loop 
  }//end for loop
 }// end 
//+------------------------------------------------------------------+
//| Refreshes the symbol quotes data                                 |
//+------------------------------------------------------------------+
bool RefreshRates()
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
     {
      Print(__FILE__," ",__FUNCTION__,", ERROR: ","RefreshRates error");
      return(false);
     }
//--- protection against the return value of "zero"
   if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
     {
      Print(__FILE__," ",__FUNCTION__,", ERROR: ","Ask == 0.0 OR Bid == 0.0");
      return(false);
     }
//---
   return(true);
  }