Add custom information in OHLC Index

OHLC (Open, High, Low, Close) is a chart object which not only contains the price and date information, but also can contain user defined information. In the following example strategy adds tick count to the OHLC object and demonstrates how one can vary the positioning of this textual information.


package jforex.charts;

import java.awt.Color;
import javax.swing.SwingConstants;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IOhlcChartObject;

 * The strategy on its start plots an OHLC object on chart 
 * and on every tick updates the customized user info on it.
 * On strategy stop the object gets removed
public class TestOHLC2 implements IStrategy {
    public IChart chart;

    private static int count = 0;
    IOhlcChartObject ohlc;

        public void onStart(IContext context) throws JFException {
        chart = context.getChart(Instrument.EURUSD);

        ohlc =  chart.getChartObjectFactory().createOhlcInformer();


        public void onTick(Instrument instrument, ITick tick) throws JFException {
        ohlc.addUserMessage("Ticks count: " + count, Color.ORANGE, SwingConstants.LEFT, true);
        ohlc.addUserMessage("Ticks count: " + count, Color.ORANGE, SwingConstants.CENTER, false);
        ohlc.addUserMessage("Ticks count: " + count, Color.ORANGE, SwingConstants.RIGHT, false);
        ohlc.addUserMessage("Ticks ", ""+count, Color.RED);

        public void onAccount(IAccount account) throws JFException {}

        public void onMessage(IMessage message) throws JFException {}

        public void onStop() throws JFException {

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {    }

The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.