package jforex.rangebartests;

import com.dukascopy.api.*;
import java.text.SimpleDateFormat;


public class Example implements IStrategy
{
    private IContext context;
    private IHistory history;

    public void onStart(IContext context) throws JFException
    {
        this.context = context;
        this.history = context.getHistory();

        long now = 0;

        context.getConsole().getOut().println(" - getting Time of latest RangeBar");

        try { now = history.getRangeBar(Instrument.EURUSD, OfferSide.BID, PriceRange.valueOf(3), 0).getTime();
        } catch (JFException e)
        {
            context.getConsole().getOut().println(e.toString());
            e.printStackTrace();
        }

        SimpleDateFormat sdf = new SimpleDateFormat();
        context.getConsole().getOut().println(sdf.format(now));
    }
 

    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    public void onStop() throws JFException {}

    public void onAccount(IAccount account) throws JFException {}

    public void onMessage(IMessage message) throws JFException {}

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
}