package jforex.rangebars;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.*;

@RequiresFullAccess
public class TicksAndRangeBars implements IStrategy {

	private IConsole console;
	
	@Override
	public void onStart(IContext context) throws JFException {
		
		this.console = context.getConsole();
		console.getOut().println("start");
		
		context.subscribeToRangeBarFeed(Instrument.EURUSD, OfferSide.BID, PriceRange.valueOf(1), 
				new IRangeBarFeedListener() {
					public void onBar(Instrument instrument, OfferSide offerSide, PriceRange priceRange, IRangeBar bar) {
						console.getOut().println("Range Bar: " + instrument + ", " + offerSide + ", " + priceRange + ", " + bar);
						
					}
				});
	}

	@Override
	public void onTick(Instrument instrument, ITick tick) throws JFException {
		console.getOut().println("tick: " + tick);
	}
	@Override
	public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
	@Override
	public void onMessage(IMessage message) throws JFException {}
	@Override
	public void onAccount(IAccount account) throws JFException {}
	@Override
	public void onStop() throws JFException {}
}
