- Error OrderModify 130/1 MQL4
- OrderModify Error 130 on pending orders
- Again OrderModify Error 130 and sometimes 1
Please read some other posts before posting . . .
Please edit your post or your thread will be removed . . . please use the SRC button to post code: How to use the SRC button.
Play videoPlease edit your post.
For large amounts of code, attach it.
- The == operand. - MQL4 forum
I cant use the operator != do this ?
|
---|
I should use it?
I cant use the operator != do this ?
I should use it?
The code now is:
if(OrderSymbol() == Symbol()){ profit=NormalizeDouble(OrderProfit()/OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE),0); if(TO == OP_BUY){ BuyTotalOrdersOpen++; if((profit > 100) && (TotalOrdersOpened() == 1) && (checkDoubles((OrderOpenPrice()+50*Point), OrderStopLoss(), "!=") == true)){ if(OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()+50*Point,OrderOpenPrice()+185*Point,0,Green)){// retorno da funcao OrderModify true ou false implicito. Print("StopLoss da ordem de compra modificado para 50 pontos de profit!!!" ); }else{ Print("Error: ", GetLastError()); } } } } int TotalOrdersOpened(){ int i, ticket, TO; int TotalOrdersOpen=0; for (i = 0; i < OrdersTotal(); i++){ if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){ ticket=OrderTicket(); TO=TipoOrdem(ticket); if(OrderSymbol() == Symbol()){ if(TO == OP_SELL){ TotalOrdersOpen++; } } if(OrderSymbol() == Symbol()){ if(TO == OP_BUY){ TotalOrdersOpen++; } } } } return(TotalOrdersOpen); } bool checkDoubles(double a, double b, string check){ if(check==">"){ if (a - b > Point / 2)return(1);else return (0); }else if(check=="<"){ if (b - a > Point / 2)return(1);else return (0); }else if(check==">="){ if (a - b > -Point)return(1);else return (0); }if(check=="<="){ if (b - a > -Point)return(1);else return (0); }else if(check=="!="){ if (MathAbs(a - b) > Point / 2)return(1);else return (0); }else { Print("Sorry you've entered a wrong check value"); } return (0); }
For me is the same problem yet.
You are modifying your order when it hits 100 Points profit
You are not checking to see if it has already been modified
Next tick, if profit remains at more than 100 Points, the program will try to modify the order again with the same values.
This will return the error.
Not exactly
The check below ensure that the order already been modified. And the error 130 is not about it, if you the in the table ERROR this error say: Stops are too close, or prices are ill-calculated or unnormalized ....
(checkDoubles((OrderOpenPrice()+50*Point), OrderStopLoss(), "!=") == true)
Not exactly
The check below ensure that the order already been modified. And the error 130 is not about it, if you the in the table ERROR this error say: Stops are too close, or prices are ill-calculated or unnormalized ....
Not exactly
The check below ensure that the order already been modified. And the error 130 is not about it, if you the in the table ERROR this error say: Stops are too close, or prices are ill-calculated or unnormalized ....
Sorry about that.
To be honest, with a name like checkDoubles(), I thought that it was some kind of checking normalise double function, so I didn't look too closely at it.
Especially as you wrote in your post "I changed the code removing the NormalizeDouble in the 'if' operators and put the function checkDoubles, but the error 130 continue happening."
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use