Error 4756 but the order send

 

hi

i use a EA on real account 

The EA send a order but i get a error 4756 


as you can see at the code below i made a alert to tell me if the order was send or not 

despite the order was send i still get a alert with error and not get a alert " order  "+ _Symbol+ " long was sent "


the code is  

        int magicNM=1111;

        bool opentrade=checkforopentrade(magicNM,_Symbol);
        
        if(!opentrade)
        {
         trade.Buy(0.01,_SYMBOL,SymbolInfoDouble(_Symbol,SYMBOL_ASK),0,0,magicNM);

         if(checkforopentrade(magicNM,SYM)==false)
        	 {
           		 Alert("order  "+ _Symbol + " long faild error = " + GetLastError());
         	 }
        	 else
        	 {
         	  	Alert("order   "+ _Symbol  + " long was sent");
        	 }
         }   

---------------------------------------------------

bool checkforopentrade(int magicNM, string SYMBOL)
{

   for(int i=0 ; i <PositionsTotal(); i++)
   {
         if(PositionSelectByTicket(PositionGetTicket(i))==true )
         {
            if(PositionGetString(POSITION_COMMENT)==magicNM
            & PositionGetString(POSITION_SYMBOL)==_Symbol)
            {
            return true;
            }
         }
    }
    return false;
}
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Account Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: