Indicator painter and errors in charting in designer
Atom
18.05.2019


Sam

Фотография
I'm trying to use a custom indicator in designer and use the indicatorPainter to display it. I assume it can be done, but the helps are not real clear. I have the indicator returning a SingleIndicatorValue<ValuesClass> where ValuesClass is a class that contain the multiple values to chart (values for 6 lines)
In the strategy, I have
ChartElementForIndicatorPainter = new ChartIndicatorElement();
ChartElementForIndicatorPainter.IndicatorPainter = new ValuesClassIndicatorPainter();
This is as far as the help gets me. It doesn't even say where this should go. I added it to the strategy initialization.

In the OnStarted method I add it to the chart
chart.AddElement(area, ChartElementForIndicatorPainter);

But then in the "OnProcess" method, when I call
NewIndicator?.Invoke(indicatorReturn);
It gives me 2 errors.




S#.Designer 5/18/2019 8:54:21 PM +10:00 Error System.InvalidOperationException: The element was already attached to chart before.
at StockSharp.Xaml.Charting.ChartArea.#=z7NgDDY12SFSN.OnAdding(IChartElement #=zqJpzaMY=)
at Ecng.Collections.BaseCollection`2.Add(TItem item)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

HistoryEmulationConnector 12/11/2018 4:40:00 AM +00:00 Error System.InvalidCastException: Can't convert Signaller.Indicators.ValuesClass of type 'Signaller.Indicators.ValuesClass to type 'System.Decimal'. ---> System.ArgumentException: Can't convert Signaller.Indicators.ValuesClass of type 'Signaller.Indicators.ValuesClass to type 'System.Decimal'.
Parameter name: value
at Ecng.Common.Converter.To(Object value, Type destinationType)
--- End of inner exception stack trace ---
at Ecng.Common.Converter.To(Object value, Type destinationType)
at Ecng.Common.Converter.To[T](Object value)
at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.#=z83WVYsU=(ReadOnlyCollection`1 #=zf3x5daU=, Int32 #=zyjj9yeM=)
at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.#=zaW8q4VLX7QUBLKN88WpP1wU=.#=zCjI32oDyepDrpW8skQ==(Int32 #=zojXel4E=)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at Ecng.Collections.CollectionHelper.IsEmpty[T](IEnumerable`1 source)
at #=z0DJIOHexY32No9PMDP1u_SU0nCszuBgy288gF$JeKlZt1P1_rnibJ8_nsYN8.#=zywKyUNA=[TX1](IEnumerableEx`1 #=zodDz6VA=)
at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.Draw(ChartDrawData data)
at #=zFL$1bzvYBLQbE9N2Sc32mMXoihonASmdP0sTsIJdrx0tOTDOI_QGtou5$cbR.#=zrbrG0UoScFKf(ChartDrawData #=z7f$H9xY=)
at #=zFL$1bzvYBLQbE9N2Sc32mMXoihonASmdP0sTsIJdrx0tOTDOI_QGtou5$cbR.#=zywKyUNA=(ChartDrawData #=z7f$H9xY=)
at StockSharp.Xaml.Charting.Chart.#=zosvLqDQVWtH9.#=zywKyUNA=(ChartDrawData #=z7f$H9xY=)
at StockSharp.Xaml.Charting.ChartPanel.Draw(ChartDrawData data)
at StockSharp.Xaml.Diagram.Elements.ChartDiagramElement.#=zIVzy6y9XB8CEwFcScKoYbYU=(IChart #=zs6cBqJg=)
at System.Action`1.Invoke(T obj)
at StockSharp.Algo.Connector.OnProcessMessage(Message message)
at StockSharp.Algo.Testing.HistoryEmulationConnector.OnProcessMessage(Message message)

In debugging it externally, it never hits the breakpoints of the indicatorpainter, though I don't know if it ever would anyways. It obviously is not using the painter if it is trying to change the class into a decimal.

Is it possible to use the indicator painter with the designer? How do you hook it up? The helps are pretty sparse about this.



Спасибо:


Mikhail Sukhov

Фотография
Дата: 18.05.2019
Ответить


Hello

Currently, Designer support custom indicator (and their painter) only via app.config file. It means you need extract your code into dedicated assembly and add into Designer.exe.config the following code:

Код
<customIndicators>
    <indicator type="ChartElementForIndicatorPainter, MyAssembly" painter="ValuesClassIndicatorPainter, MyAssembly" />
</customIndicators>
Спасибо:


Добавить файлы через драг-н-дроп, , или вставить из буфера обмена.

loading
clippy