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

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
Moderator
3206
angevoyageur 2014.03.24 16:24 #
 
GumRai:


I very much doubt it


Yes, now, we have to answer to "what are these errors ? It works before."
avatar
118
CodeMonkey 2014.03.25 18:57 #
 
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. 
}

avatar
1
demibara 2015.01.06 16:11 #
 

Thanks to CodeMonkey.

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

avatar
118
Jimdandy 2015.01.06 21:39 #
 

 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

avatar
63
Neal_Van 2016.05.18 08:26 #
 
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

 

avatar
1218
FMIC 2016.05.18 10:48 #
 
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 )".

avatar
1
amlittlehales 2016.09.09 14:48 #
 

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. 

 

Back to topics list   | 1 2  

To add comments, please log in or register