Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1099

 
Igor Makanu:

Thank you!

Yes, that's what I was looking for, if I couldn't write in "five lines" with SB.

But how much I understood, that one SB CTrade will not be able to solve my problem? And I had to use CPositionInfo as well? - If I want to accompany 9 positions by several TFs at the same time?

ZS: I'm sitting in the MQL5 help with smart TV - quite well described trade functions, the use of SatB is under a question .... i think it makes sense to use SB for primitive strategies, a bit more complicated - the functionality is insufficient or not obvious use, maybe i need more practice - i will try to "twist" the SB


Thanks again!

It is OK for "open-close a position" in the tester, or for training codes as a substitute. Otherwise, you should make your own code or inherit it from CTrade to create your own full-fledged class for trading operations taking into account various nuances.
There are much nicer things in SB - you know about them and use them.

 
fxsaber:

There is no error there, as the list is generated through HistorySelectByPosition.

Yes, I overlooked that it is not a complete list.

 
Artyom Trishkin:

SB has much nicer things - you know about them and use them.

so these are the nice things that are misleading! - I was hoping that after so many years the developers have cleaned up and made the expected functionality, and I'm just a user who was unable to use 2 clicks of SB, but it turns out I'm not the user - sadness, sadness in general!

SZY: MQL5 Help is very skillfully written, full of orders ... But they say - until you forget the word order, you're hopeless!

 
Igor Makanu:

so these are the nice things that are misleading! - I was hoping that during so many years SB developers have polished and made the expected functionality, and I'm just a user who was not able to use SB in 2 clicks, but it turned out I'm not the user - sadness in general!!!

SZY: MQL5 Help is very skillfully written, full of orders ... But they say - until you forget the word order, you're hopeless!

It's quite simple here. Order -> trade -> position. In MQL5 we also cannot avoid orders - they are there, and they are the beginning of everything. We send a trade request to the server (it is an order), the server accepts/receives it and returns the code. Sometimes, if the request is incorrect, the order is not sent to the server at all - its sending is blocked at the terminal level. Once the order has been successfully sent to the server and queued for execution, we await for this order to trigger (its execution, in other words - a deal) and as a result of this transaction (whether it is a market or a pending order), a position is formed (not always - on netting, and if there is a position in the same direction, it simply adds volume to the existing position, if the opposite direction, then, depending on the volume of the committed deal, the current position is either partially closed or reversed).

Orders have their own ticket too. So do trades and positions. But a position also has an identifier. The identifier of a position will always be equal to the ticket of its very first order - the order to open this position.

A market order only has a ticket. And its position identifier property is not filled until the order is triggered. I.e. only a historical order has a position identifier - it is filled in at the moment of the trade - at the moment of triggering of that order. If it is adeleted pending order, its position identifier is also not filled - there was no trade or position respectively.

The trade has a ticket (its ticket), there is an identifier of the order - as a result of which this trade was executed, and there is a position identifier - the position that appeared as a result of execution of this trade or the position that was changed as a result of execution of this trade

The position has a ticket, which is assigned to it when it is opened or changed. If the position is only opened then its ticket will be equal to its identifier - a unique position number, which does not change throughout the life of the position. While a position's ticket may change repeatedly and corresponds with the ticket of an order - as a result of the triggering of that order, a new trade appears which changes that position - the ticket of that order is assigned to the position's ticket.

If we closely monitor all these metamorphoses in a position, we can easily see the position behavior in mql4 during its partial closing - its ticket changes there as well.

 
Artyom Trishkin:

If you watch closely all these metamorphoses in position

Thanks! I'm watching it for the second day, but all it takes is practice, today I've got the SB figured out...well, figured it out ;)

PS: you explain well, talent for sure!

 
Igor Makanu:

Thank you! I'm watching it for the second day, but all it takes is practice, so today I got the SB sorted out...well, sorted it out ;)

PS: well explained, definitely a talent!

Glad to help ;)

 
Artyom Trishkin:

..................

An order also has its own ticket. So do trades and positions. But a position also has an identifier. The position identifier will always be equal to the ticket of its very first order - the order to open this position.

A market order only has a ticket. And its position identifier property is not filled until the order is triggered. That is, only a historical order has a position identifier - it is filled in at the moment of executing the trade - at the moment of triggering of that order. If it is a deleted pending order, its position identifier is also not filled - there was no trade or position respectively.

The trade has a ticket (its ticket), there is an identifier of the order - as a result of which this trade was executed, and there is a position identifier - the position that appeared as a result of execution of this trade or the position that was changed as a result of execution of this trade

The position has a ticket, which is assigned to it when it is opened or changed. If the position is only opened then its ticket will be equal to its identifier - a unique position number, which does not change throughout the life of the position. While the ticket of a position can be changed repeatedly and corresponds with the order ticket - as a result of triggering of that order a new trade appears which changes that position - the ticket of that order is assigned to the position ticket.

If we closely monitor all these metamorphoses in a position, we can easily see the position behavior in mql4 during its partial closing - its ticket changes there as well.

So it turns out that the mismatch was obtained because of the delay in turning the order into a trade - position? Even in the tester...? That's amazing.

So, after the order is placed, we still have to make sure that the position is opened... How long does one have to wait? Is it to hang the owl until all the conversions are confirmed? Or what is it like in general?

 
Сергей Таболин:

It turns out that the mismatch was due to the delay in turning the order into a trade - position? Even in the tester...? What a load of crap.

So, after the order is placed we still have to make sure that the position is opened... How long does one have to wait? Is it to hang the owl until all the conversions are confirmed? Or what is it like in general?

We have placed a trade order (we have remembered the trade ticket) and raised the wait flag - as soon as we got a guaranteed trigger in OnTradeTransaction - transaction type TRADE_TRANSACTION_DEAL_ADD - we check the trade ticket. If everything worked together - fine.

This is real life - events may come with different interval, connection breakdowns ... Lots of things can happen. This is reality - there is no rigid chain.

 
Vladimir Karputov:

We have placed a trade order (remembered the transaction ticket) and set the pending flag - as soon as OnTradeTransaction received a guaranteed trigger - transaction type TRADE_TRANSACTION_DEAL_ADD - we check the transaction ticket. If everything worked together - fine.

This is real life - events may come with different interval, connection breakdowns ... Lots of things can happen. This is reality - there is no rigid chain.

Well that's essentially hanging the councillor... Waiting for confirmation to come or not to come... I'm at a loss here... How do I do this waiting? Using while() ?

 
Сергей Таболин:

Well, it's essentially hanging the advisor... Waiting for confirmation to come or not to come... I'm at a loss here. How do I do this waiting? Using while() ?

No. Sleep and While are categorically forbidden.

Reason: