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 add new feed and reload the chart?
 Post subject: How to add new feed and reload the chart? Post rating: 0   New post Posted: Fri 20 Sep, 2013, 19:13 

User rating: 0
Joined: Wed 12 Jun, 2013, 16:19
Posts: 18
Location: PolandPoland
Hi

It's possible to reload a chart window after change the feed data?

For example:

public class MyStrategy implements IStrategy, IFeedListener {
    //...
    @Override
    public void onStart(IContext context) throws JFException {

        this.chart = context.getLastActiveChart();

        // Create a new feed
        this.chartFeed = new TimePeriodAggregationFeedDescriptor(this.instrument, Period.TWENTY_SECS, this.chartFeed.getOfferSide());
        context.subscribeToFeed(this.chartFeed, this);
       
        // Try to apply new feed to active chart
        //this.chart.setFeedDescriptor(this.chartFeed); // this doesn't work because that method is not exists
        this.chart.repaint();
    }
    //...
}


 
 Post subject: Re: How to add new feed and reload the chart? Post rating: 1   New post Posted: Fri 20 Sep, 2013, 22:16 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
Quote:
// Try to apply new feed to active chart
//this.chart.setFeedDescriptor(this.chartFeed); // this doesn't work because that method is not exists
this.chart.repaint();
Addressing the comments above and how to achieve that functionality,
consult the reference Interface IFeedDescriptor then consider the following:

this.chart.getFeedDescriptor().setInstrument(this.chartFeed.getInstrument());
this.chart.getFeedDescriptor().setPeriod(this.chartFeed.getPeriod());
this.chart.getFeedDescriptor().setOfferSide(this.chartFeed.getOfferSide());


 
 Post subject: Re: How to add new feed and reload the chart? Post rating: 0   New post Posted: Sat 21 Sep, 2013, 11:32 

User rating: 0
Joined: Wed 12 Jun, 2013, 16:19
Posts: 18
Location: PolandPoland
CriticalSection wrote:
this.chart.getFeedDescriptor().setInstrument(this.chartFeed.getInstrument());
this.chart.getFeedDescriptor().setPeriod(this.chartFeed.getPeriod());
this.chart.getFeedDescriptor().setOfferSide(this.chartFeed.getOfferSide());


Thank's for Your answer. I modify the code:

public class MyStrategy implements IStrategy, IFeedListener {
    //...
    @Override
    public void onStart(IContext context) throws JFException {
 
        this.chart = context.getLastActiveChart();
 
        // Create a new feed
        //this.chartFeed = new TimePeriodAggregationFeedDescriptor(this.instrument, Period.TWENTY_SECS, this.chartFeed.getOfferSide()); // removed - it is unnecessary now
        //context.subscribeToFeed(this.chartFeed, this); // removed - it is unnecessary now
       
        // Change a feed period in active chart
        this.chart.getFeedDescriptor().setPeriod(Period.TWENTY_SECS); //new line
        this.chart.repaint();
    }
    //...
}


And now I have a another problem - the chart isn't refreshed/repainted after period was changed (I test it only in the strategy tester, in visual mode because Today the market is closed;) ).
How can I do it (repaint the chart)?


 
 Post subject: Re: How to add new feed and reload the chart? Post rating: 0   New post Posted: Mon 23 Sep, 2013, 12:55 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
MaxR wrote:
It's possible to reload a chart window after change the feed data?
What do you mean by reload? When you manually change the feed then the platform reloads the chart itself. If you do it from SDK, it is done by the SDK. There is no need to handle this yourself.
CriticalSection wrote:
Addressing the comments above and how to achieve that functionality,
consult the reference Interface IFeedDescriptor then consider the following:

this.chart.getFeedDescriptor().setInstrument(this.chartFeed.getInstrument());
this.chart.getFeedDescriptor().setPeriod(this.chartFeed.getPeriod());
this.chart.getFeedDescriptor().setOfferSide(this.chartFeed.getOfferSide());
There is no such functionality as changing the chart's feed from a strategy, however, you can do it programmatically from an SDK program:
https://www.dukascopy.com/wiki/#JForex_SDK/Open_a_chart_from_IClient
and also for back-testing:
https://www.dukascopy.com/wiki/#JForex_SDK/Change_chart_type


 

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