![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Dec 2009
Posts: 67
Thanks: 0
Thanked 0 times in 0 posts
|
I have slightly modified example "SampleStreamWriter". First option works, but my code doesn't.
I am trying to write data to my file at user defined location. It doest write at the same time no error message. How to write to a file at user defined location? Any help please? Regards, Code: protectedoverridevoid Initialize() { // path = Cbi.Core.UserDataDir.ToString() + Instrument.FullName + ".txt"; path = "D:\\ForexData\\Ninja" + Instrument.FullName + ".txt"; CalculateOnBarClose = true; } |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
This works for me: privatestring path2 = "C:\\AFolderName\\MyTestFile.txt"; Try starting over with the SampleStreamWriter file and just changing the one line above and this line (of course use a patht that will work on your computer): sw = File.AppendText(path2); Can you get that to work?
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2009
Posts: 67
Thanks: 0
Thanked 0 times in 0 posts
|
Thankyou Ben for your reply.
I was missing two "\\" at the end of my path string. Its working now. Thanks a lot. Cheers, |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Aug 2010
Location: http://twitter.com/Oil_Trader
Posts: 141
Thanks: 0
Thanked 0 times in 0 posts
|
How do I encapsulate an output sw.WriteLine(" This is Close Price "25" ");
it is reading it to behaving 2 quotation marks at "25" there fore an error occurs during compile of the indicator. |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Aug 2010
Location: http://twitter.com/Oil_Trader
Posts: 141
Thanks: 0
Thanked 0 times in 0 posts
|
For the streamwriter, it seems to be writing the the next line below,
Is it possible to write on the line above? Is it possible to overwrite the existing file with the new entry? By deleting the previous line? |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
Oil_Trader, yes these are possible: to write something with quotes, please try putting an @ symbol in front of the string. As for how to overwrite the existing file, you'll have to review the MSDN documents on StreamWriter because I'm not intimately familiar with the process.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Aug 2010
Location: http://twitter.com/Oil_Trader
Posts: 141
Thanks: 0
Thanked 0 times in 0 posts
|
Can you give a specific example?
This is what I am writing and yet is is saying ------> ) expected this is my code sw.WriteLine(@" SP500 ="1225.0" + NQ "); as you can see, there are quotation marks within the parameter |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello OilTrader,
You may have to use escape characters for the quotation marks. See the reference sample below for help with this: Indicator: Manipulating string objects
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| StreamWriter with Live Strategy | tony900hwk | Strategy Development | 41 | 01-11-2010 02:25 PM |
| StreamWriter from a Strategy | stefy | Strategy Development | 10 | 08-30-2009 08:46 PM |
| StreamWriter | stefy | General Programming | 5 | 08-25-2009 11:44 AM |
| Streamwriter/reader questions | Burga1 | General Programming | 13 | 05-20-2008 12:53 PM |
| Indicator: Using StreamWriter to write to a text file | NinjaTrader_Josh | Reference Samples | 0 | 09-30-2007 10:38 PM |