Questions from Beginners MQL5 MT5 MetaTrader 5 - page 814
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
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
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 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
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?
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.
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?
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?