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