Thanks a lot for your feedback and your sample implementation of the
TypicalPrice!!!

-> This is the first step of the CCI indicator
but the CCI indicator needs a bit more work, see the following link:
http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:commodity_channel_in

Calculation according to above link:
There are 4 steps involved in the calculation of the CCI:

   1. Calculate the last period's Typical Price (TP) = (H+L+C)/3 where
H = high, L = low, and C = close.
   2. Calculate the 20-period Simple Moving Average of the Typical
Price (SMATP).
   3. Calculate the Mean Deviation. First, calculate the absolute
value of the difference between the last period's SMATP and the
typical price for each of the past 20 periods.
       Add all of these absolute values together and divide by 20 to
find the Mean Deviation.
   4. The final step is to apply the Typical Price (TP), the Simple
Moving Average of the Typical Price (SMATP), the Mean Deviation and a
Constant (.015) to the following formula:
       CCI = ( Typical Price - SMATP ) / ( .015 X Mean Deviation )

-> the steps 3-4 of the above shown instructions have to be added to
your TypicalPrice implementation

On Apr 6, 6:13 pm, John-Crichton McCutcheon
<[email protected]> wrote:
> Don't understand your problem exactly.   What about this?
>
> public class TypicalPrice extends Indicator {
>
>      private double high,low;
>
>      private final double period;
>      long tics = 0 ;
>      public TypicalPrice(int period) {
>
>          this.period=period;
>          reset();
>      }
>
>     �...@override
>      public void reset() {
>          value = 0.0;
>          high = Double.MIN_VALUE;
>          low = Double.MAX_VALUE;
>      }
>
>     �...@override
>      public void calculate() {
>          tics++;
>          double price = marketBook.getSnapshot().getPrice();
>          high = Math.max(price, high);
>          low= Math.min(price, low);
>
>          if ( tics % period == 0 ) {
>
>              value = (high + low + price) / 3;
>
>          } else if ( value == 0 ) {
>
>              value = price ;
>          }
>
>      }
>
> }
>
> On 4/6/2010 11:24 AM, new_trader wrote:
>
> > Hi guys,
> > I am just working on a CCI (Commodoty Channel Index) for JBT:
> >http://en.wikipedia.org/wiki/Commodity_Channel_Index
>
> > Part of the CCI concept is the so called Typical Price, which is setup
> > in the following way:
> > (High+Low+Close)/3
>
> > As we do not have OHLC data in JBT, some kind of OHLC logic has to be
> > constructed for CCI to work.
>
> > My thoughts were to define a bar window size, for example 60 seconds.
> > Within this time window an OHLC bar is constructed which can deliver
> > the values for the Typical Price.
>
> > The "problem" is that the values of the indicator are updating only
> > each bar window size seconds, here 60 seconds.
>
> > I plan to finish the implementation this week. The result will be
> > uploaded to this site.
>
> > Please give some feedback and opinions on CCI4JBT

-- 
You received this message because you are subscribed to the Google Groups 
"JBookTrader" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jbooktrader?hl=en.

Reply via email to