You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
it doesn't matter what you think about how to write code, the main thing is that the code works correctly, instead of bringing your code and asking where you're going wrong... once again, there is no 4105 error if the ticket is correct
What you say is untrue, because error 4105 occurs when calling functions which do not need to pass the ticket to.
For example, when OrderTicket() is called if OrderSelect() was not called before OrderTicket() was called - this is the situation discussed in this thread.
No, what I meant was a guaranteed selection of my order for each of the functions regardless of the transitions (outputs) to the outside.
i.e. saving the last selected order for each function of your
No, what I meant was a guaranteed selection of my order for each of the functions regardless of the transitions (outputs) to the outside.
i.e. saving the last selected order for each function as its own
If there are several nested functions with control of the last order selected - i.e. one function calls another and the other calls a third, then each function will keep the order selection at the moment it is called and return the selection to that state on return, if I understood the question correctly. But this is a really tricky solution. Usually more than one level of nesting is unlikely. The main thing is to control the environment of each such function, so that a call of this function will not cause logical errors due to resetting of a previous order selection. This is only needed for service functions that can be called from the main loop of order retrieval and still retrieve the orders themselves in order to calculate anything.
By the way, it seems that if the service function is in the library - then there is no need to save the "pointer"(order selection), is there? Since the main EA and the library have their own "pointer", i.e. an order selected in the library will not be selected in the EA and vice versa.
This seems like a perfect solution to the problem if both functions A and B are not located within the same module
Ideology: to have an order selection function (one for everyone) with the necessary filters outside (anyway, in each function you have to select this order somewhere (most likely at the beginning))
which will surely return the ticket of the previously picked order (in this function), or else do a new search with the filters we have specified
In this case, the ticket = OrdersTicket(); construction will work perfectly.
What you say is untrue, because error 4105 occurs when calling functions which do not need to pass the ticket to.
For example, when OrderTicket() is called if OrderSelect() was not called before OrderTicket() was called - this is the situation discussed in this thread.
where do you get the ticket from EA settings, external file - where from ?
if so, then yes, there will be an error, because the fact of OrderSelect() call remains at start on next ticks (at least in the tester),...
By the way, it seems that if the service function is in the library - then there is no need to save the "pointer" (order selection), is there? Since the main EA and the library have their own "pointer", i.e. an order selected in the library will not be selected in the EA and vice versa.
This seems like a perfect solution to the problem if both functions A and B are not located within the same module
It all depends on the degree of globality of the external variable.
By the way, it seems that if the service function is in the library - then there is no need to save the "pointer" (order selection), is there? Since the main EA and the library have their own "pointer", i.e. an order selected in the library will not be selected in the EA and vice versa.
This seems like a perfect solution to the problem if both functions A and B are not located within the same module
I'll pass. I can't help you with anything else. Round and round without me!!!
It all depends on how global the external variable is.
Specifically, the "pointer" - the state of the currentorder selection - is global within the module, i.e. this pointer is the same for the library and different for the program module. This means that if function A in the program selects some order in the loop and then calls the auxiliary function B from the library, then even if during its operation B selects another order, the order selection in function A should not be changed upon the return. But if both functions are located within a module, when returning from B, the current order selection should be stored and restored either before and after B is called in A itself or in B at the start and upon completion of its work so that the logic of A's work is not violated at that point.