Topics
13 Aug 2019, 11:33
 1535
 6
Replies

GenesisG
13 Aug 2019, 12:47

RE:

Panagiotis Charalampous said:

Hi GenesisG.

If the file is being used by another process then you will get an exception. Please read this discussion, it should be helpful.

Best Regards,

Panagiotis

Thanks!


@GenesisG

GenesisG
13 Aug 2019, 12:39

The log i am getting on crashing is
13/08/2019 19:34:28.516 | Crashed in OnTick with IOException: The process cannot access the file because another process has locked a portion of the file. 
 


@GenesisG

GenesisG
13 Aug 2019, 12:38

Thanks for your response,

I have removed the onstop and onstart completely.  But when refreshing in excel if excel and this bot read and write at the same time the cbot crashes still.  I want this cbot to write to a text file.  I have another bot writing to another text file.  Then in excel I am importing both textfiles into the sheet and making calculations in excel.

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.IO;

namespace cAlgo.Robots
{
    [Robot()]
    public class ICMARKETS : Robot
    {
        StreamWriter _fileWriter;
        protected override void OnTick()
        {
            var lastIndex = MarketSeries.Close.Count - 1;
            double close = MarketSeries.Close[lastIndex - 1];


            StreamWriter SW = new StreamWriter("C:\\Users\\Gary\\Desktop\\hi.txt");


            SW.WriteLine(Symbol.Ask);
            SW.WriteLine(Symbol.Bid);
            SW.Close();
        }


    }
}

 


 


@GenesisG