Questions from Beginners MQL5 MT5 MetaTrader 5 - page 814

 
Is there any way to stop these ineradicable checkboxes-news-objects from filling up my object list over and over again?
 
User_mt5:
Is there any way to stop these ineradicable checkboxes-news-objects from filling up my object list over and over again?

Here in the settings, remove the news and reload the terminal


 
User_mt5:
Is there any way to stop these ineradicable checkboxes-news-objects from filling up my object list over and over again?
You don't need to reload anything. In the calendar, uncheck "Delete all events", then uncheck "Auto-updates".
 
Kirill Belousov:

Here in the settings, remove the news and restart the terminal


Kirill, thank you very much. Otherwise my expert goes through the objects - goes through them again and again.
Thank you.

 

I'm trying to learn how to use the OnTradeTransaction function.

When using it in the tester, I see the following problem. An order is opened and consequently OnTradeTransaction is called. At this moment, I get the position size inside OnTradeTransaction using the CPositionInfo class. Everything is fine. Then on the same call I call another function directly from OnTradeTransaction and there CPositionInfo returns zero, i.e. not what I need. A few more minutes later I tried to get the position size in OnTimer but everything was OK there i.e. 1. Of course, the position hasn't been closed and opened again throughout the entire history.

Question. Why does CPositionInfo return in OnTradeTransaction what it needs, but in another function called from OnTradeTransaction it returns 0 instead of position volume.


Here are the logs. (Position opened at 10:30:12 closed 10:48:53)

This triggers an order.

2017.09.22 10:30:12 order [#3 buy limit 1.00 SBRF-3.18 at 19352] triggered

OnTradeTransaction is called three times. CPositionInfo on each call the position volume equals 1. On the last call of TRADE_TRANSACTION_HISTORY_ADD I call the function.

2017.09.22 10:30:50 Synmvo =SBRF-3.18 TRADE_TRANSACTION_DEAL_ADD order=3 order_type=ORDER_TYPE_BUY state=ORDER_STATE_STARTED Price=19352.0 deal=2 deal_type=DEAL_TYPE_BUY Position direction POSITION_TYPE_BUY Volume 1.0
2017.09.22 10:30:50 Synmvo =SBRF-3.18 TRADE_TRANSACTION_ORDER_DELETE order=3 order_type=ORDER_TYPE_BUY_LIMIT state=ORDER_STATE_FILLED Price=19352.0 deal=0 deal_type=DEAL_TYPE_BUY Position direction POSITION_TYPE_BUY Volume 1.0
2017.09.22 10:30:50 Synmvo =SBRF-3.18 TRADE_TRANSACTION_HISTORY_ADD order=3 order_type=ORDER_TYPE_BUY_LIMIT state=ORDER_STATE_FILLED Price=19352.0 deal=0 deal_type=DEAL_TYPE_BUY Position direction POSITION_TYPE_BUY Volume 1.0

In a function called from OnTradeTransaction.

2017.09.22 10:32:50 There is a 0.0 position on the quoted symbol SBRF-3.18 towards POSITION_TYPE_BUY

After a while trying to get volume again in OnTimer

2017.09.22 10:40:00 In OnTimer Symbol=SBRF-3.18 Volume=1.0

Closes position

2017.09.22 10:48:53 order [#5 sell limit 1.00 SBRF-3.18 at 19435] triggered

 
pivomoe:

I'm trying to learn how to use the OnTradeTransaction function.

When using it in the tester, I see the following problem. An order is opened and consequently OnTradeTransaction is called. At this moment, I get the position size inside OnTradeTransaction using the CPositionInfo class. Everything is fine. Then on the same call I call another function directly from OnTradeTransaction and there CPositionInfo returns zero, i.e. not what I need. A few more minutes later I tried to get the position size in OnTimer but everything was OK there i.e. 1. Of course, the position hasn't been closed and opened again throughout the entire history.

Here is my question. Why does CPositionInfo return what I need in OnTradeTransaction but in another function called from OnTradeTransaction, it returns 0 instead of the position volume.


Here are the logs. (Position opened at 10:30:12 closed 10:48:53)

This triggers an order.

2017.09.22 10:30:12 order [#3 buy limit 1.00 SBRF-3.18 at 19352] triggered

OnTradeTransaction is called three times. CPositionInfo on each call the position volume equals 1. On the last call of TRADE_TRANSACTION_HISTORY_ADD I call the function.

2017.09.22 10:30:50 Synmvo =SBRF-3.18 TRADE_TRANSACTION_DEAL_ADD order=3 order_type=ORDER_TYPE_BUY state=ORDER_STATE_STARTED Price=19352.0 deal=2 deal_type=DEAL_TYPE_BUY Position direction POSITION_TYPE_BUY Volume 1.0
2017.09.22 10:30:50 Synmvo =SBRF-3.18 TRADE_TRANSACTION_ORDER_DELETE order=3 order_type=ORDER_TYPE_BUY_LIMIT state=ORDER_STATE_FILLED Price=19352.0 deal=0 deal_type=DEAL_TYPE_BUY Position direction POSITION_TYPE_BUY Volume 1.0
2017.09.22 10:30:50 Synmvo =SBRF-3.18 TRADE_TRANSACTION_HISTORY_ADD order=3 order_type=ORDER_TYPE_BUY_LIMIT state=ORDER_STATE_FILLED Price=19352.0 deal=0 deal_type=DEAL_TYPE_BUY Position direction POSITION_TYPE_BUY Volume 1.0

In a function called from OnTradeTransaction.

2017.09.22 10:32:50 There is a 0.0 position on the quoted symbol SBRF-3.18 towards POSITION_TYPE_BUY

After a while trying to get volume again in OnTimer

2017.09.22 10:40:00 In OnTimer Symbol=SBRF-3.18 Volume=1.0

Closes the position

2017.09.22 10:48:53 order [#5 sell limit 1.00 SBRF-3.18 at 19435] triggered

And why use CPositionInfo if there is MqlTradeTransaction structure with all information about order, deal and position?

Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура торговой транзакции
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура торговой транзакции
  • www.mql5.com
Например, при отсылке рыночного ордера на покупку он обрабатывается, для счета создается соответствующий ордер на покупку, происходит исполнение ордера, его удаление из списка открытых, добавление в историю ордеров, далее добавляется соответствующая сделка в историю и создается новая позиция. Все эти действия являются торговыми транзакциями...
 

For convenience. A small function is called from MqlTradeTransaction. It finds the necessary element through searching for elements of the class. Then, one of the class functions is called for this element and it does something useful.

 
pivomoe:

For convenience. A small function is called from MqlTradeTransaction. The necessary element is found there through searching for elements of the class. One of the class functions is called for this element and it does something useful.

Apparently you have to change the whole algorithm to do this. The problem is very poorly described. If you needed some classes without using OnTradeTransaction, you don't need some classes using OnTradeTransaction. This is exactly why it says

Forum on trading, automated trading systems and strategy testing

FAQ from Beginners MQL5 MT5 MetaTrader 5

Alexey Viktorov, 2017.12.30 09:04

And why use CPositionInfo when there is MqlTradeTransaction structure where all order, deal and position information is?


 
It's not a problem to change the algorithm. I just can't figure out if CPositionInfo returns 1, then 0, then 1 again after position opening (we are talking about position size). Although the history shows that the position was neither closed nor opened again.
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
The custom function Abc() is executed, which implements a long (in time) algorithm.
During the execution of this function, events occur, for example - Trade, Timer, etc.
Is it possible to know that these events occurred without finishing execution of the Abc() function?