package jforex;

import com.dukascopy.api.*;

public class TestMyIndicatorStrategy implements IStrategy {
    private IConsole console;
    private IIndicators indicators;
    
    public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
        this.indicators = context.getIndicators();
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
    
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        
        //making calculations on current instrument and period with manually created indicator ENTROPY
        Object[] outputs = indicators.calculateIndicator(instrument,                         
                                                         period, 
                                                         new OfferSide[] {OfferSide.BID},
                                                         "ENTROPY", 
                                                         new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, 
                                                         new Object[]{1},
                                                          1);
        
        //getting output on console
        for (int i=0;i<outputs.length;i++){
            this.console.getOut().print("output["+i+"]: "+(Double)outputs[i]);
        }        
        this.console.getOut().println();
    }
}
