Invalid Function Parameter value

 

Hi,

I am getting Invalid Function Parameter Value at below line in my EA.

OrderClose( OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID),5), 15, CLR_NONE );

Can somebody highlight the problem in above statement. thanks in advance.

 

santoshh,


your function call seems to be correct. I tried to compile exactly same line by myself it worked. Only issue you may have is that OrderTicket(),OrderLots() return invalid parameter. You have to use such functions after OrderSElect.


Example:

for (i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i,SELECT_BY_POS))
{
if (OrderMagicNumber()==MYMAGIC)
{


regards



bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE)
Closes opened order. If the function succeeds, the return value is true. If the function fails, the return value is false. To get the detailed error information, call GetLastError().
Parameters:
ticket - Unique number of the order ticket.
lots - Number of lots.
price - Preferred closing price.
slippage - Value of the maximum price slippage in points.
Color - Color of the closing arrow on the chart. If the parameter is missing or has CLR_NONE value closing arrow will not be drawn on the chart.
 

Either you're missing an orderSelect, the order is a sell (close at the ask,) or you haven't adjust slippage (15) for 5 digit broker.

NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID),5) is unnecessary, Bid/Ask is Always normallized and correct as is.

For closing you can also always use OrderClosePrice() for either direction.