Discussion of article "Library for easy and quick development of MetaTrader programs (part X): Compatibility with MQL4 - Events of opening a position and activating pending orders" - page 3
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
Artem, please tell me what role the highlighted code section plays.
How can this code be executed if the timer is not enabled?
But if this code section is deleted, the event messages are not printed. But everything works with it.
And I would like to be able to get a ticket, prices and maybe some other properties of positions and orders along with the event message.
I think you have changed the comment. In OnTimer() the EA is tested not in the tester:
And compare the two handlers: in OnTick() the library timer is started only in the tester, and in OnTimer() the library timer is started only not in the tester - because in MQL4 the timer does not work in the tester, and we work on ticks in the tester.
I will make an example now.
I think you changed the comment.
The comment changed on its own, I didn't touch it.))))))
I just copied in one place and pasted in different places and didn't pay attention. But then put a negation in the form of ! and not important did not touch.
But the question remains unanswered: If the timer is not started in OnInit(), what is the point of the OnTimer() handler and why the code in it is executed at least once.
Basically, I got the messages to the log. It remains to get the properties of the items. Type, ticket, prices and time of opening, closing, modification.
And I would like to be able to get ticket, prices and maybe some other properties of positions and orders along with the event message.
Not in the tester you can get the order ticket of the last event in OnChartEvent() - parameter lparam. In dparam the price is stored. In sparam - symbol.
To get data in the tester, you should currently use the event code that you get with engine.LastTradeEvent() - because everything depends on the event - if it is a modification, you need to get a list of modifications, and if it is a change in the number of orders, you need to get lists of these new orders.
We need to add in CEngine to return the necessary values to the programme. I have not yet got to the point of sending information to the programme - I am still describing the preparation of the necessary data. In future articles we will reach the class that gives easy access to all the necessary data. And now - if you need it urgently, you need to add to CEngine the return of the list from the class-collection of events - the class itself has the receipt of this list, here they are - all the lists in the public section CEventCollection:
All events are stored in the m_list_events list, and these methods return either the full list or filtered by a given criterion.
To get the last event it is enough to create in CEngine the return of this list to the programme, and in the programme to take the required event from the list.
All of this will be automated soon - it's not in the queue yet.
If you still need to make a crutch, its discussion - in a private. It's not worth it here - it doesn't apply to the library, as it's under development, and further normal and proper work will be done to get all and any required events in the programme.
The comment changed on its own, I didn't touch it.)))))
I just copied in one place and pasted in different places and did not pay attention. But then I put a negation in the form of ! and did not touch the important one.
But the question remains unanswered: If the timer is not started in OnInit(), what is the point of the OnTimer() handler and why the code in it is executed at least once.
Basically, I got the messages to the log. It remains to get the properties of the items. Type, ticket, prices and time of opening, closing, modification.
Explain what do you mean? Are you talking about creating a timer? It is created in the CEngine constructor:
Not in the tester you can get the order ticket of the last event in OnChartEvent() - parameter lparam. In dparam the price is stored. In sparam - symbol.
I have already found it, thank you. And by getting a ticket you can get everything you need. Except from what price there was a modification. Or make a real crutch to know the price before modification. In principle it is not very necessary yet.
Basically I got the log messages. I just need to get the properties of the positions. Type, ticket, prices and time of opening, closing, modification.
However, for a quick solution, add an event list return to the public section of CEngine:
In the EA, add this code:
And the last event will be printed in the log
Explain what do you mean? Are you talking about creating a timer? It is created in the CEngine constructor:
Well, you had to go through the whole library for that. )))
I already found that, thank you. And if you get a ticket, you can get everything you need. Except for the price of the modification. Or make a real crutch to know the price before modification. I don't really need it yet.
I've already given you the code - there is everything there, and the price before modification too.
Well, you had to go through the whole library for that. )))
No. Just read the articles
And this is what happened:
While I was running this code on the demo, a limit order was set and deleted
And suddenly, during the next mocking, one position was modified, one position was opened and one position was closed. But where did the record of deleting a long deleted order come from?