LoadMoreHistory issue

Created at 02 May 2022, 13:43
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!
BL

bllkrkmz

Joined 28.11.2021

LoadMoreHistory issue
02 May 2022, 13:43


I use two time frame in the cbots like 1 minute and 5 minute. in the one of my indicator I need more historical data than 200 but MarketData.GetBars(TimeFrame.Minute).LoadMoreHistory(); returns always 0 and not loads more data. how can I fix the issue? 


@bllkrkmz
Replies

amusleh
03 May 2022, 12:08

Hi,

Please post a code sample that can reproduce the issue.


@amusleh

bllkrkmz
03 May 2022, 16:41

RE:

amusleh said:

Hi,

Please post a code sample that can reproduce the issue.

 

 

the example is below.

 

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

namespace NewcBot
{
    [Robot(AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        protected override void OnStart()
        {
            var kPeriod = 500;
            var _series = MarketData.GetBars(TimeFrame.Hour4);
            while (_series.Count < kPeriod * 2)
            {
                var numberOfLoadedBars = _series.LoadMoreHistory();

                Print(numberOfLoadedBars);

                if (numberOfLoadedBars < 1) break;
            }

            var so = Indicators.StochasticOscillator(kPeriod, 12, 12, MovingAverageType.Simple);
        }

        protected override void OnTick()
        {
            // Handle price updates here
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

 

 


@bllkrkmz

amusleh
04 May 2022, 09:00

Hi,

I tested on Spotware cTrader beta nd IC Markets cTrader, both loaded more than 1000 bars on first GetBars call, so there was not even a need for running the loop.

If the LoadMoreHistory returns 0 then it means you already loaded all available bars data from your broker, each broker has different amount of historical data.


@amusleh

bllkrkmz
04 May 2022, 14:26

RE:

amusleh said:

Hi,

I tested on Spotware cTrader beta nd IC Markets cTrader, both loaded more than 1000 bars on first GetBars call, so there was not even a need for running the loop.

If the LoadMoreHistory returns 0 then it means you already loaded all available bars data from your broker, each broker has different amount of historical data.

Thanks for your help. I will try another broker.


@bllkrkmz