Versuche verzweifelt diese beiden Geschichten in den IKH-CCI EA einzubauen. Aber immer gibts irgendwelche Fehler. Ansonsten scheint bis jetzt aber Alles korrekt zu sein.
Code:
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[]);
Code:
{
int i,k,pos;
double dSum,dMul;
//---
if(rates_total<=InpCCIPeriod || InpCCIPeriod<=1)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtCCIBuffer,false);
ArraySetAsSeries(ExtPriceBuffer,false);
ArraySetAsSeries(ExtMovBuffer,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- initial zero
if(prev_calculated<1)
{
for(i=0; i<InpCCIPeriod; i++)
{
ExtCCIBuffer[i]=0.0;
ExtPriceBuffer[i]=(high[i]+low[i]+close[i])/3;
ExtMovBuffer[i]=0.0;
}
}
//--- calculate position
pos=prev_calculated-1;
if(pos<InpCCIPeriod)
pos=InpCCIPeriod;
//--- typical price and its moving average
for(i=pos; i<rates_total; i++)
{
ExtPriceBuffer[i]=(high[i]+low[i]+close[i])/3;
ExtMovBuffer[i]=SimpleMA(i,InpCCIPeriod,ExtPriceBuffer);
}
//--- standard deviations and cci counting
dMul=0.015/InpCCIPeriod;
pos=InpCCIPeriod-1;
if(pos<prev_calculated-1)
pos=prev_calculated-2;
i=pos;
while(i<rates_total)
{
dSum=0.0;
k=i+1-InpCCIPeriod;
while(k<=i)
{
dSum+=MathAbs(ExtPriceBuffer[k]-ExtMovBuffer[i]);
k++;
}
dSum*=dMul;
if(dSum==0.0)
ExtCCIBuffer[i]=0.0;
else
ExtCCIBuffer[i]=(ExtPriceBuffer[i]-ExtMovBuffer[i])/dSum;
i++;
}
//---
}
//+-------