Mi bot works with EURUSD, but not with EURUSD.a

 

Hello everyone. I have this code which works perfectly for me when testing it with EURUSD.a. However, when doing it with EURUSD I get error 131. It should be noted that I use the Pepperstone broker. Thank you!

//+------------------------------------------------------------------+
//|                                                    Seminario.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+


//Variable externas
extern double Lote = 0.01;
extern double StopLoss = 300;
extern double TakeProfit = 400;
extern int TrailingStop = 280;

extern int Slipagge = 10;
extern int MagicNumber = 12345;

extern int PeriodoEMARapidaActual = 5;
extern int PeriodoEMALentaActual = 21;
extern int PeriodoEMARapidaPasada = 5;
extern int PeriodoEMALentaPasada = 21;

//Variables Globales
int TicketCompra;
int TicketVenta;
int MaximoDeOrdenes = 0;
int BarsCount = 0;
int i;
bool fm;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
void OnTick()
  {
   //Medias Exponenciales
   double EMARapidaActual = iMA(NULL,0,PeriodoEMARapidaActual,0,1,0,1);
   double EMALentaActual = iMA(NULL,0,PeriodoEMALentaActual,0,1,0,0);
   double EMARapidaPasada = iMA(NULL,0,PeriodoEMARapidaPasada,0,1,0,1);
   double EMALentaPasada = iMA(NULL,0,PeriodoEMALentaPasada,0,1,0,3);
                           
   //Orden de compra                                          // Linea EMAs: "EMARapida es mayor a EMALenta y no hay error 
   if(EMARapidaActual > EMALentaActual && EMARapidaPasada > EMALentaPasada &&  TicketCompra == 0)  
 
   if (OrdersTotal()==MaximoDeOrdenes)
   
   if (Bars > BarsCount)
                                                              //(x && y) = Si x e y son verdaderos, la expresion es verdadera
    {                                                          //(x == y) = x es igual a y    0 = No error returned 
       //Abrir operacion de compra
       TicketCompra = OrderSend(Symbol(),OP_BUY,Lote,Ask,Slipagge,(Ask - (StopLoss * Point)),(Ask + (TakeProfit * Point)),"Orden de Compra",MagicNumber,0,Green);
      
       TicketVenta = 0;     
       BarsCount = Bars;      
    }
    
   
    
   //Orden de venta 
   if(EMARapidaActual < EMALentaActual && EMARapidaPasada < EMALentaPasada && TicketVenta == 0) 
   
   if (OrdersTotal()==MaximoDeOrdenes)
   
   if (Bars > BarsCount)
 
    {     
      //Abrir operacion de venta
      TicketVenta = OrderSend(Symbol(),OP_SELL,Lote,Bid,Slipagge,(Bid + (StopLoss * Point)),(Bid - (TakeProfit * Point)),"Orden de Venta",MagicNumber,0,Green);
      
      TicketCompra = 0;  
      BarsCount = Bars;    
    }
    
    
    
    //Order Select y Order Modify 
    
       
    for (i=0;i<OrdersTotal();i++) 
    if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
      
     if(OrderType()==OP_BUY) 
     if(OrderMagicNumber()==MagicNumber)
     if(OrderSymbol()==Symbol()) 
   
     if(Bid-OrderOpenPrice()>TrailingStop*Point) //Si el precio Actual supera al de Entrada en 15 puntos..
     if(OrderStopLoss()<Bid-TrailingStop*Point)  // EL Trailing Stop nunca retrocede||((El precio Actual -Trailing Stop) debe ser siempre mayor al SL (de entrada?))
         { 
          fm = OrderModify(TicketCompra,OrderOpenPrice(),Ask-TrailingStop*Point,0,0,Green);   
         } 
      
                  
      if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
      
      if(OrderType()==OP_SELL) 
      if(OrderMagicNumber()==MagicNumber)      
      if(OrderSymbol()==Symbol())
      
      if(OrderOpenPrice()-Ask>TrailingStop*Point)
      if((OrderStopLoss()>Ask+TrailingStop*Point) || (OrderStopLoss()==0))       
        {
         fm = OrderModify(TicketVenta,OrderOpenPrice(),Bid+TrailingStop*Point,0,0,Red);
        }
       
      
    return;
    
   }
//+------------------------------------------------------------------+
 
cayenne:

Hello everyone. I have this code which works perfectly for me when testing it with EURUSD.a. However, when doing it with EURUSD I get error 131. It should be noted that I use the Pepperstone broker. Thank you!

4 things.

1) your code is either very old, OR is created by AI. This is "frowned upon" and even ops are criticised for posting such code.

2) I doubt that it is "working" as you wish. It might be opening trades, but the take profits and stop losses might not be right.

3) change Point to Point() or _Point.

4) search help in metaeditor or this website for "Normalize" and use this on all of the OrderSend(s), on every takeprofit and stoploss calculation.

EDIT: I could be wrong, but I think that you can only use 1 set of symbols. The set of symbols you are allowed to trade on, depends on your account type. It should be easy to see on your marketwatch list. If 1 set of symbols are grey or the bid and ask prices do NOT change, then these are the symbols that you do not use. If it is unclear, then, you need to chat to your broker support and ask them which ones to use.