I put it bigger in case I need more data or to prevent array out range. It shouldn't really matter as the averaging is done on the first "CCI_Period" elements of the array and shifted for the other 2 values.
Any idea why the first returns a value while the other 2 return 0 ?
![ArraySetAsSeries - Array Functions - MQL4 Reference ArraySetAsSeries - Array Functions - MQL4 Reference](https://c.mql5.com/36/12/arraysetasseries-array-functions.png)
- docs.mql4.com
I put it bigger in case I need more data or to prevent array out range. It shouldn't really matter as the averaging is done on the first "CCI_Period" elements of the array and shifted for the other 2 values.
Any idea why the first returns a value while the other 2 return 0 ?
I have modified my code as following.
Please provide feedback
Defining the arrays where I story the Heiken Ashi closed values under variables.
double HeikenClose_0[];
double HeikenClose_1[];
double HeikenClose_2[];
extern int CCI_Period=50;
double CCIvalue_now;
double CCIvalue_before;
double CCIvalue_before2;
Setting the array equal to the CCI Periods under init()
ArrayResize(HeikenClose_1,CCI_Period);
ArrayResize(HeikenClose_2,CCI_Period);
Performing the following under onTick()
for (int i=0; i<CCI_Period; i++)
{
HeikenClose_0[i]=iCustom(Symbol(),HeikenAshi_TF,"Heiken Ashi",3,i);
HeikenClose_1[i]=iCustom(Symbol(),HeikenAshi_TF,"Heiken Ashi",3,i+1);
HeikenClose_2[i]=iCustom(Symbol(),HeikenAshi_TF,"Heiken Ashi",3,i+2);
}
//setting the arrays as series as recommended
ArraySetAsSeries(HeikenClose_0,False);
ArraySetAsSeries(HeikenClose_1,False);
ArraySetAsSeries(HeikenClose_2,False);
//final calculation of the last 3 CCI values on the data
CCIvalue_now=iCCIOnArray(HeikenClose_0,CCI_Period,CCI_Period,0);
CCIvalue_before=iCCIOnArray(HeikenClose_1,CCI_Period,CCI_Period,0);
CCIvalue_before2=iCCIOnArray(HeikenClose_2,CCI_Period ,CCI_Period,0);
Thank you in advance
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 guys.
I am trying to calculate CCI values applied on an Array of Heiken Ashi closing values.
I generate an Array with values taken from the Heiken Ashi closing values
double HeikenClose[];
ArrayResize(HeikenClose,10+CCI_Period);
//develop the Heiken Values
for (int i=0; i<( CCI_Period+5); i++)
{
HeikenClose[i]= iCustom(Symbol(),HeikenAshi_TF,"Heiken Ashi",3,i);
}
and then to calculate the CCI values of the last 3
double CCIvalue_now=iCCIOnArray(HeikenClose,CCI_Period,CCI_Period,0);
double CCIvalue_before=iCCIOnArray(HeikenClose,CCI_Period,CCI_Period,1);
double CCIvalue_before2=iCCIOnArray(HeikenClose,CCI_Period,CCI_Period,2);
The first one generates a value while the other 2 give 0.
Something has to do with the shifting I am getting.
Can someone advise.
Thank you