IC markets return only 200 bars when calling MarketData.GetBars

Created at 14 Jun 2024, 21:26
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!
LU

lubiqet

Joined 23.10.2023

IC markets return only 200 bars when calling MarketData.GetBars
14 Jun 2024, 21:26


Hi, I have a problem with the function MarketData.GetBars, it return only 200. I user IC Markets broker.

How to get more bars?

Thank you so much.

using System;
using System.Diagnostics;
using System.ComponentModel;
using System.IO;
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;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Net.Http;
using System.Net;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.FullAccess)]
    public class Z1 : Robot
    {
        public Bars _m15Bars;
       
        protected override void OnStart()
        {
            _m15Bars = MarketData.GetBars(TimeFrame.Minute15, "AUDUSD");
            _m15Bars.LoadMoreHistory();
            Print(_m15Bars.Count);
        }

        public object getData(String symbol, DateTime barTime, bool mainData, int history_count)
        {
            Print("---");
            Print(symbol);
            Print(_m15Bars.ClosePrices.Count);
            Print("---");
            return _m15Bars.ClosePrices.Count;
        }

        protected override void OnTick()
        {
            var barTime = Bars.OpenTimes.LastValue;
            if ((barTime.Minute % 15 == 0)){
                var history_count = 199;
                Print(getData("AUDUSD", barTime, true, history_count));
            } 
        }
    }
}

 

LOG:

 


@lubiqet
Replies

PanagiotisCharalampous
15 Jun 2024, 06:49

Hi there,

You can use LoadMoreHistory() to load more data.

Best regards,

Panagiotis


@PanagiotisCharalampous

lubiqet
15 Jun 2024, 09:34 ( Updated at: 16 Jun 2024, 05:53 )

RE: IC markets return only 200 bars when calling MarketData.GetBars

I'm using it on line 27. It doesn't work. I tried also to put it into the while loop until the history is bigger than N, and it just goes forever.

 

PanagiotisCharalampous said: 

Hi there,

You can use LoadMoreHistory() to load more data.

Best regards,

Panagiotis

 


@lubiqet

PanagiotisCharalampous
16 Jun 2024, 05:57

RE: RE: IC markets return only 200 bars when calling MarketData.GetBars

lubiqet said: 

I'm using it on line 27. It doesn't work. I tried also to put it into the while loop until the history is bigger than N, and it just goes forever.

 

PanagiotisCharalampous said: 

Hi there,

You can use LoadMoreHistory() to load more data.

Best regards,

Panagiotis

 

This method only works in backtesting in v5.0 


@PanagiotisCharalampous