Topics

Forum Topics not found

Replies

ctid976384
11 Sep 2020, 12:39 ( Updated at: 21 Dec 2023, 09:22 )

Not sure if this is the same issue, but I am experiencing the same behavior if an indicator is based on external data series and those external data series get recalculated. As an example, you can take the code below which draws a circle on each slope change of the source data series. Create a new chart with an Oscillator, let's take Stochastic as an example, then attach the custom indicator below and set the Stochastic %D as its source. Once set up, try to change %K Period and you will see that dots will remain from the prior result, although the custom indicator recalculates and prints new dots.

Note: By changing the Parameter in the indicator you can force the recalculation which will successfully remove old objects. Explicitly adding Chart.RemoveObject didn't fix the issue.

using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleBug : Indicator
    {
        [Parameter]
        public DataSeries Source { get; set; }

        [Parameter]
        public int Parameter { get; set; }

        public override void Calculate(int index)
        {
            if (index < 3 || Source[index] > Source[index - 1] == Source[index - 1] > Source[index - 2])
            {
                Chart.RemoveObject(index.ToString());
            }
            else
            {
                IndicatorArea.DrawIcon(index.ToString(), ChartIconType.Circle, index - 1, Source[index - 1], Color.Red);
            }
        }
    }
}


@ctid976384

ctid976384
26 Aug 2020, 12:58

Agreed.


@ctid976384