ChartObjects.DrawText drawing on just last 10 bars and deleting after new bar

Created at 10 Feb 2015, 10:18
LS

LSR2412

Joined 07.11.2014

ChartObjects.DrawText drawing on just last 10 bars and deleting after new bar
10 Feb 2015, 10:18


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class timestampsforbars : Indicator
    {

        public override void Calculate(int index)
        {
      

            if (MarketSeries.OpenTime[index] < Server.Time.AddMinutes(-65))

                ChartObjects.RemoveObject(index.ToString());
           
           else if (MarketSeries.OpenTime[index - 8] > Server.Time.AddMinutes(-65))

                ChartObjects.DrawText(index.ToString(), "x", index, MarketSeries.High[index] + 0.0005, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.LightGray);


        }
    }
}

I would like to have some markings drawn on chart with ChartObjects.DrawText on only last 10 bars for example. I manage to limit drawing to last 10 bars, but as new bar is completed, last value (now 11 bars ago) should be deleted, and I have issue with deleting those. Is it possible...what I have done wrong with code above? Thanks


@LSR2412
Replies

Spotware
16 Feb 2015, 11:23

We can recommend you to contact one of our Partners or post a job in Development Jobs section.


@Spotware