I'm currently developping an addon that should display technical analysis posted online.
I have a first indicator that POST all the drawing object on a database, on a JSON format.
The addon then retriew it an should draw it again to the chart.
The problem is that the draws object is not drawed at all when I apply an analysis
.
Here you can find the part of the code that cause me issues
public IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject { if (depObj != null) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) { DependencyObject child = VisualTreeHelper.GetChild(depObj, i); if (child != null && child is T) yield return (T)child; foreach (T childOfChild in FindVisualChildren<T>(child)) yield return childOfChild; } } } public void ApplyAnalysis(Analysis analysis) { // Charts is a list of opened chart un the NinjaTrader session wich is automaticaly updated when a new chart is opened or destroyed bool finded = false; foreach (var window in this.Charts) { window.Dispatcher.Invoke(new Action(() => { foreach (ChartControl cc in FindVisualChildren<ChartControl>(window)) { if (cc.Instrument.FullName == analysis.instrument) { finded = true; DisplayAnalysis(cc, analysis); } } })); } if(!finded) MessageBox.Show($"Please open a chart of {analysis.instrument} to apply the selected analysis"); } private void DisplayAnalysis(ChartControl chart, Analysis analysis) { foreach (var draw in analysis.draws.Elements()) { var toDraw = DrawingTool.RestoreFromXElement(draw, false); toDraw.CreateNewId(); chart.ChartObjects.Add(toDraw); // may ViewModel is an IndicatorBase DrawingTool.SetDrawingToolCommonValues(toDraw, toDraw.Tag, true, this, false); toDraw.IsLocked = false; } }
Comment