int ticket_select = OrderSelect (cnt, SELECT_BY_POS); //ORDER SELECTED if ( OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == buy_magic_number )
But then,
if (OrderType() == OP_BUY)
{
You can not have OP_BUY and OP_SELL at the same time Mohammad.
so
if(OrderType()==OP_BUY) { //do something } else if(OrderType()==OP_SELL) { //do something else }
But then,
You can not have OP_BUY and OP_SELL at the same time Mohammad.
no my friend
you are not correct
I know what you mean
the first OP_SELL means the executed orders not the pending because in the mql table they are giving the OP_SELL value
ID | Value | Description |
OP_BUY | 0 | Buy operation |
OP_SELL | 1 | Sell operation |
OP_BUYLIMIT | 2 | Buy limit pending order |
OP_SELLLIMIT | 3 | Sell limit pending order |
OP_BUYSTOP | 4 | Buy stop pending order |
OP_SELLSTOP | 5 | Sell stop pending order |
thanks for your try
It filters for sell orders only.
if ( OrderType() <= OP_SELL
This litterally filters if Ordertype is <= smaller or == equal to OP_SELL.
From this moment on
if (OrderType() == OP_BUY) { if (BreakEvenStart > 0 && BreakEven) { int ticket_modify = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+(BreakEvenValue*trade_point), OrderTakeProfit(), 0, modify_arrow_color);Only BUY orders are handled so show the value of
trade_point
It filters for sell orders only.
This litterally filters if Ordertype is <= smaller or == equal to OP_SELL.
From this moment on
int OnInit() { if(Digits==3 || Digits==5) trade_point=Point*10; //--- return(INIT_SUCCEEDED); }
BreakEvenValue
I think that I found it
have been added the RefreshRates() then every think is ok
Thanks again Marco
for (int cnt3 = 0; cnt3 < OrdersTotal(); cnt3++) { int ticket_select = OrderSelect (cnt3, SELECT_BY_POS); RefreshRates(); if ( OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == buy_magic_number ) { if (OrderType() == OP_BUY) { if (BreakEvenStart > 0 && BreakEven) { int ticket_modify = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+(BreakEvenValue*trade_point), OrderTakeProfit(), 0, modify_arrow_color); if(!ticket_modify)Alert("Break Even: Order cannot be modified, ", ErrorDescription(GetLastError())); else Print("Break Even Placed Successfuly."); } } } }
I think that I found it
have been added the RefreshRates() then every think is ok
Thanks again Marco
Just by chance, RefreshRates() is useless in this code.
so, what is the perfect solution???
if(!ticket_modify)Print("Break Even: Order cannot be modified, ", GetLastError());In general you need to follow these rules when setting stoploss/takeprofit.
- book.mql4.com
Just by chance, RefreshRates() is useless in this code.
Hello Mr Alain,
yes
you are right
that was just a chance, I have tried the same in another broker with the error invalid stops!!!
what is the correction?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello community
I have always one problem
the error 130 MT4
error description: invalid stops
in the function below, if I call it then the error continuously will appear
also if I place it inside the OnTick() same error 130 will come again
so, why the error is coming by calling as a function
does the RefreshRates() help????