package JForex.myStrategies.finished;

import com.dukascopy.api.*;
import java.util.HashSet;
import java.util.Set;



/**
 * This strategy is used to see onTick events
 * 
 * @author JLongo
 */
public class MyFirstStrategy_TickEvents implements IStrategy {
    
    //Strategy base objects
    private IContext myContext          = null;
    private IAccount myAccount          = null; 
    private IEngine myEngine            = null;
    private IOrder myOrder              = null; 
    private IHistory myHistory          = null;
    private IIndicators myIndicators    = null;
    private IConsole myConsole          = null;
    

    /**
     * Strategy changeable parameters
     */
    
    /**
     * Fixed variables
     */

    /**
     * Executed at strategy start.
     * 
     * @param context - Plataform interface
     * @throws JFException
     */
    @Override 
    public void onStart(IContext context) throws JFException {
        
        myContext       = context; 
        myEngine        = myContext.getEngine();
        myAccount       = myContext.getAccount();
        myHistory       = myContext.getHistory();
        myIndicators    = myContext.getIndicators();
        myConsole       = context.getConsole();
        
        // put this code on area 3
        Set subscribedInstruments = new HashSet();
        subscribedInstruments.add(Instrument.EURGBP);
        subscribedInstruments.add(Instrument.EURNOK);
        subscribedInstruments.add(Instrument.EURSEK);
        subscribedInstruments.add(Instrument.EURUSD);
        myContext.setSubscribedInstruments(subscribedInstruments);
              
    }// end onStart

    /**
     * Executed on every tick received
     * 
     * @param instrument - instrumment of the tick received
     * @param tick - tick data
     * @throws JFException
     */
    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        myConsole.getOut().println(instrument.toString());
        
    }// end onTick

    /**
     * Executed on every bar completed
     * 
     * @param instrument - instrument for the bar received 
     * @param period - period of the bar received
     * @param askBar - OHLC and volume for the ask bar
     * @param bidBar - OHLC and volume for the bid bar
     * @throws JFException
     */
    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, 
    IBar bidBar) throws JFException {
                
        
    }// end onBar

    /**
     * Executed everytime a message is received from stream data 
     * 
     * @param message - the message itself
     * @throws JFException
     */
    @Override
    public void onMessage(IMessage message) throws JFException {            
        
    }// end onMessage

    /**
     * Executed on every account change
     * 
     * @param account - updated account data
     * @throws JFException
     */
    @Override
    public void onAccount(IAccount account) throws JFException {

        
    }// end onAccount

    /**
     * Executed when the strategy stops
     * 
     * @throws JFException
     */
    @Override
    public void onStop() throws JFException {
        
        
    }// end onStop
}    
    