OrderCloseBy not working here??

Examples step by step how to make your own automated strategy or user indicator
Message
Author
ferdijo
Posts: 2
Joined: Mon Aug 24, 2020 9:29 am

OrderCloseBy not working here??

#1 Postby ferdijo » Mon Aug 24, 2020 9:43 am

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

FX Helper
Posts: 1477
Joined: Mon Apr 01, 2013 3:55 am

Re: OrderCloseBy not working here??

#2 Postby FX Helper » Thu Aug 27, 2020 3:43 am

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.


Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 28 guests