How to switch to open chart
How to switch to open chart
03 Nov 2024, 20:04
Hello,
In a plugin we can
- open a chart with
ChartManager.AddChartFrame(symbol.Name, TimeFrame.Hour)
- change a symbol and timeframe of an active chart
ChartManager.ActiveFrame.ChartContainer.OfType<ChartFrame>().Select(frame => frame.Chart).Where(c =>
c.IsActive).FirstOrDefault().TryChangeTimeFrameAndSymbol(symbol, TimeFrame.Hour);
But how do we just switch between open charts or what is the command to bring an open chart to the front or make it Visible ?
Kind Regards
TommyFFX
Replies
TommyFFX
07 Nov 2024, 22:32
RE: How to switch to open chart
TommyFFX said:
The only solution I Found is to Detach the chart I want to see and Attach it back..
Then I have the option to switch between ChartFrames in code..
but this seems a bit strange..
I'm using a combobox to switch between ChartFrames..
public void OnSymbolComboBox_SelectionChanged(ComboBoxSelectedItemChangedEventArgs e){
var symbol = string.IsNullOrEmpty(e.SelectedItem) ? null : tms.Symbols.GetSymbol(e.SelectedItem);
if (symbol != null)
{
var frames = FindAllChartFramesBySymbol(symbol);
var chartFrame = frames.FirstOrDefault();
if (chartFrame != null)
{
chartFrame.Detach();
chartFrame.Attach();
}
}
}
public IEnumerable<ChartFrame> FindAllChartFrames(){
return ChartManager.OfType<ChartFrame>();
}
public IEnumerable<ChartFrame> FindAllChartFramesBySymbol(Symbol symbol)
{
return FindAllChartFrames().Where(frame => frame.Chart.Symbol == symbol);
}
Up
@TommyFFX
PanagiotisCharalampous
08 Nov 2024, 06:31
Hi there,
But how do we just switch between open charts or what is the command to bring an open chart to the front or make it Visible ?
There is no such command.
Best regards,
Panagiotis
@PanagiotisCharalampous
TommyFFX
05 Nov 2024, 00:52
The only solution I Found is to Detach the chart I want to see and Attach it back..
Then I have the option to switch between ChartFrames in code..
but this seems a bit strange..
I'm using a combobox to switch between ChartFrames..
public void OnSymbolComboBox_SelectionChanged(ComboBoxSelectedItemChangedEventArgs e)
{
var symbol = string.IsNullOrEmpty(e.SelectedItem) ? null : tms.Symbols.GetSymbol(e.SelectedItem);
if (symbol != null)
{
var frames = FindAllChartFramesBySymbol(symbol);
var chartFrame = frames.FirstOrDefault();
if (chartFrame != null)
{
chartFrame.Detach();
chartFrame.Attach();
}
}
}
public IEnumerable<ChartFrame> FindAllChartFrames()
{
return ChartManager.OfType<ChartFrame>();
}
public IEnumerable<ChartFrame> FindAllChartFramesBySymbol(Symbol symbol)
{
return FindAllChartFrames().Where(frame => frame.Chart.Symbol == symbol);
}
@TommyFFX