![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
C-4 In my opinion, getting operational information is much more
more interesting than history. We need to know two things about the instrument:
1. warrants.
2. Position
It seems to me that it is much more important to analyse the trades, because they are at the lowest level and you can know the orders and positions by them, but the opposite is not true. But the opposite is not true.
In your case, OnInit() is executed once at the beginning of the program. But there must be only one block of checks. It synchronizes the state of the EA with the current situation. And it doesn't matter where the new data has come to it, from the orders history at the moment of initialization, from the history at the moment of execution or from the event OnTradeTransaction. The result must be identical, because there is only one block responsible for it, too.
Vasiliy - this is a 'primitive' piece of code.
It's simple - you take an order and then work with it....
One line!
Is the OnTradeTransaction event even needed in its current form?
Mikalas:
I just noticed that the product MUST be tested (I'm testing it on MY own dime)!
i'll assume that's going off topic.
so what, you give me the magazine and the code?
i'm in the mood to help here.
It turns out that it isn't, since we still have to take information from the history.
Oh, my God! Is it valid in the history?
papaklass probably meant that OnTradeTransaction returns errors?
sergeev ->I'm in the mood to help here.
Sorry, but I don't need any help.
sergeev ->I'm in the mood to help here.
Sorry, but I don't need any help.
Vasiliy - this is a 'primitive' piece of code.
It's simple - you take an order and then work with it....
One line!
It's not a question of one line or a hundred. It's about the approach. A.k. Here's the code as an example to see what I mean. It's guaranteed to keep track of new orders coming in with or without TradeTransaction event, whether it's an initialization or a new order coming in:
That's what I'm talking about.
Why isn't this OnTradeTransaction separated into separate events:
- OnOrderCreate //issue an order;
- OnOrderModify // modification of an active order;
- OnOrderDelete //delete the order;
- OnPositionOpen //open position;
- OnPositionModify //set/modify stops, change of position volume;
- OnPositionClosed //closing a position using a Stop Loss or Market Order;
and so on.
With this approach, the trader will subscribe to and handle the events that interest him.
C-4, will be processed, of course, but why is OnRefresh() needed?
Everything is shared in OnTradeTransaction(). I have no shortage of information.