How to Explain the Situation?? the Calgo'builder is wrong???

Created at 19 Apr 2018, 21:17
Bits's avatar

Bits

Joined 14.03.2018

How to Explain the Situation?? the Calgo'builder is wrong???
19 Apr 2018, 21:17


Who can Explain the calgo's build error??? Use below code, Whether​ it should not be  draw a indicator line And drawtext "NAN" in the high of every Bar or draw a indicator line in the price 107.39 and drawText 107.39 in the high of every Bar,  but the result is Disappointing​...
​the drawText(result) is107.39, but the indicatot not draw a indicator line
Is it my fault?​????
 




namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CS : Indicator
    {
        [Output("main", Color = Colors.Yellow)]
        public IndicatorDataSeries Result { get; set; }
        protected override void Initialize()
        {
        }
        public override void Calculate(int index)
        {
            if (index == 0)
            {
                Result[0] = 107.39;
            }
            Result[index] = 107.39;
            Result[index - 1] = double.NaN;

            ChartObjects.DrawText(index.ToString(), Result[index].ToString(), index, MarketSeries.High[index] + 0.01);

        }
    }
}


@Bits
Replies

Bits
19 Apr 2018, 21:20 ( Updated at: 21 Dec 2023, 09:20 )

RE:

yearn2012 said:

Who can Explain the calgo's build error??? Use below code, Whether​ it should not be  draw a indicator line And drawtext "NAN" in the high of every Bar or draw a indicator line in the price 107.39 and drawText 107.39 in the high of every Bar,  but the result is Disappointing​...
​the drawText(result) is107.39, but the indicatot not draw a indicator line
Is it my fault?​????
 




namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CS : Indicator
    {
        [Output("main", Color = Colors.Yellow)]
        public IndicatorDataSeries Result { get; set; }
        protected override void Initialize()
        {
        }
        public override void Calculate(int index)
        {
            if (index == 0)
            {
                Result[0] = 107.39;
            }
            Result[index] = 107.39;
            Result[index - 1] = double.NaN;

            ChartObjects.DrawText(index.ToString(), Result[index].ToString(), index, MarketSeries.High[index] + 0.01);

        }
    }
}

The Result property show two diffirent  value??????


@Bits

PanagiotisCharalampous
20 Apr 2018, 09:53

Hi yearn2012,

The reason you do not see a line is because you eventually make all Result values NaN with the following line of code

Result[index - 1] = double.NaN;

Best Regards,

Panagiotis


@PanagiotisCharalampous