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

Drawing a rectangle

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

    Drawing a rectangle

    Hi guys,

    how to draw a rectangle for the current bar and 3 bars ahead?

    The conditions for the following bar as follows:

    Code:
    if (pressure >= lpMax && volume > lvolSMA)
    Thank you!

    #2
    Hello again,

    i think i found the answer from this post:



    Now i have a question regerding the projected value of the rectangle(-10 in the case above).Is it possible to expose those levels at -10 bar and use them as a breakout levels via strategy?

    Thank you!

    Comment


      #3
      Hello Outsource,

      Yes, it is possible. You would need to use the IRectangle interface to create your Rectangle object and have access to its properties -
      http://www.ninjatrader.com/support/h...irectangle.htm

      Let me know if I can be of further assistance.
      Cal H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Cal View Post
        Hello Outsource,

        Yes, it is possible. You would need to use the IRectangle interface to create your Rectangle object and have access to its properties -
        http://www.ninjatrader.com/support/h...irectangle.htm

        Let me know if I can be of further assistance.
        Hi Cal,

        an example snippet code,to add more degrees of freedom,maybe?HelpGuides is usually to narrow to my too narrow mind

        Comment


          #5
          outsource,

          Taking the sample from the help guide -
          Code:
          IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
          
          if(Close[0] > rectangle.EndY)
           EnterLong();
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Cal View Post
            outsource,

            Taking the sample from the help guide -
            Code:
            IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
            
            if(Close[0] > rectangle.EndY)
             EnterLong();
            Hi Cal,i still can`t get it working properly.The strategy doesn`t ''see'' the ''rectangle.EndY'' and doesn`t compile.What further steps should i take?

            Comment


              #7
              outsource,

              Can you please attach your full script so I can test this on my end?
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Cal View Post
                outsource,

                Can you please attach your full script so I can test this on my end?
                Hi Cal,

                check the attached.The only way i found was to add bool series but still it doesn`t work properly.It seems that it just checks for the first high/low rectangle.EndY on the chart and fires the entries from there.BTW it takes long only

                In the attached find the snippet starting from ''208'' line.
                Attached Files

                Comment


                  #9
                  Hello outsource,

                  Thank you for your response.

                  Why not pass the rectangle.EndY to a DataSeries to call it's value from the strategy?

                  Comment


                    #10
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello outsource,

                    Thank you for your response.

                    Why not pass the rectangle.EndY to a DataSeries to call it's value from the strategy?
                    Hi Patrick,

                    how would you do thay?

                    Comment


                      #11
                      Hello outsource,

                      Here is a basic example.

                      Indicator:
                      Code:
                              #region Variables
                      		private DataSeries myDataSeries;
                              #endregion
                      
                              protected override void Initialize()
                              {
                      			myDataSeries = new DataSeries(this);
                              }
                      
                              protected override void OnBarUpdate()
                              {
                      			IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
                      			
                      			myDataSeries.Set(rectangle.EndY);
                              }
                      
                              #region Properties
                              [Browsable(false)]
                              [XmlIgnore()]
                              public DataSeries MyDataSeries
                              {
                                  get { return myDataSeries; }
                              }
                              #endregion
                      Any other indicator or strategy that would call the above indicator:
                      Code:
                      Print(Test1().MyDataSeries[0]);
                      Please refer to the reference sample at the following link for more information: http://www.ninjatrader.com/support/f...ead.php?t=4991

                      Comment


                        #12
                        Originally posted by NinjaTrader_PatrickH View Post
                        Hello outsource,

                        Here is a basic example.

                        Indicator:
                        Code:
                                #region Variables
                        		private DataSeries myDataSeries;
                                #endregion
                        
                                protected override void Initialize()
                                {
                        			myDataSeries = new DataSeries(this);
                                }
                        
                                protected override void OnBarUpdate()
                                {
                        			IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
                        			
                        			myDataSeries.Set(rectangle.EndY);
                                }
                        
                                #region Properties
                                [Browsable(false)]
                                [XmlIgnore()]
                                public DataSeries MyDataSeries
                                {
                                    get { return myDataSeries; }
                                }
                                #endregion
                        Any other indicator or strategy that would call the above indicator:
                        Code:
                        Print(Test1().MyDataSeries[0]);
                        Please refer to the reference sample at the following link for more information: http://www.ninjatrader.com/support/f...ead.php?t=4991


                        Thanks Patrick,

                        two additional questions,if i may:

                        1)Should i put this line:

                        Code:
                         {
                                                IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
                        
                                                myDataSeries.Set(rectangle.EndY);
                                }


                        after OnStartUp or OnBarUpdate,if i`d want to use it COBC = false?

                        2)Could you please comment more on this:

                        Code:
                        Print(Test1().MyDataSeries[0]);
                        What does the Print and Test1 mean?How do i use it with another indicator or strategy?

                        Thank you for taking your time to assist!

                        Comment


                          #13
                          Hi Patrick,

                          can you please review the code attahced?

                          The way i modified it it opens on every bar when i call it via strategy.

                          The conditions for strategy are:

                          Code:
                          For Longs -> if(
                          					   this.Close[0] > this.bvo.BlackBox[0])
                          
                          do smth.
                          
                          For Shorts -> if(
                          					   this.Close[0] < this.bvo.BlackBox[0])
                          
                          do smth.
                          What i exactly need with this.,that if the -10 value of the rectangle is broken either above or below.There where should the strategy enter.

                          The code for you to review is attached.

                          Thanks for your time!
                          Attached Files

                          Comment


                            #14
                            Hello outsource,
                            Originally posted by outsource View Post
                            1)Should i put this line:

                            Code:
                             {
                                                    IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
                            
                                                    myDataSeries.Set(rectangle.EndY);
                                    }


                            after OnStartUp or OnBarUpdate,if i`d want to use it COBC = false?
                            OnBarUpdate().

                            Originally posted by outsource View Post
                            2)Could you please comment more on this:

                            Code:
                            Print(Test1().MyDataSeries[0]);
                            What does the Print and Test1 mean?How do i use it with another indicator or strategy?

                            Thank you for taking your time to assist!
                            Print() prints the values to the Output window, please visit the following link for more information: http://www.ninjatrader.com/support/h.../nt7/print.htm

                            Test1 is the name I gave to the indicator, so this is whatever you name your indicator.


                            Originally posted by outsource View Post
                            can you please review the code attahced?
                            Can you provide the strategy that you are calling the indicator from?

                            Comment


                              #15
                              Originally posted by NinjaTrader_PatrickH View Post
                              Hello outsource,

                              OnBarUpdate().


                              Print() prints the values to the Output window, please visit the following link for more information: http://www.ninjatrader.com/support/h.../nt7/print.htm

                              Test1 is the name I gave to the indicator, so this is whatever you name your indicator.



                              Can you provide the strategy that you are calling the indicator from?
                              Hi Patrcik,

                              thanks for your reply.

                              Did you reviw the indicator?It still doesn`t work properly.

                              This line :

                              Code:
                              Print(Test1().MyDataSeries[0]);
                              because of the semi ; that closes the code.

                              The strategy of thousands of lines has nothing to do with what we discuss.as it is designed the way you can put any possible indicator on plsanet,provided it`s coded for that properly.

                              Entry example logic of my strategy looks like this:

                              Code:
                              if(
                              					 this.lii.TopWallReversalSeries[0] == true
                              					&& setupDirection != 1				
                              					)
                              				{																						
                              					BackColor = Color.FromArgb(50, Color.Lime);
                              
                              					if(setupDirection != 0)
                              						this.CancelPendingGrid();
                              					
                              					setupDirection = 1;
                              So can we get that rectangle to work properly?Please,let me know.

                              Best!
                              Last edited by outsource; 03-31-2015, 04:40 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by f.saeidi, Today, 12:14 PM
                              7 responses
                              16 views
                              0 likes
                              Last Post f.saeidi  
                              Started by Russ Moreland, Today, 12:54 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by philmg, Today, 12:55 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by TradeForge, 04-19-2024, 02:09 AM
                              2 responses
                              32 views
                              0 likes
                              Last Post TradeForge  
                              Started by aprilfool, 12-03-2022, 03:01 PM
                              3 responses
                              329 views
                              0 likes
                              Last Post NinjaTrader_Adrian  
                              Working...
                              X