Dukascopy
 
 
Wiki JStore Search Login

Annotate specific chart
 Post subject: Annotate specific chart Post rating: 0   New post Posted: Sat 22 Aug, 2015, 15:31 

User rating: 0
Joined: Fri 04 Apr, 2014, 16:35
Posts: 50
Location: Monaco, Monte-Carlo
Hi,
I use several charts for the same instrument. (1min, 3 min, ticks and 1 hour). How can I specify the specific chart for which I want to add an annotation to?

e.g that I want to add a vertical line only on my 1 min chart?

Thanks


 
 Post subject: Re: Annotate specific chart Post rating: 0   New post Posted: Thu 27 Aug, 2015, 16:43 

User rating: 0
Joined: Fri 04 Apr, 2014, 16:35
Posts: 50
Location: Monaco, Monte-Carlo
Sorry, I should clarify: I want to add the annotations automatically via code. Not adding them manually with my mouse into the charts!


 
 Post subject: Re: Annotate specific chart Post rating: 0   New post Posted: Fri 28 Aug, 2015, 03:19 
User avatar

User rating: 0
Joined: Fri 10 Oct, 2014, 00:35
Posts: 58
Location: New Zealand, Auckland
Hi jamesadk

I do a similar thing using methods provided by IContext and IChart.

To get a list of all open charts:
Set<IChart> openCharts = context.getCharts();

To identify the particular chart you want, I think you will need to check the instrument &/or period , e.g.
Instrument instrument = chart.getInstrument();
Period period = getSelectedPeriod()
if ( instrument.equals(desiredInstrument) && period.equals(desiredPeriod) ) {
    ...
}

Once you've identified the desired chart, you can use methods in IChart and IChartObjectFactory to draw, e.g.
IChartObjectFactory factory = chart.getChartObjectFactory();
IVerticalLineChartObject vLine = factory.createVerticalLine();
...

You may also find it useful to get the chart last selected by the mouse:
IChart activeChart = context.getLastActiveChart();

There may be a better approach, but this worked for me.

Cheers
Tony


 

Jump to:  

  © 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