Hi, I have this ... but don't manage to make it work. what's wrong? what am I missing?
CopyBuffer(hMA, 0, 0, 2, itt);
Two things stand out at first glance:
1. Read the documentation to this:
CopyBuffer(hMA, 0, 0, 2, itt);
And you are assuming:
rates_total == totalBars
which is rarely the case, and if, it wont stay that way consistently. - Additionally, I suggest to replace totalBars with rates_total.
But actually it would be better to completley spare these lines:
ArrayResize(ITT_, totalBars); ArrayResize(UP, totalBars); ArrayResize(DOWN, totalBars);
And you dont want this:
ArraySetAsSeries(itt, true);
Or you want it on all arrays, else you have one reverse array in your data.
As an idea, try something like this for your buffer calls:
CopyBuffer(hMA, 0, time[prev_calculated], time[rates_total - 1], itt);
But if you are doing such, watch your indexing, as they are not synched to the other buffers. - You will need to track an offset. - As said read the docs around CopyBuffer and Timeseries access.... It is important to understand how it works.
EDIT:
I just saw, you are using the alternate function siganture for OnCalculate(), you will need to figure out the indexing for the function call:
you cannot use this function call:
CopyBuffer(hMA, 0, time[prev_calculated], time[rates_total - 1], itt);
Two things stand out at first glance:
1. Read the documentation to this:
And you are assuming:
which is rarely the case, and if, it wont stay that way consistently. - Additionally, I suggest to replace totalBars with rates_total.
But actually it would be better to completley spare these lines:
And you dont want this:
Or you want it on all arrays, else you have one reverse array in your data.
As an idea, try something like this for your buffer calls:
But if you are doing such, watch your indexing, as they are not synched to the other buffers. - You will need to track an offset. - As said read the docs around CopyBuffer and Timeseries access.... It is important to understand how it works.
EDIT:
I just saw, you are using the alternate function siganture for OnCalculate(), you will need to figure out the indexing for the function call:
you cannot use this function call:
thanks for responding.
1) why should I use coppybuffer like that?
int CopyBuffer( int indicator_handle, // indicator handle int buffer_num, // indicator buffer number int start_pos, // start position int count, // amount to copy double buffer[] // target array to copy );
CopyBuffer(hMA, 0, 0, rates_total, itt);
2) total bars is
int totalBars = Bars(_Symbol, _Period);
but you are correct, looks better if I use rates_total, but rates_total is in OnCalculate, and ArrayResize is OnInit
3) Spare RatesResize with what? or should I delet it?
thanks for responding.
1) why should I use coppybuffer like that?
2) total bars is
but you are correct, looks better if I use rates_total, but rates_total is in OnCalculate, and ArrayResize is OnInit
3) Spare RatesResize with what? or should I delet it?
Then how do I do it? just whant to creat a simple Indicator out of another one ... can't find the simple way.
Then how do I do it? just whant to creat a simple Indicator out of another one ... can't find the simple way.
ok, problem solved ... I used this article
- www.mql5.com
thanks for responding.
1) why should I use coppybuffer like that?
2) total bars is
but you are correct, looks better if I use rates_total, but rates_total is in OnCalculate, and ArrayResize is OnInit
3) Spare RatesResize with what? or should I delet it?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I have this ... but don't manage to make it work. what's wrong? what am I missing?
array out of range when testing...