Dukascopy
 
 
Wiki JStore Search Login

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

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

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

how to subscribe to specific symbols
 Post subject: how to subscribe to specific symbols Post rating: 0   New post Posted: Tue 21 Jun, 2011, 15:47 

User rating: 0
Joined: Tue 21 Jun, 2011, 15:44
Posts: 2
Location: CA
i only want to subscribe to 2 symbols from my strategy. however my output shows that i have subscribed to 7 symbols. mind u i have all of those symbols on the charts. how do i fix it.

14:41:48 instruments after subscription + EUR/USD, EUR/JPY, AUD/USD, USD/CHF, USD/CAD, GBP/USD, USD/JPY, EUR/GBP,


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();
       
         Set<Instrument> instruments = new HashSet<Instrument>();
         instruments.add(Instrument.EURUSD);
         instruments.add(Instrument.AUDUSD);
         context.setSubscribedInstruments(instruments);
         // wait max 5 seconds for the instruments to get subscribed
      int i = 5;
      while (!context.getSubscribedInstruments().containsAll(instruments)) {
         console.getOut().println(" not subscribed yet");
         try {
            Thread.sleep(1000);
         } catch (InterruptedException e) {
            console.getOut().println(e.getMessage());
         }
         i--;
      }
 
      console.getOut().print("instruments after subscription + ");
       
      for (Instrument in : context.getSubscribedInstruments()) {
         console.getOut().print( in + ", ");
      }
      console.getOut().println();
     
   }
         


 
 Post subject: Re: how to subscribe to specific symbols Post rating: 0   New post Posted: Thu 30 Jun, 2011, 09:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
IContext.getSubscribedInstruments() essentially returns all instruments which you see at the Workspace pane under Instruments folder. So if you remove the instruments from that folder they will be no more in IContext.getSubscribedInstruments().


 

Jump to:  

  © 1998-2025 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