Questions from Beginners MQL5 MT5 MetaTrader 5 - page 563

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
Yes, I'm asking about MQL 5? Yes, the data of the current symbol should be accessed. The data is needed in the EA code. So I need, for example, to know the close price of the bar preceding the current one.
Check out the example for CopyTime
Yes, I am asking about MQL5? Yes, the data of the current symbol should be accessed. The data we need in Expert Advisor code. So, for example, I need to know the close price of the bar preceding the current one
You should read the documentation a bit.
Here's an example of getting the closing price and indicator buffers
...
Here's an example of getting the closing price as well as the indicator buffers
Hello all !
I am getting data on trade history in the tester using OnTrade event.
And this is what I get in the logs.
0 22:58:16.487 Core 1 2016.04.01 00:00 Number of bars in the terminal history for the symbol-period GBPUSD at the moment = 7729
JR 0 22:58:16.487 Core 1 2016.04.01 03:00:00 Attempted trade 0 with lot 0.01
EL 0 22:58:16.487 Core 1 2016.04.01 03:00:00 market buy 0.01 GBPUSD sl: 1.43033 tp: 1.44034 (1.43646 / 1.43654 / 1.43646)
GO 0 22:58:16.487 Core 1 2016.04.01 03:00:00 deal #2 buy 0.01 GBPUSD at 1.43654 done (based on order #2)
GE 0 22:58:16.487 Core 1 2016.04.01 03:00:00 deal performed [#2 buy 0.01 GBPUSD at 1.43654]
NK 0 22:58:16.487 Core 1 2016.04.01 03:00:00 order performed buy 0.01 at 1.43654 [#2 buy 0.01 GBPUSD at 1.43654]
HI 0 22:58:16.487 Core 1 2016.04.01 03:00:00 ticket=1
HM 0 22:58:16.487 Core 1 2016.04.01 03:00:00 price=0.0
HH 0 22:58:16.487 Core 1 2016.04.01 03:00:00 time=2016.04.01 00:00
CR 0 22:58:16.487 Core 1 2016.04.01 03:00:00 ticket=2
ID 0 22:58:16.487 Core 1 2016.04.01 03:00:00 price=1.43654
OP 0 22:58:16.487 Core 1 2016.04.01 03:00:00 time=2016.04.01 03:00
Where does the first trade with zero price come from? I do not do it :-).
I do not do it :-) Explain plz.
Z.P. I think I got it. The first deal has a profit of 10K. I do not know what to do with it but it is still strange. Why?
And here is another question. The deal (buy at 1.43654) has not been opened yet. How did it appear in the history?
I need to get data ONLY on closed trades in the array like in MQL4. How to do it ???
P.S. Filter by DEAL_ENTRY_OUT ?
Have you tried reinstalling the terminal?
Bad example. The variable storing the indicator handle in MQL5 must be declared in the "header" - in the global variables area of the program, get the handle in OnInit(). And only then you can refer to the indicator's handle for getting data from anywhere in the program.
I do not quite agree with you about getting a handle, because the OnInit() function is executed once and there is no 100% guarantee that the indicator will be created from the first time. You might be right about declaring a variable, but I want to know if the following documentation says something worse than the variant with a static variable
Local variables declared with static keyword save their values as long as the function exists. With each subsequent call of a function, these local variables contain the values they had in the previous call.
Filter by DEAL_ENTRY_OUT
I do not quite agree with you about getting a handle, because the OnInit() function is executed once and there is no 100% guarantee that the indicator will be created from the first time. You might be right about the declaration of a variable, but I want to know how worse the option of a static variable is in the documentation
...
For this purpose, OnInit() checks if the indicator handle is created. If the indicator handle has not been created, OnOnit() should returnINIT_FAILED. That is, the indicator handle is created only once and only in OnInit(). This is not "4" - it's not a mess and wandering and declaring handles in all corners of the program.