Efficient method to access multi timeframe data on many symbols

Created at 19 Nov 2022, 16:25
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!
MA

mattr12x

Joined 07.10.2017

Efficient method to access multi timeframe data on many symbols
19 Nov 2022, 16:25


Hi team, I am trying to call a method to get market data via a foreach on a bunch of symbols. I feel that I am close, but the below is throwing

Error CS0120: An object reference is required for the non-static field, method, or property 'cAlgo.API.Internals.MarketData.GetBars(cAlgo.API.TimeFrame, string)'

This could be an efficient way to get multi timeframe market data for a list of symbols, if there are any suggestions I would be appreciative.

Thanks in advance.

 

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TEST : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        public Symbol[] MySymbols;

        protected override void OnStart()
        {
            MySymbols = Symbols.GetSymbols("AUDCAD", "AUDCHF", "AUDJPY", "AUDNZD", "AUDUSD", "CADCHF", "CADJPY", "CHFJPY", "EURAUD", "EURCAD",
            "EURCHF", "EURGBP", "EURJPY", "EURNZD", "EURUSD", "GBPAUD", "GBPCAD", "GBPCHF", "GBPJPY", "GBPNZD",
            "GBPUSD", "NZDCAD", "NZDCHF", "NZDJPY", "NZDUSD", "USDCAD", "USDCHF", "USDJPY");

            foreach (var symbol in MySymbols)
            {
                MyMethod(TimeFrame.Minute, symbol);
            }
        }

        protected override void OnTick()
        {
        }

        public static void MyMethod(TimeFrame _timeframe, Symbol _symbol)
        {
            var _bars = MarketData.GetBars(_timeframe, _symbol.Name);
        }

        protected override void OnStop()
        {

        }
    }
}


@mattr12x
Replies

PanagiotisChar
21 Nov 2022, 08:53

Hi there,

Remove the static keywork from MyMethod.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

mattr12x
21 Nov 2022, 10:31

RE:

PanagiotisChar said:

Hi there,

Remove the static keywork from MyMethod.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Thank you very much Panagiotis.


@mattr12x