![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| NinjaScript File Sharing Discussion Discussion for shared NinjaScript files. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2008
Posts: 23
Thanks: 0
Thanked 1 time in 1 post
|
Good Afternoon/Morning;
I am trying to print data to the output window. My code is as follows: #region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class CSVPrinter : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = true; } protected override void OnStartUp() { //Print your header Print("Date,Time,Open,High,Low,Close"); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Print your data for each bar Print("," + Time[0] + "," + Open[0] + "," + High[0] + "," + Low[0] + "," + Close[0]); } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion } } However I get this as my printout: Date,Time,Open,High,Low,Close 29/12/2011 21:00:00,1.2937,1.2965,1.2937,1.2964 29/12/2011 22:00:00,1.2963,1.2964,1.2958,1.2961 29/12/2011 23:00:00,1.2961,1.2962,1.2948,1.2951 30/12/2011 00:00:00,1.2951,1.2955,1.2942,1.2953 But I am trying to get this: Date,Time,Open,High,Low,Close 29/12/2011, 21:00:00,1.2937,1.2965,1.2937,1.2964 29/12/2011, 22:00:00,1.2963,1.2964,1.2958,1.2961 29/12/2011, 23:00:00,1.2961,1.2962,1.2948,1.2951 30/12/2011, 00:00:00,1.2951,1.2955,1.2942,1.2953 How do I get it to print the comma between the data and the time.? Any help will be appreciated. Thank you in advance. ![]() aafwintb |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello aafwintb,
Please use the below code to print as per your format. Code:
Print(Time[0].ToString("dd/MM/yyyy") + "," + Time[0].ToString("HH:mm:ss") + "," + Open[0] + "," + High[0] + "," + Low[0] + "," + Close[0]);
Please let me know if I can assist you any further.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jan 2008
Posts: 23
Thanks: 0
Thanked 1 time in 1 post
|
Thanks joydeep;
Tried that but still get the same output: Date,Time,Open,High,Low,Close 29/12/2011 21:00:00,1.2937,1.2965,1.2937,1.2964 29/12/2011 22:00:00,1.2963,1.2964,1.2958,1.2961 29/12/2011 23:00:00,1.2961,1.2962,1.2948,1.2951 |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jan 2008
Posts: 23
Thanks: 0
Thanked 1 time in 1 post
|
Problem solved , thank you and have a good day Joydeep.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello aafwintb,
The attached code gives me this print: 11/04/2012,14:15:00,1357.75,1370.5,1357.5,1364 12/04/2012,14:15:00,1364.25,1386.25,1363.25,1386 13/04/2012,14:15:00,1385.75,1388.5,1363.75,1365 16/04/2012,14:15:00,1366,1375.25,1360.5,1364 17/04/2012,14:15:00,1364.25,1388.75,1359.25,1383.5 Please let me know if I can assist you any further.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jan 2012
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
|
a related issue, when running S. Analyzer the Print goes to out, where does it go when doing realtime testing?
|
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello anwar,
The Print function will print out the logs in the Output window (Tools>Output Window) whether the code is running live or via the Strategy Analyzer.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Printing ZigZag points to output window | NoInfluence | Miscellaneous Support | 2 | 01-05-2012 03:14 PM |
| Printing Text to Output Window on the Last Bar of a Chart | ollywedgwood | Strategy Development | 2 | 07-24-2009 03:39 PM |
| why is this not printing to the output window | junkone | General Programming | 8 | 11-26-2008 07:35 AM |
| Printing the Output Window | RVRoman | General Programming | 3 | 08-07-2008 10:57 PM |
| Printing/Saving Output? | goforbroke | General Programming | 4 | 02-05-2008 12:29 PM |