My Stategy is close all order which I concern. The main code is recode onStart function as follows:
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
if (JOptionPane.showConfirmDialog(null, "Close All BUY and SELL","Close", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION){
// 停止执行策略
context.stop();
return;
}
double slippage = 2;
java.util.List<IOrder> orderList = engine.getOrders();
for (IOrder order : orderList) { // 循环遍历orderList
if (order != null){
// 只有本策略有权限管理的订单才能管理
if (!isStrategyManage(order.getLabel()))
{
continue;
}
// 订单全部平仓
order.close();
}
}
// 停止执行策略
context.stop();
}