Buystops and sell stops returning error 4756

[Deleted]  
I do understand error 4756 means invalid stops, the buystop code is below. It works on testing and all symbols except gold. What might be the issue.
//+--------------------------------------------------------------------+
void BUYSTOP(double entry, string symbol, int Magic, string EA_Comment)
   {
      double points    = SymbolInfoDouble(symbol,SYMBOL_POINT);
      bool   orders    = Borders(symbol,Magic);
      bool   positions = Bpositions(symbol,Magic);
      int    pointtp   = TPvalue(symbol);
      int    pointsl   = SLvalue(symbol);
      
      int    digits    = (int) SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      
      entry          = NormalizeDouble(entry,digits);
      double ask     = SymbolInfoDouble(symbol,SYMBOL_ASK);
      
      
      if(!orders && !positions)
         {
            double tp = entry + pointtp * points;
            tp = NormalizeDouble(tp,digits);
            
            double sl = entry - pointsl * points;
            sl = NormalizeDouble(sl,digits);
            
            double stop = entry - pointsl * points;
            datetime expiry = (datetime)TimeCurrent() + (24 * 60 * 60);
            
            MqlTradeRequest request = {};
            MqlTradeResult  result = {};
            
            ZeroMemory(request);
            ZeroMemory(result);
            
            request.action     = TRADE_ACTION_PENDING;
            request.type_time  = ORDER_TIME_SPECIFIED;
            request.symbol     = symbol;
            request.volume     = LotOptimised(MathAbs(entry - stop),symbol);
            request.deviation  = Deviation;
            request.magic      = Magic;
            request.type       = ORDER_TYPE_BUY_STOP;
            request.price      = entry; 
            request.sl         = sl;
            request.tp         = tp;
            request.comment    = EA_Comment;
            request.expiration = expiry;
      
      
            if(!OrderSend(request,result))
               {
                  ErrCode = GetLastError();
                  string error = IntegerToString(ErrCode);
                  
                  Print("Unable to place Buystop order, error - " + error + " " + symbol);
               }   
            else
               {
                  string number = IntegerToString(Magic);
                  
                  Print("Buystop placed successfully ,BLAC " + number + " " + symbol);
               }            
         }
   }
Carl Schreiber  

Check the prices and print them in case OrderSend failed: bid (for sell), ask (for buy), open, sl, & tp!

Consider the minimal distances and the spread for the symbol! (See specifications)

And remember this:


William Roeder  
Derrick Mutange: the buystop code is below

There is no need to create pending orders in code.

  1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

    Don't worry about it unless you're scalping M1 or trading news.

  2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

Reason: