Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1250
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
Thank you. In mql5 no such labyrinths were built. Instead of going straight to the goal, you have to take some detours, go through a lot of dead ends and obstacles. A language for the sake of a language.
In MQL4 you also set a magik for a position.
Here you have decided to use a trade object from SB. This means that during its creation and initialization you need to set its parameters. And then you just use it for trading functions. There may be many such objects, and you will set different parameters for each one. And then - apply to the necessary object for management of trade orders on those symbols and magic signs that have been set for each particular object, and which are needed at different moments depending on the TS.
It's as simple as that.
In MQL4, you also set a magik for a position.
Here you have decided to use a trade object from SB. This means that when you create and initialize it, you need to set its parameters. And then you just use it for trading functions. There may be many such objects, and you will set different parameters for each one. And then - apply to the necessary object for management of trade orders on those symbols and magic signs that have been set for each particular object, and which are needed at different moments depending on the TS.
It's as simple as that.
Hello. Thank you for your reply. I will give my point of view. When opening an order in MQL4, we specify its parameters including a magik. In #include <Trade\OrderInfo.mqh>, everything except the magik is specified. For example - CTrade::BuyLimit(const double volume,const double price,const string symbol=NULL,const double sl=0.0,const double tp=0.0,const ENUM_ORDER_TYPE_TIME type_time=ORDER_TIME_GTC,const datetime expiration=0,const string comment=""). In my opinion, this is not a fix and we should fix it by introducing another magician parameter. Or, #include <Trade\ HistoryOrderInfo.mqh> contains everything except the profit (profit/loss) taken by the order. This is important information about the order and it is missing. We need to find the profit of the last closed order. This information will be shown in Comment(). And we will see. While there is no open order (position), the comment shows the profit of the last order. As soon as the order (position) is opened, we get 0 in the comment, until the order is closed. I.e. the order is still in the market, but simultaneously in history, it stays in two hypostases simultaneously. But this is nonsense. That is why I say that the language is just for the sake of the language. In my opinion, there are a lot of incomplete details.
You are confusing the concepts (in particular 'order'). There can be a REMOTE ORDER or a POSITION in the market. You can read more in the help:General Principles.
The CTrade class is self-sufficient and there are no flaws in it, just your unwillingness to see the implementation code. When sending a trade order (for opening or modifying a POSITION), the trade class instance sends a magic number - you just need to initialize it immediately when creating the object.
Forum on trading, automated trading systems and strategy testing
FAQ from Beginners MQL5 MT5 MetaTrader 5
Vladimir Karputov, 2020.09.12 19:11
Don't forget toset the Expert Advisor ID
It's a matter of habit.
Hello. Thank you for your reply. I will give my opinion. When opening an order in MQL4, we specify its parameters including a magik. In #include <Trade\OrderInfo.mqh>, everything except the magik is specified. For example - CTrade::BuyLimit(const double volume,const double price,const string symbol=NULL,const double sl=0.0,const double tp=0.0,const ENUM_ORDER_TYPE_TIME type_time=ORDER_TIME_GTC,const datetime expiration=0,const string comment=""). In my opinion, this is not a fix and we should fix it by introducing another magician parameter. Or, #include <Trade\ HistoryOrderInfo.mqh> contains everything except the profit (profit/loss) taken by the order. This is important information about the order and it is missing. We need to find the profit of the last closed order. This information will be shown in Comment(). And we will see. While there is no open order (position), the comment shows the profit of the last order. As soon as the order (position) is opened, we get 0 in the comment, until the order is closed. I.e. the order is still in the market, but simultaneously in history, it stays in two hypostases simultaneously. But this is nonsense. That is why I say that the language is just for the sake of the language. In my opinion, there are a lot of unfinished details.
Yury, this is not a mass of unfinished details, but a mass of misunderstandings.
Why, in each opening of an order or position, write a magician, if it is enough to indicate it once in OnInit().
That is all!!! Then the magic of an order, deal or position will be checked in the same way to identify "friend or foe". The problem is in your mind.
An order may not have a profit! A position has a profit in the current time. And a position has a closing trade, or part of a position, but that is in the trading history. An order is just an order to make a transaction in the market.
Let me try to explain in kolkhoznyy. You come to the market, you decide to buy a pickle.
Warrant: give me a kilo of them...
deal: you give me the money, you take the fish...
position: in your bag there's the apricot...
From the seller's point of view:
position: you have the fish stew on the counter...
order: you receive an order to weigh a kilo of fish...
transaction: hand over the apricots, put the money in the bag...
Hello. Thank you for your reply. I will give my opinion. When opening an order in MQL4, we specify its parameters including the magik. In #include <Trade\OrderInfo.mqh>, everything except the magik is specified. For example - CTrade::BuyLimit(const double volume,const double price,const string symbol=NULL,const double sl=0.0,const double tp=0.0,const ENUM_ORDER_TYPE_TIME type_time=ORDER_TIME_GTC,const datetime expiration=0,const string comment=""). In my opinion, this is not a fix and we should fix it by introducing another magician parameter. Or, #include <Trade\ HistoryOrderInfo.mqh> contains everything except the profit (profit/loss) taken by the order. This is important information about the order and it is missing. We need to find the profit of the last closed order. This information will be shown in Comment(). And we will see. While there is no open order (position), the comment shows the profit of the last order. As soon as the order (position) is opened, we get 0 in the comment, until the order is closed. I.e. the order is still in the market, but simultaneously in history, it stays in two hypostases simultaneously. But this is nonsense. That is why I say that the language is just for the sake of the language. In my opinion, there are a lot of unfinished details.
You think in terms of procedures but try to use OOP-objects. They are treated in a different way. For instance:
An object is created. A magician is set for it.
A second object is created. A second magician is set.
A third object is created. A third magician is given to it.
Now you have three trade objects for three strategies in one EA.
You should use the first trade object to open a position or place a pending order for the first TS.
In order to open a position or set a pending order for the second TS, you shall refer to the second trade object.
To open a position or place a pending order for a third TS, you must refer to a third trade object.
Orders do not have a profit parameter. For one simple reason - an order is an order (a pending order is an order to a broker to perform some action when the price reaches a certain level, i.e., an order to execute a trade after some time when the specified criterion is reached). A trade (order) can result in a trade (it already has the DEAL_PROFIT profit parameter) that will lead either to creation of a position or to its change or closing (the position also has the profit parameter, but only a current - floating POSITION_PROFIT).
And then there is the market order (market order), which always appears before the trade when you send a trade order - this is your trade order. And it is visible in the list of existing orders. That is, any position opening generates a chain: order --> trade --> position. Any action on an open position creates a chain: position --> order --> trade --> no position, or a smaller position, or a larger position (netting), or a position reversal (netting).
Study the reference.
Thank you all. Especially Alexey Viktorov- clear and specific. I have already reprocessed and checked it. Now we have the information about the last order profit, and the EA uses it. This is too much convoluted, there is unnecessary and superfluous confusion. There are current orders (pending, engaged /market/) and orders that have gone into history, but all the same orders. I don't have an earwig, I have an earwig - the transfer process is short-lived and absolutely irrelevant. It turns out that while the seller's order is being weighed, the buyer's is kind of already gone. I.e. there is confusion and confusion in the interim. The simpler the better.
But thank you all anyway, and good luck.
Thank you all. Especially Alexey Viktorov- clear and specific. I have already reprocessed and checked it. Now we have the information about the last order profit, and the EA uses it. This is too much convoluted, there is unnecessary and superfluous confusion. There are current orders (pending, engaged /market/) and orders that have gone into history, but all the same orders. I don't have an earwig, I have an earwig - the transfer process is short-lived and absolutely irrelevant. It turns out that while the seller's order is being weighed, the buyer's is not yet. I.e. there is confusion and confusion in the interim. The simpler the better.
But thanks all the same, I wish you all good luck.
It's not a quirk of the terminal developers. It was a quirk to fit the entire chain into a single "order" concept in 4. Now everything is in line with what's really going on.
And the time for shifting a stub from the shelf to the bag is the execution time of a trade order. And so, having absolutely all of the data on the current events, you can easily control how fast the orders are being executed. And not only that. Now you have a wide range of possibilities for the implementation of any statistics on any of the servers, and how well they can execute your orders.
This is not a quirk of the terminal developers. It was a quirk to fit the whole chain into a single "order" concept in quadruple. It is now in line with what is actually happening.
And the time for shifting a stub from the shelf to the bag is the execution time of a trade order. And so, having absolutely all the data on the events occurring, you can easily control how fast the orders are being executed. And not only that. Now you have a lot of opportunities to implement any statistics on any of the servers, and how well they can meet your requirements.
No disrespect, purely in line with the discussion. I've been trading my EAs for a long time (I'm not selling them), with different brokers and I'm not interested inthe absolute data on events. I am interested in the final result - the quality of orders executed on request of an EA. If the orders are opened only once (figuratively speaking), I simply will not work with this broker. If one broker's order opens half a second faster than the other, it is not important to me (as well as the difference in quotes).
For how easy is it to write an EA in mql4 and how bothersome is it with mql5? Why are the questions about mql5? I've heard good reports about the MT5 tester and had to become acquainted with mql5 to try it. I have tried it and am not satisfied. It's convenient to download quotes, it's much faster, but MT4 is more informative. For example, I want to know not only at what price orders were closed but also what profit (loss) they took. Forward optimization is so processor-intensive that the computer shuts down. I have tried one time (this is not a proof of course) to run one and the same Expert Advisor at one and the same broker. The results are different; mt5 is better - more profit, significantly less drawdown, which is stressful. Perhaps this is me being senile, but for now I have more criticism than positivity. I am not going to trade on mt5 yet, but the interest in writing a good Expert Advisor remains. Just for the sake of interest.
I wish you good luck.