ulong t="a ticket of a exist order";
if (!OrderSelect(t))
{
Print("In the RunTrade().There is a error when Select order.",GetLastError());
return(false);
}
Thank you very much!!!
What sort of orders do you mean - pending or an one which placed in history (triggered, canceled, etc)?
What sort of orders do you mean - pending or an one which placed in history (triggered, canceled, etc)?
In the strategy tester, the order has been accepted which just been send by EA .
OrderSelect() get the error code is 4754.
I try to test it in MetaQuotes-Demo. The position can't be open. The error code is 4752
ERR_TRADE_DISABLED |
4752 |
Trading by Expert Advisors prohibited |
ERR_TRADE_ORDER_NOT_FOUND |
4754 |
Order not found |
I used to develop MT4. The OrderSelect also appear some problems.
bool OrderSelect( int index, int select, void pool)
if the index = 0 ,the orderselect always return true! Obviously wrong!
and
if select = SELECT_BY_POS pool = MODE_TRADES ,the orderselect always return false or not return all right orders.
ulong t="a ticket of a exist order";
if (!OrderSelect(t))
{
Print("In the RunTrade().There is a error when Select order.",GetLastError());
return(false);
}
Thank you very much!!!
I upload the source files.please help me.
//+------------------------------------------------------------------+
//| Test.mq5 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property version "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
MqlTick m_tick;
MqlTradeRequest m_request; // request data
MqlTradeResult m_result; // result data
if(!SymbolInfoTick(Symbol(),m_tick))
Print("SymbolInfoTick(Symbol(),m_tick) get error:",GetLastError());
m_request.action =TRADE_ACTION_DEAL;
m_request.symbol =Symbol();
m_request.magic =88888888;
m_request.volume =0.01;
m_request.type =ORDER_TYPE_SELL;
m_request.price =m_tick.bid;
m_request.sl =0.0;
m_request.tp =0.0;
m_request.deviation =3;
m_request.type_filling=ORDER_FILLING_FOK;
m_request.comment ="";
if(OrderSend(m_request,m_result))
{
if (!OrderSelect(m_result.order))
{
Print("There is a error when Select order:",m_result.order,", error#",GetLastError());
}
else
{
Print("####################",OrderGetDouble(ORDER_PRICE_OPEN));
}
}
else
{
Print("Open position ERROR:",GetLastError());
}
}
- www.mql5.com
See the image which I Upload.The order just there,not executed.
It's executed, the order became a deal. If you look at the picture, it has become an open position.
Your code (m_request.action =TRADE_ACTION_DEAL) confirms that.- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
ulong t="a ticket of a exist order";
if (!OrderSelect(t))
{
Print("In the RunTrade().There is a error when Select order.",GetLastError());
return(false);
}
Thank you very much!!!