Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Close of bar file output
Collapse
X
-
vadimg,
To help start you off, I've included some links below that you will find useful.
We have two reference samples on this. Each method should suffice to write output to a file.
System.IO : http://ninjatrader.com/support/forum...ead.php?t=3477
StreamWriter : http://ninjatrader.com/support/forum...ead.php?t=3475
Please let me know if I may assist further.Bobby Y.NinjaTrader Customer Service
-
vadimg,
The code from StreamWriter outputs to the Documents folder:
Code:private string path = Cbi.Core.UserDataDir.ToString() + "MyTestFile.txt";
To output to the C Drive, the path variable will have the following string:
Code:private string path = "C:\text.txt";
Bobby Y.NinjaTrader Customer Service
Comment
-
Bobby, here is what i have but nothing happens, can you please paste the entire code for the indicator?
string ohlc = ToDay(Time[0]) + ", " + Close[0] + Environment.NewLine;
/* Creates the text file at the location determined in 'path' and puts the line 'ohlc' in.
If file already exists it will append the line 'ohlc' onto the end. */
File.AppendAllText("c:\text.txt", ohlc);
Originally posted by NinjaTrader_BobbyY View Postvadimg,
The code from StreamWriter outputs to the Documents folder:
Code:private string path = Cbi.Core.UserDataDir.ToString() + "MyTestFile.txt";
To output to the C Drive, the path variable will have the following string:
Code:private string path = "C:\text.txt";
Comment
-
vadimg,
After further testing, I've found that you are unable to write directly to the C:\ directory because the root of the C:\ Drive is protected from writes from all programs. Try writing to a sub-directory inside of the C:\ Drive such as C:\test\ or something like that. I've also included a sample script that prints closes to a file in the NinjaTrader 7 folder of your Documents folder. It should help you get started with what you'd like to do.Attached FilesBobby Y.NinjaTrader Customer Service
Comment
-
Hello vadimg,
I have attached a version of this indicator that can be imported by the platform.
Here is a basic guideline of how to Import NinjaScripts.Once installed, you may add the indicator to a chart by:
To import NinjaScripts you will need the original .zip file attached to this post.
To Import
1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
2. From the Control Center window select the menu File> Utilities> Import NinjaScript
3. Select the downloaded .zip file
4. NinjaTrader will then confirm if the import has been successful.
- Right click you chart > indicators > Select the Indicator from the list on the left > New > OK
Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'Attached FilesShawn B.NinjaTrader Customer Service
Comment
-
I saw what i did wrong i tried this too, but no files write
private string FileName = "Closes.txt"; //Name of text file
private string Path = @"c:\pricedata"; // Path to the text file that will be created.
private StreamWriter sw; // StreamWriter object
#endregion
#region Properties
[Description("")] [GridCategory("Parameters")]
public string _FileName { get { return FileName; } set { FileName = value; } }
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
Overlay = true;
}
protected override void OnBarUpdate()
{
try
{
if (CurrentBar == 0) sw = File.AppendText(Path + FileName);
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by trilliantrader, Today, 08:16 AM
|
1 response
5 views
0 likes
|
Last Post Today, 08:42 AM | ||
Started by bill2023, Yesterday, 08:51 AM
|
3 responses
20 views
0 likes
|
Last Post
by bltdavid
Today, 08:42 AM
|
||
Started by yertle, Today, 08:38 AM
|
0 responses
4 views
0 likes
|
Last Post
by yertle
Today, 08:38 AM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
15 responses
378 views
0 likes
|
Last Post Today, 08:35 AM | ||
Started by samish18, Yesterday, 08:57 AM
|
10 responses
28 views
0 likes
|
Last Post
by samish18
Today, 08:35 AM
|
Comment