I would like to ask you about some calculation. I work with Range bars chart.
I try to do indicator which can do "prediction" of new CCI position based on possible close value of range bar. Let say I have range bar value 6. It means every range bar has length 6 ticks on my YM chart. It means High-Low = 6 ticks.
Example: New bar opens on price 15006. Possible close prices in this moment are on 15012 Close (Upper) and 15000 Close (Lower). I attached pic where you can see situation, where possible close positions are on 16091 (upper close) and 16081 (for lower close) - I have one tick shift for both..it means that real values are 16091 and 16080..but it doesnt matter in this case. I would like to calculate possible position/value of CCI(14) when bar closes on both position...see atteched pic below (lower blue rectangle).
I looked at your CCI indicator - how values are calculated. I tried to do on my own..based on your calculation model. I think the only one thing I have to do is to calculate last Typical price for current bar with boht close prices - lower and upper and then calculate CCI. But it doesnt work well. Sometimes I can see lower and upper CCI values but current CCI value is NOT between them !! Current CCI value must lie between my lower and upper CCI values and must end exactly at one of them.
I use code below:
in Initialize:
internalTypicalUp = new DataSeries(this);
internalTypicalDn = new DataSeries(this);
OnBarClose:
if (Historical) return;
double hiClose = Low[0] + (Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize); // upper Close of Range bar
// ---- UPPER ----
for(int i=1; i<=CCIPeriod; i++) {
internalTypicalUp.Set(i,Typical[i]);
}
_LastTypicalPrice = ( (hiClose + Low[0] + hiClose) / 3.0 ); // Close and High of Range bar will be the same
internalTypicalUp.Set(0, _LastTypicalPrice);
mean = 0;
for (int idx = Math.Min(CurrentBar, CCIPeriod - 1); idx >= 0; idx--)
mean += Math.Abs(internalTypicalUp[idx] - SMA(internalTypicalUp, CCIPeriod)[0]);
_value = (internalTypicalUp[0] - SMA(internalTypicalUp, CCIPeriod)[0]) / (mean == 0 ? 1 : (0.015 * (mean / Math.Min(CCIPeriod, CurrentBar + 1))));
// it is your CCI code, just interaTypicalUp DataSeries is used insted of Typical
DrawLine("CCILinesUP",false,1,CCI(14)[1],0,_value,Color.Green,DashStyle.Dot,2);
// draw line from previous CCI value to new predicated value
The same calculation for lower value.
Would you be so kind and help me somehow with right calculation ??
Thank you very much.
Alex
Comment