Cannot assign CORNER, X- and YDISTANCE attribute to IChartObject.Type.LABEL. What is the problem (see code)? BTW, the built-in editor is a nightmare; it shlould not convert tabs into spaces!
package jforex;
import java.util.*;
import java.awt.Font;
import java.awt.Color;
import com.dukascopy.api.*;
public class Hello implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private Font font = new Font("Arial Black", Font.BOLD, 12);
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 {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
context.getChart(Instrument.EURUSD).remove("hello");
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
if(instrument == Instrument.EURUSD){
IChart chart;
IChartObject hello;
try{
chart = context.getChart(instrument);
hello = chart.get("hello");
if (hello != null) {
//hello.move(tick.getTime(), tick.getBid());
hello.setAttrColor(IChartObject.ATTR_COLOR.COLOR, Color.RED); // works
hello.setAttrInt(IChartObject.ATTR_INT.CORNER, 0); // no effect
hello.setAttrInt(IChartObject.ATTR_INT.XDISTANCE, 100); // no effect
hello.setAttrInt(IChartObject.ATTR_INT.YDISTANCE, 100); // no effect
console.getOut().println(hello.getAttrInt(IChartObject.ATTR_INT.CORNER));
console.getOut().println(hello.getAttrInt(IChartObject.ATTR_INT.XDISTANCE));
console.getOut().println(hello.getAttrInt(IChartObject.ATTR_INT.YDISTANCE));
}else{
chart.draw("hello", IChart.Type.LABEL, tick.getTime(), tick.getBid()).setText("Hello World!", font);
}
}catch(Exception ex){
console.getOut().println(ex);
}
}
}
}