OrderSend working in one platform and not working in another

 

hi, i created an EA and made it run in 2 different metatrader platforms, one in hotforex, and another in ironfx. The below code works in ironfx and doesn't work in hotforex whereas both platforms are 5 decimal.

    double SL = Ask - BuyStoploss7*PipValue*Point;
    if (BuyStoploss7 == 0) SL = 0;
    double TP = Ask + BuyTakeprofit7*PipValue*Point;
    if (BuyTakeprofit7 == 0) TP = 0;
    int ticket = -1;
    if (true)
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots7, Ask, 2, SL, TP, "My Expert", 1, 0, Blue);
    if (ticket > -1)
    {
        if (false)
        {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
         }
     }

Please can someone tell me what might be the problem??

 
kmnatarajan:

Please can someone tell me what might be the problem??

Yes, one Broker is an ECN Broker and the other isn't. ECN

What is . . . .

if (false)

. . . supposed to do ?

false is always false . . . i.e. never true

The code in the { } will never be executed . . .

What error do you get back when your OrderSend fails ? oh of course . . . you don't check. ALWAYS test return values and report errors when there is a problem . . . .

 
    double SL = Ask - BuyStoploss7*PipValue*Point;
    if (BuyStoploss7 == 0) SL = 0;
    double TP = Ask + BuyTakeprofit7*PipValue*Point;
    if (BuyTakeprofit7 == 0) TP = 0;
    int ticket;
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots7, Ask, 2, 0, 0, "My Expert", 1, 0, Blue);
    if (ticket > 0)
       {
       OrderSelect(ticket, SELECT_BY_TICKET);
       bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
       if (ret == false)
       Print("OrderModify() error - ", ErrorDescription(GetLastError()));
       }
Code it like that :)
 
onewithzachy:
Code it like that :)

But also report the error if the OrderSend() has failed . . .

double SL = Ask - BuyStoploss7*PipValue*Point;
    if (BuyStoploss7 == 0) SL = 0;
    double TP = Ask + BuyTakeprofit7*PipValue*Point;
    if (BuyTakeprofit7 == 0) TP = 0;
    int ticket;
    ticket = OrderSend(Symbol(), OP_BUY, BuyLots7, Ask, 2, 0, 0, "My Expert", 1, 0, Blue);
    if (ticket >= 0)
       {
       OrderSelect(ticket, SELECT_BY_TICKET);
       bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
       if (ret == false)
       Print("OrderModify() error - ", ErrorDescription(GetLastError()));
       }
    else
       {
       Print("OrderSend() error - ", ErrorDescription(GetLastError()));
       }
 
RaptorUK:

But also report the error if the OrderSend() has failed . . .

Dear RaptorUK, ...

OrderSend()

... never return zero, either -1 or > 0

If it is return zero then it is fail ...

:)

 
onewithzachy:

Dear RaptorUK, ...

... never return zero, either -1 or > 0

If it is return zero then it is fail ...

:)

Ah yes, I was thinking about the Strategy Tester, but the first ticket is 1 not 0 . . . but a fail returns -1 not 0 ;-) 0 is probably not a valid return value.
 
oops my bad, in future i will report the error numbers, and thanks guys for the replies....
Reason: