PDA

View Full Version : Indicator: Using StreamWriter to write to a text file


NinjaTrader_Josh
09-30-2007, 11:38 PM
Sometimes you may want to store information related to certain market conditions or trades outside of NinjaTrader. The formatting of the text file can also make for easy importing into Microsoft Excel in the future.

This reference sample demonstrates the following concepts:

Creating a text file with StreamWriter
Writing Open-High-Low-Close data with date stamps to the file

Important methods and properties used include:

StreamWriter (http://msdn2.microsoft.com/en-us/library/system.io.streamwriter.aspx)
WriteLine (http://msdn2.microsoft.com/en-us/library/system.io.streamwriter.writeline%28VS.90%29.aspx)

Other methods and properties of interest include:

StringWriter (http://msdn2.microsoft.com/en-us/library/system.io.stringwriter%28VS.90%29.aspx)
TextWriter (http://msdn2.microsoft.com/en-us/library/system.io.textwriter%28VS.90%29.aspx)

Import instructions:

Download the file contained in this thread to your PC desktop
From the Control Center window, select the menu File > Utilities > Import NinjaScript
Select the downloaded file