This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Trade Dispatcher: all trade context is busyBack to topics list | 1 2 |
|
Vooch
2005.08.11 20:16
> mamma mia.
> 10 experts ask "is trade allowed?", 10 experts receive answer "yes of course", 10 experts send order but first > expert only trade successfully. other 9 experts are losers and outsiders hehehe... yep. : ) Now you see why some people run into problems. We take the program and use it to it's fullest capabilities. You guys have been doing a good job with the improvements. - Vooch |
|
Slawa
2005.08.11 20:29
on the russian forum discussed same problem
string SemaphoreName="TradeSemaphore";
//////////////////
int init ()
{
if(!GlobalVariableCheck(SemaphoreName)) GlobalVariableSet(SemaphoreName,0.0);
bla-bla-bla
bool bSemaphored=false;
while(!IsStopped())
{
if(GlobalVariableGet(SemaphoreName)==0.0)
{
GlobalVariableSet(SemaphoreName,1.0);
bSemaphored=true;
break;
}
Sleep(1000);
}
if(nSignal == OP_BUY)
Buy();
else if(nSignal == OP_SELL)
Sell();
for(int nCnt = OrdersTotal() - 1; nCnt >= 0; nCnt--)
{
OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == nMagic)
{
if(CurTime() - OrderOpenTime() > (nHoursToHold - 1) * 60 * 60)
{
if(OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, nSlip, Aqua);
else if(OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, nSlip, OrangeRed);
}
}
}
if(bSemaphored) GlobalVariableSet(SemaphoreName,0.0);
|
Back to topics list
| 1 2
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
