OrderModify Error 0, Error Description = no error

 

When I modify my stop loss of an open order, I get this weird Error number 0 with the error description "no error". My result is a FALSE and I cannot understand why.


Here is what I am trying to do:


At + 50 pips, update the stop loss price to my trade's open price. I do not know why this would cause it to return a FALSE. I can verify that my values are correct.

 

One usual cause is where you OrderModify (for example to move a trailing stop) but actually send unchanged values

FWIW

-BB-

 
How do you mean by "unchanged values"?
 
Due to a logic error in your code, the 'new' SL & TP values are in fact the same as the old ones!
 
When I modify my order's stop loss, must the take profit be changed? I am only want to update my stop loss and not the take profit value.
 

you only need change at least one order datum. but must be acceptable value...

best bet is OrderSelect() ticket u want modify. then u can use already in order values that not want change:

eg, OrderModify(ticket,OrderOpenPrice(),aNewSLprice,OrderTakeProfit(),OrderExpiration());

.

these thots below help also?

stoploss must be minimum distance from current price. MarketInfo(symbolName,MODE_STOPLEVEL) gives minimum distance from current price.

btw, BarrowBoy say elsewhere and is about brokers that use sub-pip pricing.

my broker is one of them.

if i use MarketInfo() call above for GBPUSD i print to log this: MarketInfo GBPUSD,H1: MODE_SPREAD=30

see 30? that is really 3 and zero is tenths pip

so this means i must "times 10" values put into trade ops calls. also Print(a double identifier) defaults to four digits only - not good - loose last digit eg, 1.12345 prints as 1.1234 unless use DoubleToStr(a double identifier,Digits) - or even just put in digit value of 8, the max width. my broker gives Digits as 5 and Point as 0.00001 for nonJPY and 3,0.001 for JPY pairs.

ideas... maybe help :)

u maybe use Print() statement and see what u sending in trade ops calls, can better figure out why system not like trade op calls

Best

 
Sometimes my stop loss gets updated, sometimes not. 50 pips away from the current price should be more than enough.
 

u say your values are correct.

well, 4 sure system is not happy - so... it appears values may seem correct to u but not system.

suggest u show code, this english talk talk is not code - is not precise, code IS precise and is true||false and regardless wat u or i or others 'say', code is only real thing that talks.

this not issue that should consume much time - please show code - all code... so we can finally say ok... we not know or - here it is, u must do this sort of thing to stop issue.

Best

 
fbj:

u say your values are correct.

well, 4 sure system is not happy - so... it appears values may seem correct to u but not system.

suggest u show code, this english talk talk is not code - is not precise, code IS precise and is true||false and regardless wat u or i or others 'say', code is only real thing that talks.

this not issue that should consume much time - please show code - all code... so we can finally say ok... we not know or - here it is, u must do this sort of thing to stop issue.

Best

if anybody is still looking at this post I have the same error code = 0 when running my EA on GBPUSD at an ECN broker.

Here is my code so that maybe you can find what is wrong with it:

for(i=1; i<=OrdersTotal(); i++) // Cycle searching in orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
{ // Analysis of orders:
int Tipo=OrderType(); // Order type
if(OrderSymbol()!=Symb||Tipo>1)continue; // The order is not "ours"
SL=OrderStopLoss(); // SL of the selected order
//---------------------------------------------------------------------- 3 --
while(true) // Modification cycle
{
//double TS=Trail_Stop; // Initial value
double TS=NormalizeDouble(Trail_Stop*StopMultd,Digits); //I prefer using Normalize values
int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL); //Min. distance
if (TS < Min_Dist) // If less than allowed
TS=Min_Dist; // New value of TS
//------------------------------------------------------------------- 4 --
bool Modify=false; // Not to be modified
switch(Tipo) // By order type
{
case 0 : // Order Buy
if (NormalizeDouble(SL,Digits)<
NormalizeDouble(Bid-TS*Point,Digits)) // If it is lower than we want
{
SL=Bid-TS*Point; // then modify it
string Text=" Buy "; // Text for Buy
Modify=true; // To be modified
}
break; // Exit 'switch'
case 1 : // Order Sell
if (NormalizeDouble(SL,Digits)>
NormalizeDouble(Ask+TS*Point,Digits) // If it is higher than we want
|| NormalizeDouble(SL,Digits)==0) //or equal to zero
{
SL=Ask+TS*Point; // then modify it
Text=" Sell "; // Text for Sell
Modify=true; // To be modified
}
} // End of 'switch'
if (Modify==false) // If it is not modified
break; // Exit 'while'
//------------------------------------------------------------------- 5 --
TP =OrderTakeProfit(); // TP of the selected order
double Price =OrderOpenPrice(); // Price of the selected order
int Ticket=OrderTicket(); // Ticket of the selected order

Alert ("Modification to",Text,"#",Ticket," - Awaiting response..");
bool Ans=OrderModify(Ticket,Price,SL,TP,0); //Modify it!



I think this line is where the problem is:

double TS=NormalizeDouble(Trail_Stop*StopMultd,Digits); //I changed the original code that I found at the forum with Normalize values

The StopMultd value is 10 because I use an ECN broker. My Trail_Stop value is for example 15 pips, but in order to translate it to a 5 digit broker I have to multiply it by 10 and then use Digits to covert it to a 5 digit broker.

Any suggestions here?

 
Please edit and use SRC. Can't really see the code properly right now.
 
deysmacro:
Please edit and use SRC. Can't really see the code properly right now.

sorry, what do you mean by use SRC? I have tried to copy the code lines to word but it doesn't help either.
Reason: