PDA

View Full Version : Print() to Output Window


xewoox
12-01-2008, 09:20 AM
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]);
}

NinjaTrader_Josh
12-01-2008, 09:23 AM
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:
if (CurrentBar == 0)
{
Print (Instrument.FullName);
}

mrlogik
12-01-2008, 09:24 AM
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.

Print("Close = " + Close[0].ToString());

Prospectus
09-04-2010, 10:24 PM
Actually, you can use Print statements in initialize.