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 Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 12-01-2008, 09:20 AM   #1
xewoox
Senior Member
 
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
Default Print() to Output Window

I am new to ninjaScript. I try to print something out on to the Output window. Nothing being print out. This is what I did.

I first create a indicator called 'MyFirstIndicator'. Then I open the output window by clicking Tools/OutputWindow... in Control Center Window.
Now I Open the chart and insert to the 'MyFirstIndicator' indicator. I can see the indicator show up on the chart, but nothing being displayed in the output. Here is my code. I wonder if there is an flag I need to set.

protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
Print ("My First Indicator");
Print (Instrument.FullName);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set((Close[0]+Open[0])/(High[0]+Low[0]));
Print (Close[0]);
}
xewoox is offline  
Reply With Quote
Old 12-01-2008, 09:23 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

All errors will show up in your Control Center logs. The line of code that is most likely producing an error is this one: Print (Instrument.FullName);

You likely cannot access that property from within the Initialize() method. If you just want to print out the instrument name once I suggest you do it in the OnBarUpdate() method within this if-statement:
Code:
if (CurrentBar == 0)
{
     Print (Instrument.FullName);
}
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-01-2008, 09:24 AM   #3
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

First, I don't think you can use the Print function in Initialize().

Always check the LOG when things aren't as you think they should.

The Print on the bottom should look like this.
Code:
Print("Close = " + Close[0].ToString());
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik is offline  
Reply With Quote
Old 09-04-2010, 10:24 PM   #4
Prospectus
Junior Member
 
Join Date: May 2009
Location: DFW
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Default

Actually, you can use Print statements in initialize.
Prospectus 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
Output window funk101 Strategy Development 7 07-12-2010 01:35 PM
why is this not printing to the output window junkone General Programming 8 11-26-2008 07:35 AM
Print to Output heech Strategy Development 3 11-15-2008 07:41 PM
What are these in the OUtput Window? paco99 Strategy Development 2 08-10-2008 10:27 AM
Printing the Output Window RVRoman General Programming 3 08-07-2008 10:57 PM


All times are GMT -6. The time now is 03:15 AM.