I'm not sure how to implement a thread.
Do I need to create a separate strategy file for each thread?
Is there a complete example somewhere that illustrates this?
The wiki example does not have sufficient information for my limited knowledge of java. Any help would be appreciated. My current strategy is being overloaded with tasks and I cannot determine why. All I am doing is calculating indicators in onBar event and checking parameters in on Tick event.
----------------------------------- code from wiki
private class BuyTask implements Callable<Object>{
private Instrument instrument;
private double stopLossPips;
public BuyTask(Instrument instrument, double stopLossPips){
this.instrument = instrument;
this.stopLossPips = stopLossPips;
}
public Object call() throws Exception {
double stopLossPrice = history.getLastTick(this.instrument).getBid() - this.stopLossPips * this.instrument.getPipValue();
return engine.submitOrder("Buy_order", this.instrument, OrderCommand.BUY, 0.001, 0, 20, stopLossPrice, 0);
}
}
private void buy() throws JFException{
BuyTask task = new BuyTask(Instrument.EURUSD, 40);
context.executeTask(task);
}