4.1.5 Stock Series

This series queries data from the ChartDataModel. Start and end dates define the period, over which stock values are known. Getter methods queries open, close, minimum and maximum prices. There are several strategies available for drawing Stock charts. They are discussed below.

Setting StockSeries:

1
2
3
4
// Sets StockSeries object named stock, where
//      model is an instanceof ChartDataModel
//      xMapper and yMapper - instances of AxisMapper
StockSeries stock = new StockSeries(model, xMapper, yMapper);

High-Low Stock Series

This series show high and low stock prices. For this sample source code, please refer to section “Candle Stock Series”.

Setting this series:

 
stock.setStrategy(StockStrategies.QUOTE_HL_STRATEGY);

High-Low Stock Series Demonstration

Figure 4.1.5.1 High-Low Stock Series Demonstration

High-Low-Close Stock Series

This series show high, low and close stock prices. For this sample source code, please refer to section “Candle Stock Series”.

Setting this series:

 
stock.setStrategy(StockStrategies.QUOTE_HLC_STRATEGY);

High-Low-Close Stock Series Demonstration

Figure 4.1.5.2 High-Low-Close Stock Series Demonstration

Open-High-Low-Close Stock Series

This series show open, high, low and close stock prices. For this sample source code, please refer to section “Candle Stock Series”.

Setting this series:

 
stock.setStrategy(StockStrategies.QUOTE_OHLC_STRATEGY);

Open-High-Low-Close Stock Series Demonstration

Figure 4.1.5.3 Open-High-Low-Close Stock Series Demonstration

Candle Stock Series

This series show stock prices using bars and lines, so that bars represent range of prices fluctuation for some particular time.

Setting this series:

 
stock.setStrategy(StockStrategies.QUOTE_CANDLE_STRATEGY);

Candle Stock Series Demonstration

Figure 4.1.5.4 Candle Stock Series Demonstration

View Source

Other Stock Series Properties

Relative width

It is possible to set relative width for series which use QuoteHLCStrategy, QuoteOHLCStrategy or QuoteCandleStrategy strategies.

Setting relative width:

 
((QuoteHLCStrategy) stock.getStrategy()).setRelativeWidth(0.1f);

Relative width set to 0.1f

Figure 4.1.5.5 Series Relative width set to 0.1f

Candle Series width

CandleSeries series' width range can be altered using setCandleWidthRange() method.

 
((QuoteCandleStrategy)stock.getStrategy()).setCandleWidthRange(1, 5);

Candle width range set to (1,5)

Figure 4.1.5.6 Candle width range set to (1,5)