package jforex;
import com.dukascopy.api.*;

public class TakeProfitSampleStrategy implements IStrategy {
    private IEngine engine;
    private IOrder myOrder;
    private IConsole console;
    
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();        
        this.console = context.getConsole();
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
        if(message.getOrder() == myOrder && message.getType()== IMessage.Type.ORDER_SUBMIT_OK){
            myOrder.setTakeProfitPrice(1.55455);                        
        }        
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
        
        if (myOrder == null) {
            myOrder = engine.submitOrder("myOrder", Instrument.EURUSD, IEngine.OrderCommand.BUY, 2);
        }
        
    }
    
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}