Problem with OrderModify on FXCM: Ordermodify not accepted

 

Hi,

I am using FXCM Demo Account. By browsing the forums I found that for FXCM we cannot set stoploss and takeprofit using OrderSend().

Therefore, I used a combination of OrderSend and OrderModify. But the problem is that on my EA, OrderModify seems to work only for once or twice after that, OrderModify is not accepted at all.

The following is the code I am using for this...

*******************************************************

int error = OrderSend(Symbol(),OP_BUY,LOTS,s_open,0,0,0,"My Order",23450,0,Green);

if (error<0)
{
Alert("Error :",GetLastError());
}
else
{
status = false;
while(status==False)
{
OrderSelect(error,SELECT_BY_TICKET);
status = OrderModify(error,0,takeprofit,stoploss,0,Blue);
if (status==true)
{
Alert("Order Modified!");
}
else
{
Alert("Order not modified!");
Sleep(2000);
}
}
}

**************************************************************

For this, I always get the Alert o/p as "Order not modified!"

Can you please help me on this?

Thanks,

Bull

 

FXCM have a lot of 'issues' with their bridge... This sounds like one of them. I suggest you get help on their support forums -> http://forexforums.dailyfx.com/mt4/.

And next time:

 

Also, try using GetLastError() to find out what the problem is.

 

Please, show how you calculate "takeprofit" and"stoploss".

status = OrderModify(error,0,takeprofit,stoploss,0,Blue);
 

Price can't be 0, must be OrderOpenPrice().

 
  1. Price can't be 0, must be OrderOpenPrice().
  2. Also takeprofit/stoploss can not be closer to the current price than MarketInfo( Symbol(), MODE_STOPLEVEL )*Point. On IBFX that's 3 pips, 30 points.

    That is closer than the current price, not the open price. Add a RefreshRates() between all server calls (orderSend, refresh, adjust tp/sl if necessary, orderModify)


  3. For readability I use things like

    #define NO_EXPIRATION 0
    if (!OrderModify( ..., NO_EXPIRATION, Clr )){ Alert(...
    
    and
    #define WINDOW_MAIN 0
    if (!ObjectCreate( TKcRect, OBJ_RECTANGLE, WINDOW_MAIN,...
 

Thanks for your replies.

I had been concentrating on my job as I had to travel. I will look into all the suggestions posted here.

Bull

Reason: