Download MetaTrader 5

Can anyone support(suggest) me to solve the strange issue?

To add comments, please log in or register
Do you have Mac OS? Find out how to install MetaTrader on it!
Sherif Hasan
7290
Sherif Hasan 2015.10.22 14:16 

I would like to close my order partially 50% of lot size when it is in +20 pips.

so when order is >20 pips i tried following code:

int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[30][2];
double lots = 0;
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber)
{
    continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
    if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
    {
        lots = OrderLots()*Lots/100;
        lots=NormalizeDouble(lots, NDigits);
         if (lots < MarketInfo(Symbol(), MODE_MINLOT))    // make sure lot is not smaller than allowed value
            lots = MarketInfo(Symbol(), MODE_MINLOT);
        bool ret = OrderClose(OrderTicket(), lots, OrderClosePrice(), 4, blue);
        if (ret == false)
        Print("OrderClose() error - ", ErrorDescription(GetLastError()));

    }
}
return;


but due to high impact news time like ECB,FOMC minutes EA not closing the partial order when +20 pips. what could be the issue?

is there any idea to rewrite my code to close the order till it executes?

Your help is appreciated. Thanks

Carl Schreiber
6586
Carl Schreiber 2015.10.22 19:42  
sheriffonline:

I would like to close my order partially 50% of lot size when it is in +20 pips.

so when order is >20 pips i tried following code:

but due to high impact news time like ECB,FOMC minutes EA not closing the partial order when +20 pips. what could be the issue?

is there any idea to rewrite my code to close the order till it executes?

Your help is appreciated. Thanks

At the moments of "high impact news time" the banks or hedge funds or .. from which your broker gets the quotes you see stop providing new quotes.
To add comments, please log in or register