Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1111
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 is practically one line of code. But we need to get a position ticket for it. Here is an Expert Advisor from OnInit that opens position with 0.2 lot and closes half of it with OnTick.
Or here is the full code from the CTrade class
Thank you!
Go here to the Articles section and browse - there's a lot on OOP, including for beginners.
Not claiming anything. But why not where to read ....
Global and local variables. The choice of variable visibility declaration is determined by the need to use the values of the function variables in other functions and of course in the ontic advisor. That is, if the function only needs the value passed to it, it is correct to declare all variables of the function as local. If the function is calculating, and the variables, to which the results of calculation are assigned, are used in other functions, these variables must be declared on the global level.
The same goes for classes and the visibility level of variables, functions, methods. If first, we define what we want from the class, which functions, variables, structures and we declare them as public. If the class members are only used inside the class, we declare them private or protected, depending on whether we want inheritance.
Reading the manual, you get the impression that you are being told about properties of something and how to use it, guess for yourself...
In general, the idea is that if the manual was more clearly explained, the language would be learned faster, and without additional articles. I can't do without it (of course, I'm talking about me only)). ). Kudos to the authors of the articles.
Does MQL have an analogue of try, catch and throw from C++?
Greetings. Can you advise me please?
I have an indicator that creates objects on a chart, and an EA that works on those objects, (by going through their list).
But the EA only detects the objects on the next tick after they have been created.
Is it possible that the EA can detect objects on the same tick when they are created?
Greetings. Can you advise me please?
I have an indicator that creates objects on a chart, and an EA that works on those objects, (by going through their list).
But the EA only detects the objects on the next tick after they have been created.
Is it possible that the EA can detect objects on the same tick when they are created?
It is possible to transfer an indicator algorithm to an EA. Such indicators, which do not have buffers, are much easier to transfer to an EA.
It is possible to transfer an indicator algorithm to an EA. Such indicators, which have no buffers, are much easier to transfer to an EA.
This is understandable, but so far this is the question.
At the same time, if I print messages from the indicator and EA, then the first one comes from the indicator.
AlsoChartRedraw(0); both at the end of the indicator and at the beginning of the EA have not helped.
That's understandable, but for now that's the question.
"Such" as what? How do you imagine reading something not yet written or seeing something not yet drawn?
"Such", is it what? How do you imagine reading something not yet written or seeing something not yet drawn?
"read" on the same tick, but after drawing is possible?
"Such", what is it? "For the Expert Advisor to work with objects
I will try it viaOnChartEvent
"read" on the same tick, but after drawing is it possible?
"Such", what is it? " - for the EA to work on the objects.I'll try using OnChartEvent
In OnChartEvent you also need to know the exact name of the object. And there isn't one until there is no object itself.