Self-learning the MQL5 language from scratch - page 26

 
Vladimir Simakov:
0. Data Types.

0.1 Type conversion

0.2 Boolean algebra

0.3 Concept of integer overflow (x+1 is not always greater than x)

0.4 Mathematics of floating point numbers

0.5 Variable

0.6 Variable initialization

...

Too lazy to think further)))

I have already mastered some of it (data types, variable), and will incorporate the rest into my learning plan.

Regards, Vladimir.

 

Good day and good mood everyone!

I am studying the MQL4 tutorial by Sergey Kovalev and I do not fully understand one simple thing. There is a section in the tutorial called "General order of trade operations" which lists all the concepts: Market Order, Pending Order, Trade Order and Trade Operation. But the concept of Position is often mentioned in messages of forum participants.

Thus, my question to the experts: Market Order = Position or it is a different concept?

Sincerely, Vladimir.

 
MrBrooklin:

Good day and good mood everyone!

I am studying the MQL4 tutorial by Sergey Kovalev and I do not fully understand one simple thing. There is a section in the tutorial called "General order of trade operations" which lists all the concepts: Market Order, Pending Order, Trade Order and Trade Operation. But the concept of Position is often mentioned in messages of forum participants.

Question to the experts: Market Order = Position or they are different concepts?

Sincerely, Vladimir.

Yes, the implementation of trading operations is simplified in Quartet. And the tutorial reflects it correctly, and in 4ka everything is tied to the order ticket. And the ticket of a pending order does not change after it has become a market one. In 5, the documentation also says in detail. There the order has its own ticket, deal - trade operation has its own ticket, position has its own ticket. All trades in 5ka are deals, all orders are orders. Therefore SL and TP are orders - orders. And after trades positions appear or are changed or closed. And there are 2 types of accounting - netting accounts, when only a position is accounted for, and hedge accounts, when positions are accounted for with differently directed orders. In 4ka only hedge account, and there is even an operation to close differently directed orders in one action, to save transaction costs. And the conclusion of a correct market order in 4 is a position in 5. There are no market orders in 5. Only pending orders.)

 
Valeriy Yastremskiy:

Yes, in 4, the implementation of trade transactions is simplified. And the tutorial is correct, and in 4 everything is tied to the order ticket. And the ticket of a pending order does not change after it has become market. In 5, the documentation also says in detail. There the order has its own ticket, deal - trade operation has its own ticket, position has its own ticket. All trades in 5ka are trades, all orders are orders. Therefore SL and TP are orders - orders. And after trades positions appear or are changed or closed. And there are 2 types of accounting - netting accounts, when only a position is accounted for, and hedge accounts, when positions are accounted for with differently directed orders. In 4ka only hedge account, and there is even an operation to close differently directed orders in one action, to save transaction costs. And the conclusion of a correct market order in 4 is a position in 5. There are no market orders in 5. Only pending orders.)

Hello Valery! Thank you very much for such a detailed reply. About the fact that ... Order has its own ticket, deal - trade operation - its own ticket, position - its own ticket ..." I did not know, so thank you for the tip.

Regards, Vladimir.

 

Found in MQL5 Reference: Types of Trading Operations .Trading is performed by sending orders to open positions, as well as orders to set, modify or delete pending orders using the OrderSend() function. Each trade order contains indication of a requested trade operation type. Trade operations are described in enumeration ENUM_TRADE_REQUEST_ACTIONS.

Now everything is clear: an order to open a position (I added it myself - at market price).

Regards, Vladimir.

 
MrBrooklin:

Found in MQL5 Reference: Types of Trading Operations .Trading is performed by sending orders to open positions, as well as orders to set, modify or delete pending orders using the OrderSend() function. Each trade order contains indication of a requested trade operation type. Trade operations are described in enumeration ENUM_TRADE_REQUEST_ACTIONS.

Now everything is clear: an order to open a position (I added it myself - at market price).

Sincerely, Vladimir.

I would like to add that the price is a necessary condition for the order to close the position, just like at the market - you can buy only at the market price, as well as sell. The price range is slippage and if the price moves out of the level, the order will not be closed.

 
Valeriy Yastremskiy:

I would like to add that the price is a precondition for opening and closing a position, just like in a bazaar, you can only buy at the bazaar price, as well as sell. If the price leaves this level, the order will not be closed.

Thank you, Valery! By the way, I have understood the slippage, and now you have once again confirmed it.

Regards, Vladimir.

 

In Sergei Kovalev's MQL4 textbook I found what I was looking for. Here is an extract from the book:"Structure of a Simple Expert Advisor . Below is the basic structure of a simple Expert Advisor based on several functional blocks, each block performing a certain independent part of calculations".


In this regard, I need some expert advice, is this block diagram applicable to writing an Expert Advisor in MQL5, or should I add some other blocks?

Best regards, Vladimir.

 
MrBrooklin:

In Sergei Kovalev's MQL4 textbook I found what I was looking for. Here is an extract from the book:"Structure of a Simple Expert Advisor . Below is the basic structure of a simple Expert Advisor based on several functional blocks, each of which involves a certain independent part of calculations".

In this regard, I need some expert advice, is this structured scheme applicable to writing an Expert Advisor in MQL5, or should I add some other blocks?

Best regards, Vladimir.

This is a spherical horse in a vacuum, not a flowchart of a working EA. Some blocks may not exist at all. Blocks can be rearranged. Any MCL program is an event handler. This is the main postulate that is not in the scheme, which means that it misleads the readers. My advice to you: do not read this old stuff. Kovalev's textbook is outdated. Many of the information in it is not correct, especially with respect to the order system of MT5. Kovalev essentially offers to memorize this ridiculous scheme, then memorize sets of events, and then pulls the owl on the globe: where supposedly this scheme is implemented in the Expert Advisor program. There are no schemes in MKL. There are typical patterns of using the trading environment. But there is no universal scheme, which has to be understood and remembered. All "schemes" are composed using functions and reactions of these functions to events. Plus, there are data that are requested... again by functions.

 
MrBrooklin:

In Sergei Kovalev's MQL4 textbook I found what I was looking for. Here is an extract from the book:"Structure of a Simple Expert Advisor . Below is the basic structure of a simple Expert Advisor based on several functional blocks, each block performing a certain independent part of calculations".


In this regard, I need some expert advice, is this structured scheme applicable to writing an Expert Advisor in MQL5, or should I add some other blocks?

Best regards, Vladimir.

It is logically applicable, but the Accounting block is different. In 4 it's easier, and that's why I like it. In 5ka it's more complicated. There are libraries that make life easier, but you have to know the language to use them. In essence, in 5ka, the order is sent, the answer is correct or not, if correct, the status for execution, after execution there is no answer, it must also be requested, then the transaction, whether it worked or not, the answer must also be requested, and if the transaction is successful, then there is a position - an asset (goods in the bazaar), which has a market price.