ERROR 0 (MT4)

 

Hello friends,

 

I'm wondering about an error in MT4.

I test one of my personal EAs and in the journal I see an alert: Error 0

Why error 0? This should mean no error, but orders remain unable to open using this robot !!!

ConstantValueDescription
ERR_NO_ERROR0No error returned.

Any share anyone?


 

Error 0 probably means the GetLastError() wasn't captured properly.  <<< If this correct, how to allow the function GetLastError() to capture errors and let the EA works?

  • Note that this error is only coming in one Broker only, not coming with another one and it is working fine with all the brokers!!


 

Regards  :)
Mohammad Soubra

 
Hi,

Your code needs to be fixed. It is possible to solve this issue.

One of the examples:

OrderModify with same TP and SL as before and repeat it then it gives error#0.

Solution here: 

if (sl != OrderStopLoss() || tp!= OrderTakeProfit())
{
   // OrderModify here 
} 

 

Regards,

Anton 


 
Anton Nel:
Hi,

Your code needs to be fixed. It is possible to solve this issue.

One of the examples:

OrderModify with same TP and SL as before and repeat it then it gives error#0.

Solution here: 

 

Regards,

Anton 


Thanks my friend

I finally got it
The broker has the symbol ends with micro such as  EURUSDmicro that accepts the micro lot sizes
But..
The symbol EURUSD will not open any order with micro lot size and may return the err 00

Thanks again Anton
 
soubra2003 :
Grazie amico mio

Finalmente l'ho capito
Il broker ha il simbolo con micro come EURUSDmicro che accetta le micro dimensioni del lotto
Ma ..
Il simbolo EURUSD non aprirà alcun ordine con la dimensione del lotto micro e potrebbe restituire l'errore 00

Grazie ancora Anton

SAME  ERROR 0:

PLease helP ME


if (Stoploss!=0   && Ask>=OOP + Stoploss   * Point) {if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,clrNONE)) continue;}

               if (Takeprofit!=0 && Ask<=OOP - Takeprofit * Point) {if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,clrNONE)) continue;}

               if (OSL==0 && Stoploss>=STOPLEVEL && Stoploss!=0)

               {

                  SL = NormalizeDouble(OOP + Stoploss   * Point,Digits);

               }

               if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)

               {

                  TP = NormalizeDouble(OOP - Takeprofit * Point,Digits);

               }

               if (TrailingStop>=STOPLEVEL && TrailingStop!=0 && (OOP - Ask)/Point>=TrailingStart)

               {

                  StLo = NormalizeDouble(Ask + TrailingStop*Point,Digits); 

                  if (StLo <= OOP && (StLo < OSL-TrailingStep*Point || OSL==0)) SL = StLo;

               }

               if (SL != OSL || TP != OTP)

               {  

                  if (!OrderModify(OrderTicket(),OOP,SL,TP,0,clrNONE)) Print("Error OrderModify <<",Error(GetLastError()),">> ");

 

Hi Dears, I've just installed my new ea on live account and I'm getting Error 0 every time that an order is triggered.  I want ask you if is it possible that the latency of execution is my "error0".. because the same ea always worked in other versions and different mt4. I put the code that place order, so you can see that i refresh rates, now refresh also just before sending order (i've to see if this can fix issues). please let me know what do you think about it. thanks


bool PlaceOrder(int type, int magic, int id, bool checkmargin = true)
  {
   
   //Print("PlaceOrder called.. Type : "+TypeToStr(type));
   double entry, lot;
   color  col;
   int typet;

   int i = 0;
   while(i < NumRetries)
     {
      i += 1;
      while(IsTradeContextBusy())
         Sleep(RetryDelayInSec*1000);
      RefreshRates();
      if(type == OP_BUY)
        {
         entry = Ask;
         col   = Blue;
         typet = 2;

        }
      else
        {
         entry = Bid;
         col   = Red;
         typet = 4;
        }

      if(MathAbs(entry-Close[1]) > stoplevel)
         break;  //--Controllo che non ci siano stati spike nel prezzo (es. new impattante)

      if(LotCalculation == FixedLots)
         lot = FixedLotSize;
      else
         lot = GetLotSize(type, entry);

      Print("Try "+i+" : Open "+TypeToStr(type)+" order. Entry : "+DoubleToStr(entry,Digits)+" Lot :"+lot+" Magic :"+magic);

      if(checkmargin)
        {
         double margin_required = 2 * MarketInfo(Symbol(),MODE_MARGINREQUIRED)*lot;
         double initloss = MathCeil((InitialPL() + CommissionPerLot)*lot);
         //Print("margin_required to open 2 trades : "+margin_required+" initloss : "+initloss+" AccountFreeMargin : "+AccountFreeMargin());
         if(AccountFreeMargin() <= margin_required+initloss)
           {
            Print("Unable to place order due to insufficient margin");
            return(false);
           }
        }
      /*-- STOP ORDERS
            if(typet==2)
               int ticket = OrderSend(Symbol(),typet,lot,Close[1],Slippage,Close[1] - (MyRPips *myPoint) ,Close[1] + (MyRPips * myPoint * TradeRewardMult),TradeComment,magic,120,col);
            if(typet==4)
               ticket = OrderSend(Symbol(),typet,lot,Close[1],Slippage,Close[1] + (MyRPips *myPoint) ,Close[1] - (MyRPips * myPoint * TradeRewardMult),TradeComment,magic,120,col);
      */
      //MARKET ORDERS
      if(type == OP_BUY && MaxOpenTrade <= CountOrdersByMagic(MagicNumber) )
        {
         RefreshRates();
         int ticket = OrderSend(Symbol(),type,lot,Ask,Slippage,0,0,TradeComment,magic,0,col);
        }
      if(type==OP_SELL && MaxOpenTrade <= CountOrdersByMagic(MagicNumber) )
        {
         RefreshRates();
         ticket = OrderSend(Symbol(),type,lot,Bid,Slippage,0,0,TradeComment,magic,0,col);
        }
      if(ticket <= 0)
        {
         Print("ERROR opening market order. ErrorCode:"+GetLastError());
         if(i == NumRetries)
           {
            Print("*** Final retry to OPEN ORDER failed ***");
            return(false);
           }
        }
      else
        {
         SetSLandTP(ticket, id);
         i = NumRetries;
         return(true);
        }
     }

   return(false);
  }
 
11:35:00.585 Nasdaq Ghost Robot Platinum US30Cash,M5: Error: 0
0 11:37:17.910 Nasdaq Ghost Robot Platinum US30Cash,M5: uninit reason 5

0 11:37:17.954 Nasdaq Ghost Robot Platinum US30Cash,M5 inputs: NGRP=Settings; LotSize=0.01; TakeProfit=150.0; Stoploss=50.0; PercentToRisk=0.02; Layer_Multiplier=8



I am getting this error while running my bot for US30 and US100, however it works fine for all the FX pairs and gold. Can anyone please help me to fix this ??

Reason: