NinjaScript > Educational Resources > Reference Samples > Indicator >

Using System.IO File properties to write to and read from a text file

Print this Topic Previous pageReturn to chapter overviewNext page

Using Stream objects can be cumbersome when you only want to write/read a small amount of data. Fortunately, you can handle this operation with another method. Keep in mind that in exchange for the convenience you will lose some performance.

 

Key concepts in this example

Creating and appending a text file with Open-High-Low-Close data and date stamps

Determining current day Open-High-Low-Close after reading data from the text file

 

Important related documentation

File.AppendAllText()
File.ReadAllText()

 

Other methods and properties of interest include:

File.ReadAllLines()
File.WriteAllLines()

 

Import instructions

1.Download the file contained in this Help Guide topic to your PC desktop
2.From the Control Center window, select the menu File > Utilities > Import NinjaScript
3.Select the downloaded file and click Import.

 

SampleFileReadWrite_NT7.zip