Bring in other time series to a bot

Created at 22 Dec 2022, 19:17
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!
DY

dykesn92

Joined 31.03.2020

Bring in other time series to a bot
22 Dec 2022, 19:17


Hello

 

I am trying to build a bot that uses a higher TF for indicators than the bot.

Below is what I found to use but then CALGO says it's been obselete.

       var dailySeries = MarketData.GetSeries(TimeFrame.Daily);

 

Ideally I would have a supertrend on hourly as well as an RSI on hourly as my bot is in minutes.

Does anyone know how to do this?

 

Thanks

 

Nick


@dykesn92
Replies

drilonhametaj
22 Dec 2022, 19:27

Use GetBars

Hi, i had the same problem but i found a solution using 

 MarketData.GetBars(TimeFrame.Daily)

Then you can use this bars as Source for your indicators, i will put here an example for using it:

 

 protected override void OnStart()
        {
            // Put your initialization logic here
            timeFrameDaily = MarketData.GetBars(TimeFrame.Daily);
            timeFrameWeekly = MarketData.GetBars(TimeFrame.Weekly);
            timeFrameMonthly = MarketData.GetBars(TimeFrame.Monthly);
            
        }

        protected override void OnTick()
        {
            // Put your core logic here
            emaDaily = Indicators.ExponentialMovingAverage(timeFrameDaily.ClosePrices, fastPeriod);
            emaWeekly= Indicators.ExponentialMovingAverage(timeFrameWeekly.ClosePrices, midPeriod);
            emaMonthly = Indicators.ExponentialMovingAverage(timeFrameMonthly.ClosePrices, slowPeriod);

 

In this example i use 3 EMA with different timeframe, in backtesting this will kill the performance, need a lot of time for backtesting


@drilonhametaj

PanagiotisChar
23 Dec 2022, 09:41

Hi Nick,

You can only do this for the RSI, like this

            var dailyBars = MarketData.GetBars(TimeFrame.Daily);
            var rsi = Indicators.RelativeStrengthIndex(dailyBars.ClosePrices, 14);

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

dykesn92
23 Dec 2022, 12:38

thanks all!

resolved, thank you everyone.

 

For supertrend I am just brute force optimising and it's working a treat at emulating the higher TF 


@dykesn92