I created a simple strategy,which submit an stop loss order once a day,and then track the exact Order name in the onMessage() method,test the strategy in the JForex platform but didn't get the correct results.
the JForex version :3.41; the JForex API version:2.13.57.
the onBar method is:
public Instrument myInstrument=Instrument.EURUSD;
public Period myPeriod=Period.DAILY;
private int myOrderCounter=0;
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if(instrument==myInstrument && period==myPeriod){
myOrder=myEngine.submitOrder("mySimpleOrder"+ ++myOrderCounter,myInstrument,IEngine.OrderCommand.SELL,0.01);
myOrder.waitForUpdate(1000);
myConsole.getOut().println(myOrder.getLabel()+" is opened and filled!");
double myStopLossPrice=myOrder.getOpenPrice()+60*myInstrument.getPipValue();
myOrder.setStopLossPrice(myStopLossPrice,OfferSide.ASK,20);
myOrder.waitForUpdate(1000);
myConsole.getOut().println(myOrder+"stopLoss is setted!");
}
}
the onMessage method is:
public void onMessage(IMessage message) throws JFException {
if(message.getOrder()==myOrder && message.getReasons().contains(IMessage.Reason.ORDER_CHANGED_SL)){
boolean OrderLabelEqual=message.getOrder().getLabel()=="mySimpleOrder"+myOrderCounter;//something Wrong!!
myConsole.getInfo().println(myOrder.getLabel()+"'s stop loss changed to: "
+myOrder.getStopLossPrice()+"|| OrderLabelEqual: "+OrderLabelEqual);
}
but the results is(part):
...
16:39:36 mySimpleOrder4's stop loss changed to: 1.16453|| OrderLabelEqual: false
15:38:34 mySimpleOrder4's stop loss changed to: 1.16653|| OrderLabelEqual: false
15:10:21 mySimpleOrder4's stop loss changed to: 1.16854|| OrderLabelEqual: false
11:27:13 mySimpleOrder4's stop loss changed to: 1.17054|| OrderLabelEqual: false
00:00:00 FILLED SELL 0.01 @ 1.16654stopLoss is setted!
....
the OrderLabelEqual object ought to be "true",but always return "false",WHY!!!
the full class is testOrderLabel.java in the attachment.
thanks for help!!!!!!!!!!!