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.