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

Created at 10 Feb 2015, 10:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
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