Problems with Bar Count vs Actual Bars, please help

Created at 13 Dec 2019, 12:21
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!
MY

myinvestmentsfx

Joined 06.11.2017

Problems with Bar Count vs Actual Bars, please help
13 Dec 2019, 12:21


Hi Guys,

There seems to be a problem with the amount of data you can access on lower timeframes.  

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using CsvHelper;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class NewcBot : Robot
    {
        protected override void OnStart()
        {

            WriteToCSVFile();

        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }

        public class ArtificialNeuralNetwork
        {
            public int id { get; set; }
            public double high { get; set; }
            public double low { get; set; }
            public double close { get; set; }
            public double open { get; set; }
            public double weightedClose { get; set; }
            public string nextCandleTrend { get; set; }
        }

        public void WriteToCSVFile()
        {
            List<ArtificialNeuralNetwork> records = new List<ArtificialNeuralNetwork>();


            for (var i = 0; i < Bars.OpenPrices.Count; i++)
            {
                var open = Bars.OpenPrices[i];
                var close = Bars.ClosePrices[i];
                var high = Bars.HighPrices[i];
                var low = Bars.LowPrices[i];
                var weightedClose = Bars.WeightedPrices[i];
                var nextCandleTrend = Bars.OpenPrices[i + 1] < Bars.ClosePrices[i + 1] ? "Up" : "Down";

                ArtificialNeuralNetwork record = new ArtificialNeuralNetwork 
                {
                    id = i,
                    close = close,
                    open = open,
                    high = high,
                    low = low,
                    weightedClose = weightedClose,
                    nextCandleTrend = nextCandleTrend
                };

                records.Add(record);
            }

            using (var writer = new StreamWriter("C:\\\\temp\\\\ann.csv"))
            {
                using (var csv = new CsvWriter(writer))
                {
                    csv.WriteRecords(records);
                }
            }

            Print("Count: ", Bars.OpenPrices.Count);
            Print("Done Writing To CSV File");
        }
    }
}

Looking at the bar counts for 15 min and 1 hour timeframes, I would expect the amount of bars to be more on the 15 min side.  But it's the opposite

Kind Regards,

myinvestmentsfx


@myinvestmentsfx
Replies

PanagiotisCharalampous
13 Dec 2019, 12:35

Hi myinvestmentsfx,

If you need more bars, you can use LoadMoreHistory() method. You can find more information here

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@PanagiotisCharalampous

myinvestmentsfx
17 Dec 2019, 18:10

RE:

PanagiotisCharalampous said:

Hi myinvestmentsfx,

If you need more bars, you can use LoadMoreHistory() method. You can find more information here

Best Regards,

Panagiotis 

Join us on Telegram

 

Sorry for the delay, thank you Panagiotis.  You are always very helpfull :)

 


@myinvestmentsfx