I've even tried an adaption of the StreamWriter (using the GlobalStrategy.cs), and I get the exact same results. Sometimes it works, then other times it doesn't.
I've tried it on multiple machines, all with the same results.
What am I doing wrong?
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
using System.IO;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
[Description("Enter the description of your strategy here")]
public class TextFileWriter : Strategy
{
#region Variables
private int date = 0;
private string path = Cbi.Core.UserDataDir.ToString() ;
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
}
public virtual string GetSymbol()
{
return base.Bars.Instrument.FullName;
}
protected override void OnBarUpdate()
{
string myWriteString = ToDay(Time[0]) + " " + Time[0].TimeOfDay + " " + Close[0] + " " + Volume[0] + Environment.NewLine;
File.AppendAllText(path + GetSymbol() + ".txt", myWriteString);
}
#region Properties
#endregion
}
}

Comment