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 into the future

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

    Drawing a rectangle into the future

    I want to draw a rectangle for the entire session. In my code I set the end time to be a time into the future (the next day). This draws the rectangle but as time goes on the end of the rectangle appears and it does not extend to the date/time I set.

    When I double click on the rectangle and click data I see I have the end time set correctly. Is this a bug? Is there another way to get this to draw into the future? The only workaround I found was to redraw this rectangle on every bar. This seems to work but it just seems inefficient to redraw it every bar (I have lots of them).


    #2
    cunparis,

    Could you possibly post your code for review?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      It depends on what type of chart you are using. If you are not using a fixed time interval chart, then there is no way for the code to determine where the session end time will be, so you will have to redraw the rectangle on each bar, or at least periodically.

      Comment


        #4
        Adam, the code is here:

        Code:
        i.DrawRectangle("Zone"+i.ToDay(startTime)+":"+top+":"+bottom, false, startTime, bottom, endTime, top, color, colorArea, opacity);
        Originally posted by koganam View Post
        It depends on what type of chart you are using. If you are not using a fixed time interval chart, then there is no way for the code to determine where the session end time will be, so you will have to redraw the rectangle on each bar, or at least periodically.
        I think you found the reason. I'm not using minute chart. So this makes sense.

        I wonder if I could specify x bars into the future instead of a date/time?

        Comment


          #5
          Hi cunparis, correct, this would only work on a timed based chart, where future timestamps are known - unfortunately we could only support drawing into the future by using a future DateTime.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Originally posted by cunparis View Post
            ... I wonder if I could specify x bars into the future instead of a date/time?
            Yes, you can. Then just start praying that they do not break it in a future update.

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Hi cunparis, correct, this would only work on a timed based chart, where future timestamps are known - unfortunately we could only support drawing into the future by using a future DateTime.
              I have found that you can draw into the future by using DrawRectangle with a negative value for the index. Example is attached. The indicator shows the Jackson Zones for coming Monday.
              Attached Files

              Comment


                #8
                Harry

                Can you please explain to an amateur how to enter a negative value on the index?

                I want to extend my rectangle into the future

                Thanks

                Comment


                  #9
                  Originally posted by [email protected] View Post
                  Harry

                  Can you please explain to an amateur how to enter a negative value on the index?

                  I want to extend my rectangle into the future

                  Thanks

                  Just use DrawRectangle as described in the NinjaScript reference manual

                  Code:
                  DrawRectangle(string tag, int startBarsAgo,  double  startY, int endBarsAgo,  double  endY, Color color)  
                  DrawRectangle(string tag, bool autoScale,  int  startBarsAgo, double startY,  int  endBarsAgo, double endY, Color color,  Color  areaColor, int areaOpacity)
                  and use it with negative values for startBarsAgo and endBarsAgo.

                  Also make sure to select a sufficient value for the right margin under chart properties.

                  Comment


                    #10
                    extend rectangle

                    where do you go to enter the negitive value.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by DayTradingDEMON, Today, 09:28 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post DayTradingDEMON  
                    Started by navyguy06, Today, 09:28 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post navyguy06  
                    Started by rjbtrade1, 11-30-2023, 04:38 PM
                    2 responses
                    77 views
                    0 likes
                    Last Post DavidHP
                    by DavidHP
                     
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    7 responses
                    31 views
                    0 likes
                    Last Post cmtjoancolmenero  
                    Started by Stanfillirenfro, Today, 07:23 AM
                    3 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X