Skip to content
Tim Olson edited this page Feb 7, 2015 · 5 revisions

OHLC Bars

You can build OHLC bars like this:

cointrader-esper.cfg.xml:

<plugin-view factory-class="org.cryptocoinpartners.esper.OHLCBarPlugInViewFactory" name="ohlcbar" namespace="custom"/>
  • Create an esper named window to add the OHLC bars into
create window OHLCShortWindow.win:length(10)
as 
select * from Bar;
  • Add the OHLC bars to it
insert into OHLCShortWindow
select * from Trade.custom:ohlcbar(timestamp, priceCountAsDouble, market);
  • Select values from OHLC bar window
select * from OHLCShortWindow as ohlc 

TA-Lib

Coin Trader incorporates TA-Lib which provides many indicators.

First set up OHLC bars as above.

cointrader-esper.cfg.xml:

<plugin-aggregation-function name="talib" function-class="org.cryptocoinpartners.esper.GenericTALibFunction"/>  

Now you can call TA-Lib from within Esper like this:

select coalesce(talib("atr", max, min, last, 9),0) as atr from OHLCShortWindow;
Clone this wiki locally