Why doesn't breakeven work for XAU? PLS

 

As soon as the order is opened, even if I increase the Pips as input, the stop loss is immediately positioned at BE after very few pips.


bool fxBreakEven(int argMagicNumber, int argBeakevenPip){

         bool response=false;
         // conversione da PIP in POINT
         if(Digits()==3 || Digits()==5){ 
            argBeakevenPip= argBeakevenPip*10;
         }  
         // esco dalla funzione se i pip di attivazione sono settati a zero
         if (argBeakevenPip==0 ) {return(false);}
         // conversione da POINT a prezzo reale
         double realSpread = SymbolInfoInteger(_Symbol,SYMBOL_SPREAD)*Point();
         double realBeakeven =argBeakevenPip*Point()+realSpread; //per calcolo livello di attivazione breakeven
         
         int pos_total=PositionsTotal();
         for (int i = pos_total - 1; i >= 0; i-- ){
            ulong ticket=PositionGetTicket(i); //acquisisco il ticket della posizione in base all'indice
            if( ! PositionSelectByTicket(ticket)){ continue; } // seleziono la posizione in base al ticket
            if (PositionGetInteger(POSITION_MAGIC)==argMagicNumber && PositionGetString(POSITION_SYMBOL)== Symbol()){
               MqlTradeRequest request;
               ZeroMemory(request);
               MqlTradeResult result;
               ZeroMemory(result);
                  
               long posType = PositionGetInteger(POSITION_TYPE);
               double currentSL = PositionGetDouble(POSITION_SL);
               double currentTP = PositionGetDouble(POSITION_TP);
               double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);            

               request.action = TRADE_ACTION_SLTP;
               request.symbol = _Symbol;
               request.tp = currentTP;
               request.position=ticket;
               
               // Modifica posizione BUY
               if (posType == POSITION_TYPE_BUY){
                  double currentPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID);
                  double breakEvenPrice = openPrice + realSpread;
                  double currentProfit = currentPrice - openPrice;

                  if(currentSL < openPrice-realSpread && currentProfit >= realBeakeven){
                     request.sl = breakEvenPrice;
                     bool res=OrderSend(request,result);
                     response=true;
                  }                
                }
                
               // Modifica posizione SELL
               if (posType == POSITION_TYPE_SELL){
                  double currentPrice = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
                  double breakEvenPrice = openPrice - realSpread;
                  double currentProfit = openPrice - currentPrice;
            
                  if(currentSL > openPrice+realSpread && currentProfit >= realBeakeven){
                     request.sl = breakEvenPrice;
                     bool res=OrderSend(request,result);
                     response=true;
                  }
               }
            }//end if (PositionGetInteger             
         }// exit for
         return(response);
}