Error 130 on OrderModify

Back to topics list To post a new topic, please log in or register
avatar
14
filipefr 2015.10.05 13:45
 

I'm trying to modify an Order, but I always get Error #130.

How can I fix my OrderModify() function?

    double stoploss = NormalizeDouble(Ask - Point * TrailingStop,Digits);
    int ticket;
    double takeprofit = NormalizeDouble(Ask + Point * TrailingStopTP,Digits);
    double minstoplevel = MarketInfo( Symbol(), MODE_STOPLEVEL );
    if(stoploss > NormalizeDouble(Ask - Point*minstoplevel,Digits)) {
        stoploss = NormalizeDouble(Ask - Point*minstoplevel,Digits);
    }
    if(takeprofit < NormalizeDouble( Ask + Point*minstoplevel2, Digits )) {
        takeprofit = NormalizeDouble( Ask + Point*minstoplevel2, Digits );
    }
    if(AccountFreeMarginCheck(Symbol(),OP_SELL,lotsize)>0) {
        ticket=OrderSend(Symbol(),OP_BUY,lotsize,Ask, 0, 0.0, 0.0, "comment", MagicNumber, 0, Lime);
        if(ticket<0) {
            Print("Order send failed with error #",GetLastError());       
        } else {
            Print("Order send sucesso!! Ticket#", ticket);
            res=OrderModify(ticket,OrderOpenPrice(),stoploss,takeprofit,0,Blue);
            if(res==false) {
                Print("Error modifying order!, error#",GetLastError());
            } else {
                Print("Order modified successfully, res#", res);
            }            
        }
    } else {
        Print("Sem dinheiro na conta D=");
    }
 }

avatar
Moderator
3427
GumRai 2015.10.05 14:04 #
 
if(stoploss > NormalizeDouble(Ask - Point*minstoplevel,Digits)) {

Stop loss and Take profit will be Bid for a buy, not ask

            res=OrderModify(ticket,OrderOpenPrice(),stoploss,takeprofit,0,Blue);

 You don't select the order, so OrderOpenPrice() could be anything

 

Back to topics list  

To add comments, please log in or register