In an indicator: Getting Different Symbol (in Multicurrency) with a different time frame

Created at 26 Oct 2020, 13:50
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!
JE

JeanPaul

Joined 17.10.2020

In an indicator: Getting Different Symbol (in Multicurrency) with a different time frame
26 Oct 2020, 13:50


I am in an indicator for Symbol SMaster with TimeFrame TFMaster (this is the main instrument in the chart), I want to access:

- SMaster with TFSlave

- SSlave with TFSlave

Bars[] _sMasterTFSlaveBars;
Bars[] _sSlaveTFSlaveBars;

protected override void Initialize()
{
    _sMasterTFSlaveBars = MarketData.GetBars(TFSlave, "SMaster");
    _sSlaveTFSlaveBars = MarketData.GetBars(TFSlave, "SSlave");
}

public override void Calculate(int index)
{
    int masterIndex = _sMasterTFSlaveBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
    int slaveIndex = _sSlaveTFSlaveBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
}

My questions:

- Do I need to do this function to get the masterIndex as well as the slaveIndex?

- What is the difference between GetIndexByTime and GetIndexByExactTime, what should I use if I rely on 0 UTC on everything?


@JeanPaul
Replies

PanagiotisCharalampous
26 Oct 2020, 14:16

Hi JeanPaul,

Do I need to do this function to get the masterIndex as well as the slaveIndex?

You need to do this for every TimeSeries coming from a different timeframe

 What is the difference between GetIndexByTime and GetIndexByExactTime, what should I use if I rely on 0 UTC on everything?

GetIndexByExactTime will return -1 if there is no exact time match. GetIndexByTime will return the closest index.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

JeanPaul
26 Oct 2020, 15:23

RE:

PanagiotisCharalampous said:

Hi JeanPaul,

Do I need to do this function to get the masterIndex as well as the slaveIndex?

You need to do this for every TimeSeries coming from a different timeframe

 What is the difference between GetIndexByTime and GetIndexByExactTime, what should I use if I rely on 0 UTC on everything?

GetIndexByExactTime will return -1 if there is no exact time match. GetIndexByTime will return the closest index.

Best Regards,

Panagiotis 

Join us on Telegram

Thank you for the prompt response.


@JeanPaul