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()

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

    Print()

    Hello. Where should I use Print()?
    If I have condition to buy, and than want to print "buy":
    Code:
    protected override void OnBarUpdate()
            {
                
    			// Condition for long
    			if (Close[1] < Close[2])
    			{
    				Enter_long = Close[0] + SMA()[1];
    				Print("EnterLong="+Enter_long);		
    			}
    But there no data in output window =(. What is wrong?

    #2
    Hello alexstox,
    Thanks for writing in and I am happy to assist you.

    You have not added the SMA period in the below code.
    Code:
    Enter_long = Close[0] + SMA([B]14[/B])[1];  //14 period SMA for example
    Please rectify it and see if it works or not.

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      no. it does not work. and indicator is not plotted on chart
      Code:
      protected override void Initialize()
              {
      SMA(14).Plots[0].Pen.Color = Color.Blue;
                  Add(SMA(14));
      CalculateOnBarClose = true;
              }
      Last edited by alexstox; 05-03-2012, 06:27 AM.

      Comment


        #4
        Hello alexstox,
        In addition you also need to check whether there is sufficient bars in the data series you are accessing.

        Please add the below code just below OnBarUpdate
        Code:
        if (CurrentBar < 2) return;
        Please refer to this post for further reference http://ninjatrader.com/support/forum...ead.php?t=3170

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          I try to use my strategy on 6E (euro future) data - there are enough bars ))). And everything go OK in Strategy Analyzer.

          Comment


            #6
            Hello alexstox,
            I am not referring to the chart bars which is displayed on the screen. But how a NinjaScript code references the bars. Con you confirm, whether the code works when you add the below code just below OnBarUpdate.
            Code:
            if (CurrentBar < 2) return;
            I look forward to assisting you further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              I paste all conditions in Initialize() with CalculateOnBarClose = true;
              Doesn't work

              Comment


                #8
                Hello alexstox,
                Can you upload the full code or email your code to support[AT]ninjatrader[DOT]com. If you email it please append Attn:Joydeep in the subject line and add a reference of this thread in the body of the email.

                I look forward to assisting you further.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Even built-in strategies doesn't plot indicator on the chart

                  Even built-in strategies doesn't plot indicator on the chart

                  1. Connected to IB
                  2. Add SimpleMA strategy to the chart
                  3. Can see only chart without indicators.

                  On Backtesting it plot OK. Why real-time not?
                  Click image for larger version

Name:	1.PNG
Views:	1
Size:	54.3 KB
ID:	865245

                  Comment


                    #10
                    alexstox,

                    Please go to your "Strategies" tab. Do the strategies show up as green here or yellow?

                    Also, please right click your chart > go to "Data series", please check that your "PlotExecutions" setting is set to something other than "DoNotPlot".
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      1. Can I plot on the chart data, that is print to output window? For example, strategy add red arrow for sell and plot red price for enter and stop-loss with profit-taking?
                      2. Why in output window lot of points? I mean, if we use real-time data - it should be only last (and maybe previous) point to enter. But there are many points from past. How to reduce it to last and previous (2 points). Because I use strategy as advisor.

                      Comment


                        #12
                        Hello,

                        1) You can Draw objects on the chart using Draw methods. Print() will only print to the output window and you cannot print different colors. It will be plain text only

                        2) Your script will be ran on historical data. However you can add an function to prevent it from calculating on historical

                        Code:
                        if(Historical)
                        return;
                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          Originally posted by NinjaTrader_Matthew View Post
                          Hello,

                          1) You can Draw objects on the chart using Draw methods. Print() will only print to the output window and you cannot print different colors. It will be plain text only

                          2) Your script will be ran on historical data. However you can add an function to prevent it from calculating on historical

                          Code:
                          if(Historical)
                          return;
                          1. Can I draw on the chart: [<ArrowUp> "Enter for long="<Price>]
                          2. When did that, there is no data in output, even last action ))). Is there any condition "start calculation from N bars ago"
                          3. How can I return date and time of operation?
                          Last edited by alexstox; 05-09-2012, 01:37 AM.

                          Comment


                            #14
                            1) You can use DrawArrow() and DrawText() to draw these objects on your chart:




                            2) Are you running your script with CalculateOnBarClose set to True or False?

                            You can use Count to determine how many bars are on the chart and then use current bar to compare to Count to start processing N number of bars from current. For example if you only wanted to process on the last 50 bars:


                            if (CurrentBar > (Count - 50))

                            3) You can return the data and time of a bar by using Time[0]
                            MatthewNinjaTrader Product Management

                            Comment


                              #15
                              1. How to draw horizontal line 1 bar long?
                              2. How to edit numbers after separator? 1.0120120120102 ----> 1.0120. Can I do it depend on TickSize? To use another instruments when less numbers after separator. For example ES 1230.25.
                              Last edited by alexstox; 05-11-2012, 01:21 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fx.practic, 10-15-2013, 12:53 AM
                              5 responses
                              5,404 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by Shai Samuel, 07-02-2022, 02:46 PM
                              4 responses
                              95 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by DJ888, Yesterday, 10:57 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              159 views
                              0 likes
                              Last Post loganjarosz123  
                              Started by Belfortbucks, Yesterday, 09:29 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Belfortbucks  
                              Working...
                              X