Features of the mql5 language, subtleties and tricks - page 33
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
Highlighted can return 0. I ran into them at BCS.
Yeah, crooked brokers. They would also put negative numbers there.
It would be good if developers had a limit of possible values range for each parameter when brokers set symbols.
What exactly is wrong? That was the question - what am I doing wrong to get indicator data from a non-native timeframe?
Example: The indicator is running on М1, while data from АO should be obtained from М5. So, while we have limit>1 (history needs to be recalculated), AO from M5 returns zeros with absence of data error. As soon as the history is calculated (limit==0), the data starts to arrive from AO with M5.
To begin with - you don't need to make such entries:
I first thought that you were assigning to a variable its own value.
Next:
There is no need to copy during initialization. Initialization is not for this purpose. Moreover, this record will not be meaningful when data request from older TFs, which at the moment of request from OnInit() won't be calculated yet.
But this record is enough to be done just once at initialization stage.
Further ... um... subjectively, that's not how I would do it.
I like to break the program into:
1. First run (history analysis);
2. Subsequent runs:
2.1 Each tick;
2.2 Formed bar;
I.e:
And only after - the main cycle (function) of calculations.
Your copy-functions give out uninformative errors. Just the code is not very good.
There is no check of synchronization of the data of the older TF.
And the most important thing here is to understand the sequence. I advise you to create a test indicator, so it would only request the data of the major TF at the first start and to understand how the copying is made. I.e. to remove this from the beginning of the code:
And to unset the first and the last element of the array. And only then, if necessary, change the direction of indexing.
For starters, you don't need to make such entries:
I first thought you were assigning a variable its own value.
Next:
There is no need to copy during initialization. Initialization is not for this purpose. Moreover, this record will not be meaningful when data request from older TFs, which at the moment of request from OnInit() won't be calculated yet.
But this record is enough to be done just once at initialization stage.
Further ... um... subjectively, that's not how I would do it.
I like to break the program into:
1. First run (history analysis);
2. Subsequent runs:
2.1 Each tick;
2.2 The bar formed;
I.e:
And only after - the main cycle (function) of calculations.
Your copy-functions give out uninformative errors. Just the code is not very good.
There is no check of synchronization of the data of the older TF.
And the most important thing here is to understand the sequence. I advise you to create a test indicator, so it would only request the data of the major TF at the first start and to understand how the copying is made. I.e. to remove this from the beginning of the code:
And to unset the first and the last element of the array. And only then, if necessary, change direction of indexing.
I make variables in such a way that they are clear to me at a glance. If you don't understand them, make them in a way that you do ;)
I always start to write non-global variables with a small letter - the reason is simple: case sensitive intelligence...
This is the test code, as not test code is big enough, and on MT4 it flies when switching the TF, and there are no errors of missing data - everything is always there. In MT5, however, when switching the trader only half a minute loads the history, and then also does not work with the data is not his trader - says about their absence.
I have never had a chance to try it before. It turned out that it is necessary to request the data for all used TFs in the initis. I think that if you do not know in advance the estimated number of phones used, then you need to ask them all. Only one by half a minute counts. There are 21 of them in total...
Am I thinking something wrong again?
In MT5 it takes half a minute to download the history
wrote about it
more details here
https://www.mql5.com/ru/forum/1111/page1871#comment_4866969
https://www.mql5.com/ru/forum/1111/page1871#comment_4867939
This is and will be. The more TF or symbols it will request, the slower the start of work will be.
wrote about it
more details here
https://www.mql5.com/ru/forum/1111/page1871#comment_4866969
https://www.mql5.com/ru/forum/1111/page1871#comment_4867939
This is and will be. The more TFs or characters will be requested, the more retarded the start will be.
It would be good if only when I start the indicator for the first time. I have half a minute loading history every time I switch timeframe. I know it shouldn't be like that, but... I'm doing something wrong... I'm trying to access a non-native timeframe in only one indicator.
Well, measure the speed of copying data from another timeframe and see where the bottleneck is.
If you need to use several indicators from different TFs for calculations - you need to get the handle of each TF.
If you want everything to be calculated faster - reduce the size of the history in the terminal.
Have you run my test indicator? Is it collecting data?
If you need to use several indicators from different TFs for calculations - you need to get the handle of each TF.
If you want everything to be calculated faster - reduce the size of the history in the terminal.
Have you run my test indicator? Is it collecting data?
No, I haven't.
It turns out that if you need ALL timeframes, you have to create 21 AO indicator handles? Isn't it wasteful?
No, I haven't run it yet.
It turns out that if you need ALL timeframes, you need to create 21 AO indicator handles? Isn't it wasteful?