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.

IChart.setFeedDescriptor() incorrectly switches periods
 Post subject: IChart.setFeedDescriptor() incorrectly switches periods Post rating: 0   New post Posted: Fri 15 Dec, 2017, 22:16 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
Hello,

i'm trying to programmatically change selected period for chart and it does not work correctly.
Title of the chart changes whereas dropdown still shows old period. See screenshot.

Image

Sample strategy to reproduce is below.
Steps to reproduce:
1. Open any chart from "Instruments" and manually select "Period = 1 minute"
2. Click button "Set 4H" button on Strategy's pane

Expected behavior: both title and dropdown should show "4H / 4 Hours" as selected time frame.

package jforex.experimental;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.IFeedDescriptor;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SetPeriodBugDemoStrategy implements IStrategy {
    private IContext context;

    private String myTabTitle = "Set Chart Period Bug";
    private JPanel myTab;

    @Override
    public void onStart(IContext context) throws JFException {
        this.context = context;
        myTab = context.getUserInterface().getLeftTab(myTabTitle);

        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                IChart chart = SetPeriodBugDemoStrategy.this.context.getLastActiveChart();
                IFeedDescriptor fd = chart.getFeedDescriptor();

                fd.setPeriod(Period.FOUR_HOURS);
                chart.setFeedDescriptor(fd);
            }
        };

        JButton button = new JButton("Set 4H");
        button.addActionListener(actionListener);
        myTab.add(button);
    }

    public void onStop() throws JFException {
        context.getUserInterface().removeLeftTab(myTabTitle);
    }

    @Override public void onTick(Instrument instrument, ITick tick) throws JFException {}
    @Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
    @Override public void onMessage(IMessage message) throws JFException {}
    @Override public void onAccount(IAccount account) throws JFException {}
}


Attachments:
Set Chart Period.png [12.19 KiB]
Downloaded 297 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: IChart.setFeedDescriptor() incorrectly switches periods Post rating: 0   New post Posted: Thu 21 Dec, 2017, 10:54 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This has been fixed and will be available with next platform release.


 

Jump to:  

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