getLabel() in Interface IOrder returns null if it is called from an IOrder object of getOrdersHistory(...) in Interface IHistory.
Please correct this.
Dukascopy ver. 2.13.30
JForex API ver. 2.6.38
See an example here
/*
* This is a test program only, do not use for trading!
* It shows that getLabel() of an IOrder object returns null, if called from a IHistory List
*
* Stash GmbH Muenchen
* www.stash.de
* Author: Bernhard Schicht
*/
package jforex;
import java.util.*;
import com.dukascopy.api.*;
public class StrategyTest2 implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
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();
}
public void onAccount(IAccount account) throws JFException {
for (Instrument instr : context.getSubscribedInstruments() ) {
p("checking instrument: "+instr.toString());
IHistory history = context.getHistory();
// console.getOut().println(cal.getTime().toString());
List<IOrder> historyOrders = null;
while (true){
try{
// from = 30 days back
historyOrders = history.getOrdersHistory(instr , System.currentTimeMillis()-30*24*60*60*1000, System.currentTimeMillis());
}
catch (Exception e) {
try{ Thread.sleep(2*1000); } catch (Exception e2) { e2.printStackTrace(console.getErr()); }
continue;
}
break;
}
for (IOrder order : historyOrders) {
p("label = "+order.getLabel()+", id = "+order.getId());
}
}
}
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 {
}
public void p(String text){
console.getOut().println(text);
}
}