NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript File Sharing > NinjaScript File Sharing Discussion

NinjaScript File Sharing Discussion Discussion for shared NinjaScript files.

Reply
 
Thread Tools Display Modes
Old 04-18-2012, 05:59 AM   #1
aafwintb
Junior Member
 
Join Date: Jan 2008
Posts: 23
Thanks: 0
Thanked 1 time in 1 post
Default Printing to output window

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
aafwintb is offline  
Reply With Quote
Old 04-18-2012, 06:10 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

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.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 04-18-2012, 06:14 AM   #3
aafwintb
Junior Member
 
Join Date: Jan 2008
Posts: 23
Thanks: 0
Thanked 1 time in 1 post
Default

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
aafwintb is offline  
Reply With Quote
Old 04-18-2012, 06:22 AM   #4
aafwintb
Junior Member
 
Join Date: Jan 2008
Posts: 23
Thanks: 0
Thanked 1 time in 1 post
Default

Problem solved , thank you and have a good day Joydeep.
aafwintb is offline  
Reply With Quote
Old 04-18-2012, 06:24 AM   #5
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

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.
Attached Files
File Type: zip MSC.zip (816 Bytes, 39 views)
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-06-2012, 09:29 PM   #6
anwar
Junior Member
 
Join Date: Jan 2012
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default where does it print during live testing

a related issue, when running S. Analyzer the Print goes to out, where does it go when doing realtime testing?
anwar is offline  
Reply With Quote
Old 05-07-2012, 03:53 AM   #7
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

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.
NinjaTrader_Joydeep is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 04:28 PM.