﻿<?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-04-23T00:11:31Z</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">Hello&lt;br /&gt;&lt;br /&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;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&amp;lt;customIndicators&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;indicator type=&amp;quot;ChartElementForIndicatorPainter, MyAssembly&amp;quot; painter=&amp;quot;ValuesClassIndicatorPainter, MyAssembly&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;/customIndicators&amp;gt;&lt;/div&gt;&lt;/div&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">I&amp;#39;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&amp;lt;ValuesClass&amp;gt; where ValuesClass is a class that contain the multiple values to chart (values for 6 lines) &lt;br /&gt;In the strategy, I have&lt;br /&gt;    ChartElementForIndicatorPainter = new ChartIndicatorElement();&lt;br /&gt;            ChartElementForIndicatorPainter.IndicatorPainter = new ValuesClassIndicatorPainter();&lt;br /&gt;This is as far as the help gets me. It doesn&amp;#39;t even say where this should go. I added it to the strategy initialization.&lt;br /&gt;&lt;br /&gt;In the OnStarted method I add it to the chart&lt;br /&gt;chart.AddElement(area, ChartElementForIndicatorPainter);&lt;br /&gt;&lt;br /&gt;But then in the &amp;quot;OnProcess&amp;quot; method, when I call &lt;br /&gt;                NewIndicator?.Invoke(indicatorReturn);&lt;br /&gt;It gives me 2 errors.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;S#.Designer	5/18/2019 8:54:21 PM +10:00	Error	System.InvalidOperationException: The element was already attached to chart before.&lt;br /&gt;   at StockSharp.Xaml.Charting.ChartArea.#=z7NgDDY12SFSN.OnAdding(IChartElement #=zqJpzaMY=)&lt;br /&gt;   at Ecng.Collections.BaseCollection`2.Add(TItem item)&lt;br /&gt;   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)&lt;br /&gt;   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)&lt;br /&gt;&lt;br /&gt;HistoryEmulationConnector	12/11/2018 4:40:00 AM +00:00	Error	System.InvalidCastException: Can&amp;#39;t convert Signaller.Indicators.ValuesClass of type &amp;#39;Signaller.Indicators.ValuesClass to type &amp;#39;System.Decimal&amp;#39;. ---&amp;gt; System.ArgumentException: Can&amp;#39;t convert Signaller.Indicators.ValuesClass of type &amp;#39;Signaller.Indicators.ValuesClass to type &amp;#39;System.Decimal&amp;#39;.&lt;br /&gt;Parameter name: value&lt;br /&gt;   at Ecng.Common.Converter.To(Object value, Type destinationType)&lt;br /&gt;   --- End of inner exception stack trace ---&lt;br /&gt;   at Ecng.Common.Converter.To(Object value, Type destinationType)&lt;br /&gt;   at Ecng.Common.Converter.To[T](Object value)&lt;br /&gt;   at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.#=z83WVYsU=(ReadOnlyCollection`1 #=zf3x5daU=, Int32 #=zyjj9yeM=)&lt;br /&gt;   at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.#=zaW8q4VLX7QUBLKN88WpP1wU=.#=zCjI32oDyepDrpW8skQ==(Int32 #=zojXel4E=)&lt;br /&gt;   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()&lt;br /&gt;   at System.Linq.Enumerable.&amp;lt;CastIterator&amp;gt;d__97`1.MoveNext()&lt;br /&gt;   at System.Linq.Enumerable.&amp;lt;CastIterator&amp;gt;d__97`1.MoveNext()&lt;br /&gt;   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)&lt;br /&gt;   at Ecng.Collections.CollectionHelper.IsEmpty[T](IEnumerable`1 source)&lt;br /&gt;   at #=z0DJIOHexY32No9PMDP1u_SU0nCszuBgy288gF$JeKlZt1P1_rnibJ8_nsYN8.#=zywKyUNA=[TX1](IEnumerableEx`1 #=zodDz6VA=)&lt;br /&gt;   at StockSharp.Xaml.Charting.IndicatorPainters.BaseChartIndicatorPainter.Draw(ChartDrawData data)&lt;br /&gt;   at #=zFL$1bzvYBLQbE9N2Sc32mMXoihonASmdP0sTsIJdrx0tOTDOI_QGtou5$cbR.#=zrbrG0UoScFKf(ChartDrawData #=z7f$H9xY=)&lt;br /&gt;   at #=zFL$1bzvYBLQbE9N2Sc32mMXoihonASmdP0sTsIJdrx0tOTDOI_QGtou5$cbR.#=zywKyUNA=(ChartDrawData #=z7f$H9xY=)&lt;br /&gt;   at StockSharp.Xaml.Charting.Chart.#=zosvLqDQVWtH9.#=zywKyUNA=(ChartDrawData #=z7f$H9xY=)&lt;br /&gt;   at StockSharp.Xaml.Charting.ChartPanel.Draw(ChartDrawData data)&lt;br /&gt;   at StockSharp.Xaml.Diagram.Elements.ChartDiagramElement.#=zIVzy6y9XB8CEwFcScKoYbYU=(IChart #=zs6cBqJg=)&lt;br /&gt;   at System.Action`1.Invoke(T obj)&lt;br /&gt;   at StockSharp.Algo.Connector.OnProcessMessage(Message message)&lt;br /&gt;   at StockSharp.Algo.Testing.HistoryEmulationConnector.OnProcessMessage(Message message)&lt;br /&gt;&lt;br /&gt;In debugging it externally, it never hits the breakpoints of the indicatorpainter, though I don&amp;#39;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;br /&gt;&lt;br /&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.</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>