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 ?
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?
Show OnInit ().
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); }
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.
- www.mql5.com
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 | |
SYMBOL_TRADE_MODE_DISABLED | Trade is disabled for the symbol | |
SYMBOL_TRADE_MODE_FULL | No trade restrictions | |
SYMBOL_TRADE_MODE_LONGONLY | Allowed only long positions | |
SYMBOL_TRADE_MODE_SHORTONLY | Allowed only short positions |
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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