Reading binary or dat file

Created at 27 Sep 2016, 10:09
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!
ST

stevennjuki

Joined 15.08.2016

Reading binary or dat file
27 Sep 2016, 10:09


Hello,

I am new to cTrader and I would like to test my code and see if it can read a DAT file before I attach it to a chart. How can I go about this? Below is my code.     

        private bool FileRead()
        {
            string _run_file = "@C:\\cAlgo\\" + _FILE;

            if (!File.Exists(_run_file))
            {
                Print(_run_file + " does not exist! ");
                return false;
            }

            using (BinaryReader _binary = new BinaryReader(File.Open(_run_file, FileMode.Open)))
            {
                string _build_time = _binary.ReadString();

                _instrument.build_time = DateTime.Parse(_build_time);

                Print(" BUILD OF: " + _instrument.build_time.ToString());

                int _capacity = _binary.ReadInt32();

                Print(" BUILD AT: " + _capacity.ToString());// How can I read this from cTrader


            }
            return true;
        }

 

 

 

 


@stevennjuki
Replies

stevennjuki
27 Sep 2016, 10:44

To my point, if I attach the bot below to a chart I do not see the print message in either the journal or the log. 

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

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

        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnBar()
        {
            Print("Hi there!");
        }

        protected override void OnTick()
        {
            // Put your core logic here
            Print("Hi there!");
        }

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

 

 


@stevennjuki