Page 1 of 1

OrderCloseBy not working here??

Posted: Mon Aug 24, 2020 9:43 am
by ferdijo
I'm applying the strategy and one of the statement using "OrderCloseBy" which is absolutely fine in MT4 Strategy Tester... but not working in ForexTester which was return in error code 4019 (cannot call function) ... May anybody give me the solution how to make it works in ForexTester please...

here are the coding i used:
void TutupSellPosisi()
{
// cari OP_BUY dengan harga terendah...
int tiket2;
double BuyPrxTerendah=100;

for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i, SELECT_BY_POS)==true)
if (OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
if(OrderOpenPrice()<BuyPrxTerendah)
{
BuyPrxTerendah=OrderOpenPrice();
tiket2=OrderTicket();
}
}
}
//====================

int tiket1;
int check;

for(int j=0;j<OrdersTotal();j++)
{
if(OrderSelect(j, SELECT_BY_POS)==true)
tiket1=OrderTicket();
// Delete all pending trades
if (OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber)
{
OrderCloseBy(tiket1, tiket2);
check=GetLastError();
if(check!=ERR_NO_ERROR) Print("Error: ",check);
}
}
}

Thanks

Re: OrderCloseBy not working here??

Posted: Thu Aug 27, 2020 3:43 am
by FX Helper
Hello,

Sorry, but as far as I know, Forex Tester program doesn't have Close By functionality so this option will not work here.

The only way is to close orders separately in this case.