Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1266
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
Good time to you all!
I have a question about ResultDeal() function in CTrade class.
The thing is, in the Strategy Tester this function returns the trade ticket without any problem, but when you throw the EA on the Chart it always returns "zero", in spite of the fact that the ResultRetcode() function always returns "TRADE_RETCODE_DONE".
Example code:
Execution log in the Tester:
Execution log on the Chart:
What am I doing wrong? How do I get a trade ticket in real time?
And the second question (of less importance), why immediately after a trade execution the PositionsTotal() function returns "zero"? And it shows reliable data with the next tick. Is it possible to obtain this information at once?
Good time to you all!
I have a question about ResultDeal() function in CTrade class.
The thing is, in the Strategy Tester this function returns the trade ticket without any problem, but when you throw the EA on the Chart it always returns "zero", in spite of the fact that the ResultRetcode() function always returns "TRADE_RETCODE_DONE".
Example code:
Execution log in the Tester:
Execution log on the Chart:
What am I doing wrong? How do I get a trade ticket in real time?
And the second question (of less importance), why immediately after a trade execution the PositionsTotal() function returns "zero"? And it shows reliable data with the next tick. Is it possible to obtain this information at once?
Hmm... Suddenly the data I need in real time is returned by ResultOrder() function of the sameCTrade class, though I didn't use pending orders...
The question is the same: What am I doing wrong?
There is a macro like this.
I use it like this.
Warning"Warnig сработал. ");
Question: What needs to be corrected in the macro definition to be able to use it like this ?
Warning("Warnig сработал. ");
i.e. with a parenthesis between Warning and "Warnig worked. "Tried to use a parenthesis in the macro definition
but the compiler won't let me use a parenthesis.
Hmm... Suddenly, the ResultOrder() function of the sameCTrade class returns the data I need in real time, although I didn't use pending orders...
The question is the same: What am I doing wrong?
Just understand the order system of MT5, order - trade - position.
ResultOrder is the opening order. The position will be with POSITION_IDENTIFIER equal to the ticket of this order.
All of the deals can be found in the history by the position identifier. Do not confuse with the ticket of the position, it can change, and the identifier is constant.
s.s. The tester is different in that there is no delay in executing the order and the deal is created immediately. In real life, time passes and at the time of successful creation of an order there is no deal yet, it has to be caught in the OnTrade eventsThere is a macro like this.
I use it like this.
Question: What needs to be corrected in the macro definition to be able to use it like this ?
i.e. with a parenthesis between Warning and "Warnig worked. "Tried to use a parenthesis in the macro definition
but the compiler won't let me use a parenthesis.
you want to use a parametric form, but you've specified a non-parametric form. it has to be like this
I didn't explain it well. Let's start from the beginning. Now I'm using the macro like this:
Warning,"Warnig сработал. i=",i);
Here's the macro itself:
In the macro call between "Warning," and ");" An arbitrary number of parameters of arbitrary types. This is all achieved by repeatedly reloading theWrite function.
Question. What should I correct in the macro to be able to call it like this:
Warning("Warnig сработал. i=",i);
I didn't explain it well. Let's start from the beginning. Now I'm using the macro like this:
Here's the macro itself:
In the macro call between "Warning," and ");" An arbitrary number of parameters of arbitrary types. This is all achieved by repeatedly reloading theWrite function.
Question. What should be corrected in the macro to enable its call like this:
Answer: also reload the macro multiple times)
But it's better to use operator + for strings and convert everything to strings, then you don't need a version of function (and macro) with lots of parameters
Just understand the order system of MT5, order - trade - position.
ResultOrder is the opening order. The position will be with POSITION_IDENTIFIER equal to the ticket of this order.
All of the deals can be found in the history by the position identifier. Do not confuse with the ticket of the position, it can change, and the identifier is constant.
s.w. The tester is different in that there is no delay in executing the order and immediately a deal is born. In real trade the time passes and at the time of successful execution there is no deal yet, it has to be caught in the OnTrade events.Hello! How do I access indicator properties from an EA? For example I want to change the line colour from an EA if I know the indicator handle. I searched for it, i couldn't find it, maybe i am looking too hard?
An indicator for this must have an input colour parameter. That is, it must be a custom indicator.