TimeFrame question

gorin since: 16 Jul 2013;

  05 Sep 2013, 14:41
TimeFrame question

Hello,

On the newly added feature for multi time-frames, if I have an indicator which is the daily moving average of a formula that uses H-L-C, I understand that the H-L-C needs to be of the daily series but do I also need to translate the index each time?
Specifically, I am trying to create the Chaikin Oscillator see definition at wikipedia.  
http://en.wikipedia.org/wiki/Accumulation/distribution_index

So, this is what I came up with according to my understanding. See uploaded algo here:
/algos/indicators/show/329

But, it does not display nothing for certain time-frames.
Any help is greatly appreciated.

bp2012 since: 31 Aug 2013;

  05 Sep 2013, 16:52

Hi gorin,

I'm still wrapping my head around the multi timeframe functionality as well, but thought I would post a quick comment. It looks like your code is only taking the index differences into consideration when it comes to displaying the results. I think that it also needs to be considered when calculating. 

Here is my understanding. Assume that you have 7000 bars available on a 1M chart marketseries. That marketseries represents 7000 minutes. Let's say you pull a marketseries for the Minute5 timeframe. It doesn't automatically pull only the bars that match your current chart time span. It may pull 8000 bars based on the data available. 8000 bars on a 5M series represents a much larger time span than is in your Minute1 chart. Therefore, if you use the index supplied in the calculate method you aren't going to get the results you expect. Hopefully this code snippet will make it clearer. If you put this in cAlgo and set your instance timeframe to Minute, the log will show the time differences between the chart data and the other time frame data.

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class TFDataTest : Indicator
    {
        [Parameter(DefaultValue = "Minute5")]
        public TimeFrame Period { get; set; }


        private MarketSeries ms;

        protected override void Initialize()
        {
            ms = MarketData.GetSeries(Period);
            Print("Chart Time Frame: " + TimeFrame + "     Data Time Frame: " + ms.TimeFrame);
            Print("Chart Bars: " + MarketSeries.Close.Count + "     Data Bars: " + ms.Close.Count);
            Print("Index 1000 Chart time: " + MarketSeries.OpenTime[1000].ToString("dd MMMM yyyy H:mm:ss") + "  Index 1000 Data time: " + ms.OpenTime[1000].ToString("dd MMMM yyyy H:mm:ss"));

        }

        public override void Calculate(int index)
        {
        }
    }
}

Good Luck!

- bp

gorin since: 16 Jul 2013;

  05 Sep 2013, 17:37

Hi bp,

Thanks for your reply. 
I understand what you are saying and your code, I also thought about it and tried it in the code but it still does not produce results under certain time-frames...
I think as far as the definition of the indicator is concerned it shouldn't be based on daily time-frame. The definition of MACD also says 12-day Ema - 26-day ema... but the calculation is not on daily time-frame only. 
I will test more cases with such indicators and post here again.