﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">Indicator painter and errors in charting in designer</title>
  <id>~/topic/10713/indicator-painter-and-errors-in-charting-in-designer/</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-06-04T03:41:54Z</updated>
  <logo>https://stocksharp.ru/images/logo.png</logo>
  <link href="https://stocksharp.ru/handlers/atom.ashx?category=topic&amp;id=10713" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.ru/posts/m/47523/</id>
    <title type="text">Hello Currently, Designer support custom indicator (and their painter) only via app.config file. It ...</title>
    <published>2019-05-18T18:44:32Z</published>
    <updated>2019-05-18T18:44:32Z</updated>
    <author>
      <name>Mikhail Sukhov</name>
      <uri>https://stocksharp.ru/users/201/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;[code]&lt;customIndicators&gt;
&lt;indicator type="ChartElementForIndicatorPainter, MyAssembly" painter="ValuesClassIndicatorPainter, MyAssembly" /&gt;
&lt;/customIndicators&gt;[/code]&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/47522/</id>
    <title type="text">I&amp;apos;m trying to use a custom indicator in designer and use the indicatorPainter to display it. I assum...</title>
    <published>2019-05-18T14:06:29Z</published>
    <updated>2019-05-18T14:06:29Z</updated>
    <author>
      <name>Sam</name>
      <uri>https://stocksharp.ru/users/104377/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;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&lt;ValuesClass&gt; 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.&lt;/p&gt;
&lt;p&gt;In the OnStarted method I add it to the chart
chart.AddElement(area, ChartElementForIndicatorPainter);&lt;/p&gt;
&lt;p&gt;But then in the &amp;quot;OnProcess&amp;quot; method, when I call
NewIndicator?.Invoke(indicatorReturn);
It gives me 2 errors.&lt;/p&gt;
&lt;p&gt;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)&lt;/p&gt;
&lt;p&gt;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'. ---&amp;gt; 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&lt;code&gt;1 #=zf3x5daU=, Int32 #=zyjj9yeM=) at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.#=zaW8q4VLX7QUBLKN88WpP1wU=.#=zCjI32oDyepDrpW8skQ==(Int32 #=zojXel4E=) at System.Linq.Enumerable.WhereSelectEnumerableIterator&lt;/code&gt;2.MoveNext()
at System.Linq.Enumerable.&lt;CastIterator&gt;d__97&lt;code&gt;1.MoveNext() at System.Linq.Enumerable.&amp;lt;CastIterator&amp;gt;d__97&lt;/code&gt;1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable&lt;code&gt;1 source) at Ecng.Collections.CollectionHelper.IsEmpty[T](IEnumerable&lt;/code&gt;1 source)
at #=z0DJIOHexY32No9PMDP1u_SU0nCszuBgy288gF$JeKlZt1P1_rnibJ8_nsYN8.#=zywKyUNA=[TX1](IEnumerableEx&lt;code&gt;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&lt;/code&gt;1.Invoke(T obj)
at StockSharp.Algo.Connector.OnProcessMessage(Message message)
at StockSharp.Algo.Testing.HistoryEmulationConnector.OnProcessMessage(Message message)&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Is it possible to use the indicator painter with the designer? How do you hook it up? The helps are pretty sparse about this.&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>