How to control the start time of count of cauculate for debug Custom Indicators

Created at 09 Apr 2018, 05:38
Bits's avatar

Bits

Joined 14.03.2018

How to control the start time of count of cauculate for debug Custom Indicators
09 Apr 2018, 05:38


Sometimes for Convenient to  debugger the indicator, i want to only cauculate the last bars form now,eg:only culculate the newest 10 bars,what i want to do?


@Bits
Replies

PanagiotisCharalampous
10 Apr 2018, 10:58

Hi yearn2012,

You can use a condition in the Calculate function and skip the calculation for bars before a certain time. See below

        private DateTime _openTime;
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }

        public override void Calculate(int index)
        {
            if (MarketSeries.OpenTime[index] > _openTime)
            {
                // Calculate Indicator;
            }
        }

Let me know if this helps,

Best Regards,

Panagiotis


@PanagiotisCharalampous

Bits
15 Apr 2018, 19:30

RE:

Panagiotis Charalampous said:

Hi yearn2012,

You can use a condition in the Calculate function and skip the calculation for bars before a certain time. See below

        private DateTime _openTime;
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }

        public override void Calculate(int index)
        {
            if (MarketSeries.OpenTime[index] > _openTime)
            {
                // Calculate Indicator;
            }
        }

Let me know if this helps,

Best Regards,

Panagiotis

it's right ,thanks!

 


@Bits