PDA

View Full Version : 'Hello World' as a text file record ?


grd974
07-29-2007, 02:06 PM
I wrote down this code after msdn library, compiled it as an indicator, put it over a chart, ran Market Replay but it did not write to any file.

public static void Main()
{
string path = @"C:\TEMP\MyTest.txt";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello World");
}
}
}

Where is the error ?

NinjaTrader_Josh
07-29-2007, 02:10 PM
Try putting it in the OnBarUpdate() section.

grd974
07-29-2007, 03:02 PM
That works !
By the way, do you know how I code the file closing ?
I tried sw.close() but I got a compilation error.

NinjaTrader_Josh
07-29-2007, 03:18 PM
Try sw.Close() with a capital C.