EA does not execute trades in another symbol

 

Hi, I am new to Metatrader 5.

I've got kind of a weird problem:


I am using an EA which is working completely perfect when I attach it to the symbol ENQ.

After detaching it and attaching it to the symbol DD, the German DAX future, it doesn't execute any trades. There is enough cash in the account, which means I can trade DD when I manually put on trades and I can see no error messages.

Any idea what could be the reason for that behavior?

Thx

 
cookie2398:

Hi, I am new to Metatrader 5.

I've got kind of a weird problem:


I am using an EA which is working completely perfect when I attach it to the symbol ENQ.

After detaching it and attaching it to the symbol DD, the German DAX future, it doesn't execute any trades. There is enough cash in the account, which means I can trade DD when I manually put on trades and I can see no error messages.

Any idea what could be the reason for that behavior?

Thx

Can you share the code ?

 
Stanislav Ivanov:

Can you share the code ?

The problematic part is this one:


//+------------------------------------------------------------------+
//| Open Buy position                                                |
//+------------------------------------------------------------------+
void OpenBuy(double lot,double sl,double tp)
  {
   sl=m_symbol.NormalizePrice(sl);
   tp=m_symbol.NormalizePrice(tp);

   double long_lot=lot;
//--- check volume before OrderSend to avoid "not enough money" error (CTrade)
   double free_margin_check= m_account.FreeMarginCheck(m_symbol.Name(),ORDER_TYPE_BUY,long_lot,m_symbol.Ask());
   double margin_check     = m_account.MarginCheck(m_symbol.Name(),ORDER_TYPE_SELL,long_lot,m_symbol.Bid());
   if(free_margin_check>margin_check)
     {
      if(m_trade.Buy(long_lot,m_symbol.Name(),m_symbol.Ask(),sl,tp))
        {
         if(m_trade.ResultDeal()==0)
           {
            Print("#1 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
                  ", description of result: ",m_trade.ResultRetcodeDescription());
            PrintResultTrade(m_trade,m_symbol);
           }
         else
           {
            Print("#2 Buy -> true. Result Retcode: ",m_trade.ResultRetcode(),
                  ", description of result: ",m_trade.ResultRetcodeDescription());
            PrintResultTrade(m_trade,m_symbol);
           }
        }
      else
        {
         Print("#3 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
               ", description of result: ",m_trade.ResultRetcodeDescription());
         PrintResultTrade(m_trade,m_symbol);
        }
     }
   else
     {
      Print(__FUNCTION__,", ERROR: method CAccountInfo::FreeMarginCheck returned the value ",DoubleToString(free_margin_check,2));
      return;
     }
//---
  }


It always ends in #3 with Retcode 10006 (rejected)


The thing is:


In the ENQ, the system works fine and trades and everything OK


In the DD and FDXM all the orders are rejected.


Any idea?

And in the demo, DD and FDXM are executed - that's weird isn't it?

 
cookie2398 :


Show OnInit ().

 
Vladimir Karputov:

Show OnInit ().



//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   start_pos=0;
   count=3;
   ArraySetAsSeries(rates,true);
//---
   if(!m_symbol.Name(Symbol())) // sets symbol name
      return(INIT_FAILED);
   RefreshRates();
//---
   m_trade.SetExpertMagicNumber(m_magic);
   m_trade.SetMarginMode();
   m_trade.SetTypeFillingBySymbol(m_symbol.Name());
   m_trade.SetDeviationInPoints(m_slippage);
//---
   return(INIT_SUCCEEDED);
  }
 
cookie2398 :

The problematic part is this one:

It always ends in #3 with Retcode 10006 (rejected)

The thing is:

In the ENQ, the system works fine and trades and everything OK

In the DD and FDXM all the orders are rejected.

Any idea?

And in the demo, DD and FDXM are executed - that's weird isn't it?

You need to check all trade permissions for these symbols. Check using a script.

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Client Terminal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Client Terminal Properties
  • www.mql5.com
Information about the client terminal can be obtained by two functions: TerminalInfoInteger() and TerminalInfoString(). For parameters, these functions accept values from ENUM_TERMINAL_INFO_INTEGER and ENUM_TERMINAL_INFO_STRING respectively. Knowing the parameter value, you can set the size of graphical objects so that they look the same on...
 
Vladimir Karputov:

You need to check all trade permissions for these symbols. Check using a script.

That sounds reasonable.


Where do I find such a script to check the trading permissions on a certain symbol ??

 

Hi you can use 

SymbolInfoInteger() 

Function.

SYMBOL_TRADE_MODE_CLOSEONLY

Allowed only position close operations

SymbolInfoInteger

SYMBOL_TRADE_MODE_DISABLED

Trade is disabled for the symbol

SymbolInfoInteger

SYMBOL_TRADE_MODE_FULL

No trade restrictions

SymbolInfoInteger

SYMBOL_TRADE_MODE_LONGONLY

Allowed only long positions

SymbolInfoInteger

SYMBOL_TRADE_MODE_SHORTONLY

Allowed only short positions

SymbolInfoInteger

Documentation on MQL5: Market Info / SymbolInfoInteger
Documentation on MQL5: Market Info / SymbolInfoInteger
  • www.mql5.com
2. Returns true or false depending on whether a function is successfully performed. In case of success, the value of the property is placed into a recipient variable, passed by reference by the last parameter. It is recommended to use SymbolInfoTick() if the function is used for getting information about the last tick. It may well be that not a...
Reason: