Hi, support
I write a simple strategy. But it doesn't work.
Would you please tell me where is the problem?
package jforex;
import java.util.*;
import com.dukascopy.api.*;
public class MyCloseAll implements IStrategy
{
private IContext context = null;
private IEngine engine = null;
public void onStart(IContext context) throws JFException
{
this.context = context;
engine = context.getEngine();
}
public void onStop() throws JFException
{
}
public void onTick(Instrument instrument, ITick tick) throws JFException
{
if (positionsTotal(instrument) > 0)
{
engine.closeOrders();
}
}
protected int positionsTotal(Instrument instrument) throws JFException
{
int counter = 0;
for (IOrder order : engine.getOrders(instrument))
{
if (order.getState() == IOrder.State.FILLED)
{
counter++;
}
}
return counter;
}
public void onBar(Instrument instrument, Period period, IBar askbar, IBar bidbar) throws JFException
{
}
public void onMessage(IMessage message) throws JFException
{
}
public void onAccount(IAccount account) throws JFException
{
}
}
//+////////////////////////////////////////////////////////////////////+