Hello Support,
Why I cannot use the
subscribeToFeed method within an indicator? If I have to use the method
history.getTickBar(Instrument.EURJPY, OfferSide.ASK, TickBarSize.valueOf(300), i);
, the execution is bloody slow.
Thank you
08:50:06 The method subscribeToFeed(IFeedDescriptor, myTickCandleIndicator) is undefined for the type IIndicatorContext
08:50:06 ^^^^^^^^^^^^^^^
08:50:06 ctx.subscribeToFeed(feedDescriptorBid, this);
08:50:06 4. ERROR
public class myTickCandleIndicator implements IIndicator, IDrawingIndicator{
private IndicatorInfo indicatorInfo;
private InputParameterInfo[] inputParameterInfos;
private OutputParameterInfo[] outputParameterInfos;
private OptInputParameterInfo[] optInputParameterInfos;
private IBar[][] inputs = new IBar[3][];
private int[][] outputs = new int[1][];
private Period[] periods = new Period[7];
public IConsole console;
private DecimalFormat df ;
private DateFormat dateFormat ;
private IHistory history;
private IIndicatorContext ctx;
private IFeedDescriptor feedDescriptorAsk = new TickBarFeedDescriptor(Instrument.EURJPY, TickBarSize.valueOf(300), OfferSide.ASK);
private IFeedDescriptor feedDescriptorBid = new TickBarFeedDescriptor(Instrument.EURJPY, TickBarSize.valueOf(300), OfferSide.BID);
public void onStart(IIndicatorContext context) {
this.console = context.getConsole();
this.history = context.getHistory();
ctx = context;
ctx.setSubscribedInstruments(java.util.Collections.singleton(feedDescriptorAsk.getInstrument()), true);
ctx.subscribeToFeed(feedDescriptorAsk, this);
ctx.setSubscribedInstruments(java.util.Collections.singleton(feedDescriptorBid.getInstrument()), true);
ctx.subscribeToFeed(feedDescriptorBid, this);
dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm") ;
indicatorInfo = new IndicatorInfo("myCUSTOMCANDLE", "Custom candle", "", true, false, false, 3, 0, 1);
indicatorInfo.setRecalculateAll(true);
inputParameterInfos = new InputParameterInfo[]{
new InputParameterInfo("bid", InputParameterInfo.Type.BAR){{
//setPeriod(Period.ONE_MIN);
setOfferSide(OfferSide.BID);
}},
new InputParameterInfo("ask", InputParameterInfo.Type.BAR){{
//setPeriod(Period.ONE_MIN);
setOfferSide(OfferSide.ASK);
}},
new InputParameterInfo("main", InputParameterInfo.Type.BAR)
};
outputParameterInfos = new OutputParameterInfo[]{
new OutputParameterInfo("CustomCandle", OutputParameterInfo.Type.INT, OutputParameterInfo.DrawingStyle.LINE) {{
setDrawnByIndicator(true);
}}
};
}