LO
logodesignsaustralia
Blocked user by Spotware at 20 Feb 2023, 10:42
0 follower(s) 0 following 1 subscription(s)

Information

Username: logodesignsaustralia
Member since: 10 Jun 2022
Last login: 10 Jun 2022
Status: Blocked

Activity

Where Created Comments
Algorithms 0 1
Forum Topics 0 0
Jobs 0 0

Last Algorithm Comments

LO
logodesignsaustralia · 2 years ago

using System;

using System.Linq;

using System.IO;

using cAlgo.API;

using cAlgo.API.Indicators;

using cAlgo.API.Internals;

using cAlgo.Indicators;

 

namespace cAlgo

{

    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]

    public class DataExportTicks : Robot

    {

        // QUESTION:  How do I set default Source Timeframe to T1 (1 tick)

        //[Parameter("TimeFrame ")]

        //public TimeFrame TFrame { get; set; }

 

        // QUESTION: How do I get Backteset to default to 1 tick from server

        //  so don't have to manually reset?

 

 

        [Parameter("MA Type")]

        public MovingAverageType MAType { get; set; }

 

        [Parameter("Data Dir", DefaultValue = "c:\\download\\calgo")]

        public string DataDir { get; set; }

 

 

        private string fiName;

        private System.IO.FileStream fstream;

        private System.IO.StreamWriter fwriter;

        private string csvhead = "date,ask,bid,spread,num_ask,num_bid,vol_adj_ask,vol_adj_bid,vol_adj_spread,vac_ask,vac_bid,vac_bear_vs_bull\n";

 

 

        protected override void OnStart()

        {

            var ticktype = MarketSeries.TimeFrame.ToString();

            fiName = DataDir + "\\" + "exp-" + Symbol.Code + "-ticks.csv";

            Print("fiName=" + fiName);  // Best Logo Design Australia

 

            if (System.IO.File.Exists(fiName) == false)

            {

                // generate new file with CSV header only if

                // one does not already exist.

                System.IO.File.WriteAllText(fiName, csvhead);

            }

 

            // had to open file this way to prevent .net from locking it and preventing

            // access by other processes when using to download live ticks.

            fstream = File.Open(fiName, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);

            // setup to append to end of file

            Print("File is Open");

            fstream.Seek(0, SeekOrigin.End);

            // write stream has to be created after seek due to .net wierdness

            // creating with 0 prevents buffering since we want tick data

            // to be available to consumers right away.

            fwriter = new System.IO.StreamWriter(fstream, System.Text.Encoding.UTF8, 1);

            // QUESTION:  How to tell when in Backtest mode so we

            //  can create the stream with a large buffer and turn off

            // auto flush to improve IO performance.

            Print("Fwriter is created");

            fwriter.AutoFlush = true;

            // with autoflush true will autocleanup

            // since we can not close since we may run forever

            Print("done onStart()");

        }

I'm facing an error in the above code.