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.

Howto: Have more than one instrument in the config dialogue?
 Post subject: Howto: Have more than one instrument in the config dialogue? Post rating: 0   New post Posted: Thu 26 May, 2011, 15:39 

User rating: -
Hi,

I'm writing a strategy that runs on more than one currency. How can I enable the user to choose more than one instrument in the configuration dialogue?

I know you can do this:
    @Configurable("Instrument")
    public Instrument selectedInstrument = Instrument.EURUSD;



I tried the following without success (nothing shown on the config box):
  @Configurable("Instruments")
  public Instrument[] selectedInstruments;


I'd like to loop over the instruments later like that:
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
  for(int a = 0; a < this.selectedInstruments.length; a++) {
    if (!instrument.equals(this.selectedInstruments[a]) || !period.equals(this.selectedPeriod)) return;
      // Do something!
    }
  }
}


Any clues?


Thanks in advance!

Kind regards,

Roberto


 
 Post subject: Re: Howto: Have more than one instrument in the config dialo Post rating: 0   New post Posted: Fri 27 May, 2011, 07:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider the following approach:
@Configurable("Instrument1")
public Instrument instrument1 = Instrument.EURUSD;
@Configurable("Instrument2")
public Instrument instrument2;
@Configurable("Instrument3")
public Instrument instrument3;


 

Jump to:  

cron
  © 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