Login
Login

Re: Implementing indicators which require OHLC

Home 21090308 Forums Re: Implementing indicators which require OHLC

#2026
kmika
Member

Hello Ryu,

Yup, your reply definitely helps. I have looked through the example class you mentioned [font=Monaco:177hx6by]OhlcChartDemo[/font:177hx6by] and now have a better understanding of what to do. Still, I have a few specific questions on how I should implement an indicator which requires Ohlc data.

I understand from the example class how we call the [font=Monaco:177hx6by]update[/font:177hx6by] method in the [font=Monaco:177hx6by]OhlcBars[/font:177hx6by], inserting the arguments [font=Monaco:177hx6by]time[/font:177hx6by] and [font=Monaco:177hx6by]price[/font:177hx6by]. From there, we can extract the ohlc information from the instance of [font=Monaco:177hx6by]OhlcBars[/font:177hx6by]. What is set in this example is that the [font=Monaco:177hx6by]price[/font:177hx6by] information is taken from an instance of [font=Monaco:177hx6by]ArimaSim[/font:177hx6by] via [font=Monaco:177hx6by]get[/font:177hx6by].

My question is thus, how do we integrate the ohlc information in an indicator which will be used by our strategy similar to the [font=Monaco:177hx6by]SMA2Crossover[/font:177hx6by]?

The idea I thought of is that I’ll make a class [font=Monaco:177hx6by]OhlcIndicator implements DoubleSignal[/font:177hx6by] and I’ll rewrite the method [font=Monaco:177hx6by]public synchronized void update(Time t, Double px)[/font:177hx6by]. This idea is based on the fact that the classes [font=Monaco:177hx6by]Simulator[/font:177hx6by] and [font=Monaco:177hx6by]Strategy[/font:177hx6by] ultimately calls [font=Monaco:177hx6by]update[/font:177hx6by] in our indicator class and inserts the latest price.

However, I’m still at lost at where should I create an instance of [font=Monaco:177hx6by]OhlcBars[/font:177hx6by] where I’ll update it with the latest prices. Should I do it in [font=Monaco:177hx6by]OhlcIndicator implements DoubleSignal[/font:177hx6by], or [font=Monaco:177hx6by]OhlcIndicatorCache extends SimpleSequentialCache[/font:177hx6by].

Thank you and any help is greatly appreciated.

Donny.
P.S.: Has anyone in the class manage to program an strategy which uses an indicator requiring ohlc data. I’m kind of worried of my java programming abilities.