Anybody know why the error appear??

 

Hi All,


Anybody know why the error appear??

codes:

      
       int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,0,0,comment,MagicNumber,0,Blue);
       if(ticket>0) 
       {
          OrderSelect(ticket,SELECT_BY_TICKET);
          Alert(OrderOpenPrice(),"   ",StopLoss,"   ",Point,"   ",OrderOpenPrice()-StopLoss*Point);
          if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point,OrderTakeProfit(),0,0))
          { 
             return(0);
          }
       }

Log file:

01:03:51 2009.10.05 12:00  EA GBPUSD,H1: open #1 buy 0.10 GBPUSD at 1.5954 ok
01:03:51 2009.10.05 12:00  EA GBPUSD,H1: Alert: 1.5954   30   0.0001   1.5984
01:03:51 2009.10.05 12:00  EA GBPUSD,H1: OrderModify error 130
01:04:00 2009.10.05 13:00  EA GBPUSD,H1: close #1 buy 0.10 GBPUSD at 1.5954 at price 1.5924

why 1.5954 minus 30 pips = 1.5984 ???


This slowly lead me to headache.. anybody can help?


Thank you

 
is your StopLoss negative ?
 
meikel:
is your StopLoss negative ?

Nope, you can see my alert code above

Alert(OrderOpenPrice(),"   ",StopLoss,"   ",Point,"   ",OrderOpenPrice()-StopLoss*Point);

and the result is:

01:03:51 2009.10.05 12:00  EA GBPUSD,H1: Alert: 1.5954   30   0.0001   1.5984


Any thought??

I'm using IBFx MT4 v225

 

this is the complete function

void openbuy()
{
    int ticket;
    //if the broker is NOT ECN
    if(!IsECNBroker)
    {
       RefreshRates();
       ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,Ask-StopLoss*Point,0,comment,MagicNumber,0,Blue);
       if(ticket>0) 
       {
          return(0);
       }
       else Alert("Error "+GetLastError()+" on opening a new order on "+Symbol()+" ("+per+")");
    }
    //if the broker is ECN
    if(IsECNBroker)
    {
       RefreshRates();
       ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,0,0,comment,MagicNumber,0,Blue);
       if(ticket>0) 
       {
          OrderSelect(ticket,SELECT_BY_TICKET);
          Alert(OrderOpenPrice(),"   ",StopLoss,"   ",Point,"   ",OrderOpenPrice()-StopLoss*Point);
          if(OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point,OrderTakeProfit(),0,0))
          { 
             return(0);
          }
       }
       else Alert("Error "+GetLastError()+" on opening a new order on "+Symbol()+" ("+per+")");
    }
}


and if IsECNBroker=false, it's working fine.

 
devilian1899:

Nope, you can see my alert code above

and the result is:


Any thought??

I'm using IBFx MT4 v225

yes you are right - i should have noticed that - my god, i am getting dumber every day ...

i have no answer - but i have noticed that MT4 behaves strange sometimes.

i know that i write some bugs, and i am used to detect them and correct them. but some things in MQ4 are really strange...

i write perl,php and sometimes c-code and debug them all by myself, but MQ4 behaves sometimes very strange.

i workaround this issues, but it looks like as is there a little amount of bugs in the compiler at the moment to me.


maybe i am wrong....

sorry, cant help you at the moment - i think about this issue...

 
Yeah it is true. MQ4 is such a mess of bugs
 
meikel:

yes you are right - i should have noticed that - my god, i am getting dumber every day ...

i have no answer - but i have noticed that MT4 behaves strange sometimes.

i know that i write some bugs, and i am used to detect them and correct them. but some things in MQ4 are really strange...

i write perl,php and sometimes c-code and debug them all by myself, but MQ4 behaves sometimes very strange.

i workaround this issues, but it looks like as is there a little amount of bugs in the compiler at the moment to me.


maybe i am wrong....

sorry, cant help you at the moment - i think about this issue...


No problem with that, we slip on someting sometimes. Thanks for your response, please let me know if you think about something.


Meanwhile, it looks like an MQL4 bug rather than code bug..

 
I didn't find any problem with your function
2009.11.15 19:56:46 test GBPUSD,M5: modify #59322317 buy 0.10 GBPUSD at 1.67049 sl: 1.66749 tp: 0.00000 ok
2009.11.15 19:56:44 test GBPUSD,M5: 1.6705 300 0 1.6675
2009.11.15 19:56:44 test GBPUSD,M5: open #59322317 buy 0.10 GBPUSD at 1.67049 ok
 

Thank you. I do believe the code is correct, and I'm not too surprise if the code is working on other terminal. But what's wrong with mine??


btw, why the "Point" on your log = 0?

2009.11.15 19:56:44 test GBPUSD,M5: 1.6705 300 0 1.6675
 

try setting your SL to 3


mt4 has many bugs and brokers mod mt4 and then things dont work so well .....

 
devilian1899 wrote >>

btw, why the "Point" on your log = 0?

It's because my broker has 5 digits and I didn't correct it for printing, oops.

Reason: