Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Print() to Output Window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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]);
    }

    #2
    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);
    }
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      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());
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Actually, you can use Print statements in initialize.

        Comment


          #5
          Can i print all information in one line?
          Without line break (\n)

          Comment


            #6
            Hello Udimuz,

            Welcome to the NinjaTrader forums.

            Each time you print will be a new line.

            But if you accumulate all the information to a string variable and print only once, you can put all the information on one line.

            string myString = "information1";
            myString += " information2";
            Print(myString);
            Last edited by NinjaTrader_ChelseaB; 04-02-2019, 09:11 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by 309338, Today, 12:06 PM
            0 responses
            11 views
            0 likes
            Last Post 309338
            by 309338
             
            Started by AaronKoRn, Yesterday, 08:38 PM
            2 responses
            51 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by rocketstock, 08-05-2022, 09:36 PM
            2 responses
            76 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by ronyggg83, Yesterday, 03:48 PM
            4 responses
            54 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by preqc, 08-05-2022, 09:10 AM
            1 response
            40 views
            0 likes
            Last Post NinjaTrader_Jim  
            Working...
            X