Why is this happening ?? - page 2

 
the sar code and trailing stop is working.

What is not working is this expert.

It buys 5 pips above High[1], close is opposite.
Trailing is 5 pips below Low[1] for long trade opposite for short

This exact same expert is working on 2 other crosses ( usd/yen and usd/cad ) but not on gbp/usd

extern double TakeProfit = 0;
extern double Lots = 1;
extern double TrailingStop = 25;
extern double Stoploss = 45;
extern double Pips = 5;
extern double Perc =10;

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
  double Levv,  equity, Lotss, trd ;
  int cnt=0, total ;
  
  double array_price[][6];
   double array_price1[][6];
   
   ArrayCopyRates(array_price,Symbol() , 0);
ArrayCopyRates(array_price1,Symbol(), 0);  
  
  double llow, hhigh;
            llow = array_price[1][2];
            hhigh =  array_price1[1][3]; 
  if(Bars<2)
  {
    Print("bars less than 100");
    return(0);
  }  
  total=OrdersTotal();
   trd =0 ;
   
   for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol()) trd++;
} 
  {
    if(AccountFreeMargin()<(1*Lots))
    {
      Print("We have no money");
      return(0);
    }
   equity =AccountEquity();
   
  Lotss = MathAbs((equity*Perc/100/100)/10);
   
  Levv=NormalizeDouble(Lotss,1);
  
 //================================================================================
   // (BUY)
    if (trd < 1 && Close[0] >=hhigh+ Pips*Point )
    {
      OrderSend(Symbol(),OP_BUY,Levv,Ask,3,llow-Pips*Point,0,0,0,0,Blue);}
    else
   
    if (trd < 1 && Close[0] > Open[0] )
    {
      OrderSend(Symbol(),OP_BUYSTOP,Levv,hhigh+ Pips*Point,3, llow-Pips*Point,0,0,0,0,Blue);
     return(0);
    }
    
    // (SELL)
   if ( trd < 1 && Close[0] <= llow- Pips*Point ) 
    {
      OrderSend(Symbol(),OP_SELL,Levv,Bid,3, hhigh+ Pips*Point,0,0,0,0,Red);}
     else
     
    if ( trd < 1 && Close[0] < Open[0] ) 
    {
      OrderSend(Symbol(),OP_SELLSTOP,Levv,llow- Pips*Point,3, hhigh+ Pips*Point,0,0,0,0,Red);
      return(0);
    }
    }
//================================================================================
   for (int i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

      if (OrderType() == OP_BUYSTOP && OrderSymbol()==Symbol()&& Close[0] < Open[0]) 
      
      { OrderDelete(OrderTicket());}
      
     for ( i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

      if (OrderType() == OP_SELLSTOP && OrderSymbol()==Symbol()&& Close[0] > Open[0]) 
      
      { OrderDelete(OrderTicket());}
      }
      
  //================================================================================
         
      
  //CLOSE
  
   for ( i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL && 
         OrderSymbol()==Symbol())   
        {
         if(OrderType()==OP_BUY)   
           {
            
            if( Bid <= llow- Pips*Point )
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
                 return(0); 
                }
                }
                }
               
   for ( i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL && 
         OrderSymbol()==Symbol())   
        {
         if(OrderType()==OP_SELL)   
           {
            
            if(Ask >= hhigh+ Pips*Point )
                {
                 OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
                 return(0); 
                }
                }
                }
                }             
                
              
  //================================================================================
               for ( i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
             if( OrderSymbol()==Symbol() && OrderType()==OP_BUY)  
              {                 
                if(OrderStopLoss()!=llow- Pips*Point)
                    {
            OrderModify(OrderTicket(),OrderOpenPrice(),llow- Pips*Point,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }

     for ( i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
    if( OrderSymbol()==Symbol()&& OrderType()==OP_SELL)  
              {                 
               
                  if((OrderStopLoss() !=hhigh+ Pips*Point))
                    {
       OrderModify(OrderTicket(),OrderOpenPrice(),hhigh+ Pips*Point,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
}}}