Topics

Forum Topics not found

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