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.

multi instrument subscribtion
 Post subject: multi instrument subscribtion Post rating: 0   New post Posted: Tue 31 Jul, 2012, 04:18 

User rating: 0
Joined: Tue 31 Jul, 2012, 03:47
Posts: 2
Location: Malaysia, Kuala Lumpur
Hi I am trying to subscribe to 4 pairs on my strategy ..everything complies ok but it had error when running

code is as follows
public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
        this.indicators = context.getIndicators();
        this.history = context.getHistory();
        this.engine = context.getEngine();
        this.account = context.getAccount();
        this.context = context;
       Set<Instrument> instruments = new HashSet<Instrument>();
        instruments.add(Instrument.EURUSD);
        instruments.add(Instrument.EURCAD);
        instruments.add(Instrument.USDSGD);
        instruments.add(Instrument.GBPUSD);
               
        context.setSubscribedInstruments(instruments);

        if (appliedPrice.equals(AppliedPrice.OPEN)) {
            appliedPriceParam = 0;
        } else if (appliedPrice.equals(AppliedPrice.CLOSE)) {
            appliedPriceParam = 1;
        } else if (appliedPrice.equals(AppliedPrice.HIGH)) {
            appliedPriceParam = 2;
        } else if (appliedPrice.equals(AppliedPrice.LOW)) {
            appliedPriceParam = 3;
        }

        feedDescriptor = new FeedDescriptor();
        feedDescriptor.setDataType(DataType.RENKO);
        feedDescriptor.setOfferSide(offerSide);
        feedDescriptor.setInstrument(instrument);
        feedDescriptor.setPriceRange(PriceRange.valueOf(priceRangePips));
        feedDescriptor.setFilter(filter);

        IChart chart = context.getChart(instrument);
        if (chart != null) {
            chart.addIndicator(indicators.getIndicator("JAMES_INDI"), new Object[]{appliedPriceParam });
        }

        context.subscribeToRenkoBarFeed(instrument, offerSide, PriceRange.valueOf(priceRangePips), this);


and I get the following error when running

2012-07-23 00:00:00 Exception java.lang.IllegalArgumentException: Could not load data for Instrument=null because this Instrument isn't subscribed! @ jforex.strategies.indicators.tradebynumbers.onStart(tradebynumbers.java:102)


 
 Post subject: Re: multi instrument subscribtion Post rating: 0   New post Posted: Tue 31 Jul, 2012, 07:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Use the synchronous 2-argument method:
https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IContext.html#setSubscribedInstruments(java.util.Set,%20boolean)


 
 Post subject: Re: multi instrument subscribtion Post rating: 0   New post Posted: Thu 02 Aug, 2012, 07:45 

User rating: 0
Joined: Tue 31 Jul, 2012, 03:47
Posts: 2
Location: Malaysia, Kuala Lumpur
Thank you I will try

Is it possible to backtest with MA's on renko? I saw one of your strategy "Anotherbrick" it says is not possible in historic tester


 
 Post subject: Re: multi instrument subscribtion Post rating: 0   New post Posted: Thu 02 Aug, 2012, 07:48 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
James1 wrote:
Is it possible to backtest with MA's on renko?
Yes.
James1 wrote:
I saw one of your strategy "Anotherbrick" it says is not possible in historic tester
Presumably since then the platform has been enhanced to feature the back-testing with feeds.


 

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