PrintTo

View as Markdown

Definition

Determines either tab of the NinjaScript Output window the Print() and ClearOutputWindow() method targets.

Property Value

An enum value representing the target Output Tab. The default value is PrintTo.OutputTab1.

Possible values are:

PropertyDescription
PrintTo.OutputTab1Output Windows tab named “Output 1”
PrintTo.OutputTab2Output Windows tab named “Output 2”

Syntax

PrintTo

Examples

Setting the default PrintTo in separate scripts (#1)

1protected override void OnStateChange()
2{
3 if (State == State.SetDefaults)
4 {
5 Name = "Sample PrintTo Indicator #1";
6 Description = @"Used to Print updates to Output 1";
7
8 //Set this scripts Print() calls to the first output tab
9 PrintTo = PrintTo.OutputTab1;
10 }
11}
12
13protected override void OnBarUpdate()
14{
15 Print("This script will print messages to Output Tab 1");
16}

Setting the default PrintTo in separate scripts (#2)

1protected override void OnStateChange()
2{
3 if (State == State.SetDefaults)
4 {
5 Name = "Sample PrintTo Indicator #2";
6 Description = "@Used to Print updates to Output 2";
7
8 //Set this scripts Print() calls to the second output tab
9 PrintTo = PrintTo.OutputTab2;
10 }
11}
12
13protected override void OnBarUpdate()
14{
15 Print("This script will print messages to Output Tab 2");
16}

Setting PrintTo conditionally in a single script

1protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
2{
3 if(marketDataUpdate.MarketDataType == MarketDataType.Ask)
4 {
5 //Print Ask updates to Output 1
6 PrintTo = PrintTo.OutputTab1;
7 Print("Ask: " + marketDataUpdate.Price);
8 }
9
10 else if (marketDataUpdate.MarketDataType == MarketDataType.Bid)
11 {
12 //Print Bid updates to Output 2
13 PrintTo = PrintTo.OutputTab2;
14 Print("Bid: " + marketDataUpdate.Price);
15 }
16}