Hi,
So the selection of the orders is invalid :
4051 |
ERR_INVALID_FUNCTION_PARAMVALUE |
Invalid function parameter
value |
It would be in this way :
Thanks for the response Mehrdad
But apart from the inversion it appears to be the same function arrangement as my original post , I must be missing the point , could you explain the shortcomings of my effort
Regards
Will
Do not duplicate topics
Your other topics have been deleted.
Thanks for the response Mehrdad
But apart from the inversion it appears to be the same function arrangement as my original post , I must be missing the point , could you explain the shortcomings of my effort
Regards
Will
So if you dont have any order,then the selection of order by zero value is invalid,
In loop statement the OrdersTotal will be checked of there is not any opened order.
So if you dont have any order,then the selection of order by zero value is invalid,
In loop statement the OrdersTotal will be checked of there is not any opened order.
Hi Mehrdad
I am just using it to check if I have any active open trades, no loops, if there is a trade it will be in position 0 and the switch instigates a return if there is no trade open the switch will not return and proceed through the code.
I can't see how the parameters are incorrect, btw the switch does function correctly i.e. returns when trade present otherwise proceeds' to next line. However, it always generates Error 4051.
Currently I just use ResetLastError() to clear.
Regards
Will
Hi Mehrdad
I am just using it to check if I have any active open trades, no loops, if there is a trade it will be in position 0 and the switch instigates a return if there is no trade open the switch will not return and proceed through the code.
I can't see how the parameters are incorrect, btw the switch does function correctly i.e. returns when trade present otherwise proceeds' to next line. However, it always generates Error 4051.
Currently I just use ResetLastError() to clear.
Regards
Will
This is not a good way to use OrderSelect at all... This will guarantee that you will only be able to ever run only one EA on only one chart per account. Not good. Furthermore, if you're just mucking around with the strategy tester and want to take the easy way out then just use orderstotal because it does the exact same thing without generating errors and arbitrarily (inefficiently) selecting orders behind the scenes.
if (OrdersTotal()) return;
Hi Mehrdad
I am just using it to check if I have any active open trades, no loops, if there is a trade it will be in position 0 and the switch instigates a return if there is no trade open the switch will not return and proceed through the code.
I can't see how the parameters are incorrect, btw the switch does function correctly i.e. returns when trade present otherwise proceeds' to next line. However, it always generates Error 4051.
Currently I just use ResetLastError() to clear.
Regards
Will
So maybe the error is from another function that has invalid input,
So provide the full code that i check it better.
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))return;I can just use GetLastError to clear but in an attempt to learn more about MQL4 I would like to understand why it is generated.
- If there are open or pending orders, the OrderSelect selects it, and returns true. Then the if then calls return. Below that line there will always be an error, because no order has been selected.
Perhaps you meant to write:
if(!OrderSelect(0,SELECT_BY_POS,MODE_TRADES))return;
-
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual
trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Could someone help me with a frustrating problem ?
When I use the following command it works perfectly as a switch but always generates Error 4051.
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))return;
I can just use GetLastError to clear but in an attempt to learn more about MQL4 I would like to understand why it is generated.
Kind Regards to all.
William