Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1052

 
Igor Makanu:

alternatively openhttps://www.mql5.com/ru/code/16006

and look at@fxsaber's implementation

or just connect the above library and transfer the code from MT4 to MT5, in 99% of cases you won't have to tweak anything, everything will work the same as in MT4

And don't let the knowledge go to waste...
 
Artyom Trishkin:
And let the knowledge not add up...

knowledge? that's not knowledge you need to develop a TS or a trader!

You don't write a driver for yourself to control your hard drive --> API --> your program, do you? You just use the capabilities of the platform and programming language and nothing more - in 2 clicks (a couple of lines) you get

It's a fact that MQL5 has a tedious and boring way of dealing with orders,

i have no idea how to open an order, how to check its status, how to know the price and close time (i know about CTrade, i have partially opened the source code) - those are elementary things a trading platform should do in 2 clicks and it should not cause any problems.

SZZY: it has been less than 5 years since MQL5 added iTime(), IClose() functions .... that's the follow-up, a trading platform that can neither access instrument history nor place orders in 2 clicks, in the first year the whole kodobase was flooded with "miracle implementations" of how to read the history of a trading instrument in 2 clicks.... OK, it's a hackneyed topic.

 
Igor Makanu:

knowledge? it's not necessary knowledge for developing a TS or for a trader!

Exactly right. You do not need this knowledge to develop a strategy or as a trader. Similarly, the knowledge of mql4 is not needed.

That's what the programmer needs. And only if he wants to understand what he is doing and can check the obtained result against the expected one.

Not so long ago I had to edit someone else's EA: according to the TOR, a position should be closed at Breakeven at a certain moment. In fact, the Expert Advisor opened a position, closed it immediately and set a new one, which it closed according to the rules.

After I had watched this mess for a couple of hours, I suggested that I write my Expert Advisor from scratch. Wasn't it your Expert Advisor?

 
Alexey Viktorov:

After watching this mess for a couple of hours, I suggested that I write my Expert Advisor from scratch. Wasn't that your Expert Advisor?

Definitely mine! ))))) - I maintain my codes for at least a month, but usually everything works right the first time, although there may be some discrepancies in the ToR, but this is not a submission, it's a work in progress. I edit often other people's code, but that's a separate story, it is very time consuming and the result is unknown - just warn me about this

If low-level programming fascinates, so to speak "to dig in small bowels" - go ahead, there is a standard library CTrade from developers, it should do the minimum required for the user

 
Igor Makanu:

Definitely mine! ))))) - I maintain my codes for at least a month, but usually everything works right the first time, although there may be some discrepancies in the ToR, but this is not a submission, it's a work in progress. I edit often other people's code, but that's a separate story, it is very time consuming and the result is unknown - just warn me about this

If low-level programming fascinates, so to speak "to dig in small bowels" - go ahead, there is a standard library CTrade from developers, it should do the minimum required for the user

The owner of this miracle code, as well as its author, did not know about the subtlety that the position is opened and then closed. That is why there are no claims.

In general, I agree with you. Some developers do not catch mice at all. Then they deliberately create bugs, according to statements of one character, he is tortured to catch these bugs. Now they will not make one single command like "Mow the money". You don't need to know any programming. "It's not the king's business to mess with ***. I'll order and ***" that's what you sound like.

 
Alexey Viktorov: The owner of this miracle code as well as its author were not aware of the subtlety that the position is opened and then closed. I agree with you. They do not catch mice at all. They will deliberately create bugs but they are tired of catching them as one character has put it. Now they will not make one single command like "Mow the money". You don't need to know any programming. "It's not the king's business to mess with ***. I'll order and ***" that's what you sound like.

As far as I understand we are talking about some code in MQL5 ? - I haven't written any public code in that language, I only use ready-made solutions.

Well, about your performance - all languages are always "updated" with libraries, the developers of the libraries are often simple programmers-users, but this does not prevent these libraries from being popular and made with a very high quality, if you manage to get out of the MQL sandbox - have a walk on GitHub, I've always found ready-made libraries for C# that save time for development

 
Vladimir Karputov:

There is no direct analogy. A position consists of trades. If you want accurate position data, you must first build the position back up from the trading history.

Therefore it is better to work with the concept of "deal".

Generally, the implementation depends very much on the answer to the question: "Why?". That is, first describe exactly what you want and why.

To get the profit of the deal in pips. In MT4 it was done like this:

( OrderClosePrice() - OrderOpenPrice() )/Point;
 
secret:

Get the trade's profit in pips. In MT4 it was done like this:

You cannot get a profit on a trade. A trade can be:

ENUM_DEAL_TYPE-Type of trade

ENUM_DEAL_TYPE

Identifier

Description

DEAL_TYPE_BUY

Buy

DEAL_TYPE_SELLSell

***


You need to get information on a closed position (a complete position consists of at least two trades: entry and exit). To do this:

  • assemble the position from the trading history and check its completeness (I remind you that the position can be assembled from the trades) - use the DEAL_POSITION_ID property of the trades.
The control word here is "Collect position from the trading history and check its completeness".
 
Vladimir Karputov:

I see. Thank you) Very strange terminology in MT5.

I wonder why the developers didn't make ready-made position properties in history. They did in MT4.

 
secret:

I see. Thank you) Very strange terminology in MT5.

I wonder why the developers didn't make ready-made position properties in history. They did in MT4.

It's very good that they have done so. There is access to the whole history of any position change. In 4 everything is piled into an order. And a warrant is just an order to execute. In five, on the other hand, it's an order-deal-position.
Reason: