Need help on orderselect and ordermodify - MQl 4 Build 625 problem - page 2

 
GumRai:


I very much doubt it


Yes, now, we have to answer to "what are these errors ? It works before."
 
New-Trader:

Hi Traders:


I have upgraded my platform to MQl 4 Build 625, however, I am receiving the following error:

return value of 'OrderSelect' should be checked


return value of 'OrderModify' should be checked



The problem you are having is because OrderSelect is returning a bool value, and you are not checking for it.

For example,selecting an open order you would use something similar to the following.

if(OrderSelect(c,SELECT_BY_POS,MODE_TRADES)==true){ 
// some code for processing your order would go here. 
}
 

Thanks to CodeMonkey.

I have same problem as New-Trader. It was fixed now.

 

 Hmmmmm I don't understand how you read the post cited by RaptorUK and did not fix your code to reflect what he suggests there. The new compiler has a pre-compiler line at the top that says #property strict. The old programs you were using would allow for less strict, less robust, sloppier code to be used. 

When ever you select an order to do something with it and then move on to check some value of that order such as OrderProfit() or OrderOpenPrice()... you need to make sure, before you start looking for this information, that you were actually able to select an order. If you were NOT able to select one... then the code looking for parameters of a non-existing order could be problematic.

As per Raptor's excellent post, the OrderSelect() function is a boolean function. It returns true if it does select an order, and false if it does not. So, before you start asking for information, find out what the OrderSelect()  returned. Instead of simply assuming that it selected an order and then going on to ask for info... OrderSelect(); GetInfo; make it a conditional if statement. if(OrderSelect()){Go get the info;}In this way you can put in some error checking if it does NOT select and order else.... {Print("Failed to Select and order! Error #  "GetLastError();} or whatever you want it to do if something goes wrong and you did not select an order for some reason. 

The OrderSend() function is an integer and returns the ticket number of the successfully placed order... unless it did not place the order in which case it returns a -1. So it only makes sense to have some checks in place to make sure that you did actually place the order before you go any further so put the OrderSend() within an if statement to check to make sure that you did NOT receive back a -1 when attempting to place the order...

There is no better way to explain this than the post  that Raptor provided. I suggest you re-read it and APPLY what he is saying to do there. "I read the link you provided, but, no luck." Means that you either did not understand what you read or did not implement it in your code. Please read it again and I hope your luck changes ... PipPip...Jimdandy

 
Jimdandy:

 Hmmmmm I don't understand how you read the post cited by RaptorUK and did not fix your code to reflect what he suggests there. The new compiler has a pre-compiler line at the top that says #property strict. The old programs you were using would allow for less strict, less robust, sloppier code to be used. 

When ever you select an order to do something with it and then move on to check some value of that order such as OrderProfit() or OrderOpenPrice()... you need to make sure, before you start looking for this information, that you were actually able to select an order. If you were NOT able to select one... then the code looking for parameters of a non-existing order could be problematic.

As per Raptor's excellent post, the OrderSelect() function is a boolean function. It returns true if it does select an order, and false if it does not. So, before you start asking for information, find out what the OrderSelect()  returned. Instead of simply assuming that it selected an order and then going on to ask for info... OrderSelect(); GetInfo; make it a conditional if statement. if(OrderSelect()){Go get the info;}In this way you can put in some error checking if it does NOT select and order else.... {Print("Failed to Select and order! Error #  "GetLastError();} or whatever you want it to do if something goes wrong and you did not select an order for some reason. 

The OrderSend() function is an integer and returns the ticket number of the successfully placed order... unless it did not place the order in which case it returns a -1. So it only makes sense to have some checks in place to make sure that you did actually place the order before you go any further so put the OrderSend() within an if statement to check to make sure that you did NOT receive back a -1 when attempting to place the order...

There is no better way to explain this than the post  that Raptor provided. I suggest you re-read it and APPLY what he is saying to do there. "I read the link you provided, but, no luck." Means that you either did not understand what you read or did not implement it in your code. Please read it again and I hope your luck changes ... PipPip...Jimdandy

Hello, I know this is an old thread but what if the order already exist by say a previous manual trade and you want an EA to control the stop loss level.  In this case the OrderSend() function would not be called by the EA so there would be no ticket number right?  So my question is how would you find the ticket numbers of existing orders to modify stop losses? I'm working on an EA and trying to make this work.  I do not want to share my code because my indicator is private until it is finished.  Thank you in advance for any assistance.  I much need help.  Best regards, Neal

 
Neal_Van:

Hello, I know this is an old thread but what if the order already exist by say a previous manual trade and you want an EA to control the stop loss level.  In this case the OrderSend() function would not be called by the EA so there would be no ticket number right?  So my question is how would you find the ticket numbers of existing orders to modify stop losses? I'm working on an EA and trying to make this work.  I do not want to share my code because my indicator is private until it is finished.  Thank you in advance for any assistance.  I much need help.  Best regards, Neal

Manual Orders have a MagicNumber of 0. So, you would loop through the "OrdersTotal()", selecting each one with "OrderSelect()", and testing "if( OrderMagicNumber() == 0 )".

 

Just noticing what lovely, helpful, friendly people you are. I thought this forum was meant for helping people, I`m learning mql4 at the moment but this lot on here and your general attitude puts me off ever asking a question. 

 

hello!

I think the problem with: "return value of 'OrderModify' should be checked" can be solved with this ex: 

bool result=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),newtp,0,Red);

Good luck!

 
Ricardo CarvalhoI think the problem with: "return value of 'OrderModify' should be checked" can be solved with this ex: 
bool result=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),newtp,0,Red);
That doesn't solve anything. All it does is hide the warning. If the modify fails, don't you want to know about it? Check your return codes and find out why.