The System.IO name space provides types for reading and writing to files.
http://msdn2.microsoft.com/en-us/library/system.io.aspx
Following is a conceptual sample of using the System.IO.StreamWriter class.
Create a method:
{
// Creates the file path
string file = NinjaTrader.Cbi.Core.UserDataDir + @"log" + fileName;
// Writes out a line to the specified file name
try
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(file))
{
writer.WriteLine(line);
}
}
catch (System.Exception exp)
{
Log("File write error for file name '" + fileName + "' Error '" + exp.Message + "'", LogLevel.Warning);
}
}
Then call this method from within OnBarUpdate():
{
if (condition == true)
WriteFile("myFile", "The condition is true");
}
Ray
Comment