correlation between timeframes

Created at 05 Aug 2016, 22:37
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!
CE

Cezary

Joined 28.05.2014

correlation between timeframes
05 Aug 2016, 22:37


Hi,

I try to create an indicator which has to access data from higher timeframe.

for instance:

I attache the indicator to M15 and would like to access data from H4 data series

which corresponds to the same real time.

public override void Calculate(int index)
        {

}

I can't find anything intuitive in the API to use for that purpose.

Could someone tell how to get from above function to H4 data series?

 

Regards,

Cezary


@Cezary
Replies

croucrou
05 Aug 2016, 23:12

You have to try better with your searching. Here it is:

/api/guides/indicators#el12


@croucrou

Cezary
05 Aug 2016, 23:24

RE:

croucrou said:

You have to try better with your searching. Here it is:

/api/guides/indicators#el12

Great ! Thanks !


@Cezary

Cezary
06 Aug 2016, 00:09

RE:

croucrou said:

You have to try better with your searching. Here it is:

/api/guides/indicators#el12

 

Hi,

It would be good but something is wrong. Maybe API error.

protected override void Initialize()
        {
            ms = MarketData.GetSeries(TimeFrame.Hour);
        }

        public override void Calculate(int index)
        {
            var idx = ms.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]);
            Print("Time , index , idx = " + MarketSeries.OpenTime[index] + "---" + index + "---" + idx);

}

 

and I get logs (last part) run on M15 chart:

 

05/08/2016 23:01:55.802 | Time , index , idx = 2016-08-05 18:00:00---4277---8918
05/08/2016 23:01:55.802 | Time , index , idx = 2016-08-05 18:15:00---4278----1
05/08/2016 23:01:55.802 | Time , index , idx = 2016-08-05 18:30:00---4279----1
05/08/2016 23:01:55.817 | Time , index , idx = 2016-08-05 18:45:00---4280----1
05/08/2016 23:01:55.817 | Time , index , idx = 2016-08-05 19:00:00---4281---8919
05/08/2016 23:01:55.817 | Time , index , idx = 2016-08-05 19:15:00---4282----1
05/08/2016 23:01:55.817 | Time , index , idx = 2016-08-05 19:30:00---4283----1
05/08/2016 23:01:55.817 | Time , index , idx = 2016-08-05 19:45:00---4284----1

 

 

So, the  GetIndexByExactTime worked only for the first 15 minute.For next 3 is always 1.

Is it intented or API error ?

Regards,

Cezary

 

 


@Cezary

croucrou
06 Aug 2016, 15:24

There is no GetIndexByExactTime in the Guide. Why did you use it?

To access another timeframe of the same asset, GetIndexByTime is enough.

I believe GetIndexByExactTime becomes useful, when you refer to another symbol, which might have different time sessions.


@croucrou

Cezary
07 Aug 2016, 20:33

RE:

croucrou said:

There is no GetIndexByExactTime in the Guide. Why did you use it?

To access another timeframe of the same asset, GetIndexByTime is enough.

I believe GetIndexByExactTime becomes useful, when you refer to another symbol, which might have different time sessions.

I changed to GetIndexByTime and it helped.

Thanks !


@Cezary