Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

method subscribeToFeed is undefined for the type IIndicatorContext
 Post subject: method subscribeToFeed is undefined for the type IIndicatorContext Post rating: 0   New post Posted: Fri 04 Apr, 2014, 09:57 

User rating: 2
Joined: Mon 05 Nov, 2012, 11:56
Posts: 80
Location: Germany,
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);
          }}
      };
       
    }


 
 Post subject: Re: method subscribeToFeed is undefined for the type IIndicatorContext Post rating: 0   New post Posted: Fri 04 Apr, 2014, 15:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
consider using an IDE for instant assistance on compile-time errors, see:
https://www.dukascopy.com/wiki/#Use_in_Eclipse
or
https://www.dukascopy.com/wiki/#Use_in_NetBeans


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com