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 OnBarClose to the right, into the current developing bar

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

    Drawing a rectangle OnBarClose to the right, into the current developing bar

    What would my "endBarsAgo" value be to print a rectangle into a developing column if I am using an "on bar close" indicator? My "startBarsAgo" would be zero to start the rectangle on the first fully developed bar, right?. This is the draw method I am using:
    Code:
    Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)
    Let me know if I am wrong about the "startBarsAgo", or if I am missing something in the docs. Thank you

    #2
    Hello rbeckmann05,

    Thank you for your note.

    When calculating On Bar Close, you won't be able to draw into the currently developing bar. You would be able to draw up to the bar right before the currently developing bar. The same could be observed with other indicators, such as an EMA - if you set it to calculate On Bar Close, it will show values up to the last fully formed bar. If you change it to On Price Change or On Each Tick, then it will calculate during the currently forming bar.

    When it comes to barsAgo indexes, they count from the right backward. The "current bar" is 0 bars ago and the bar before that to the left is 1 barsAgo, etc. We have a page about referencing the correct bar here:


    If you want the rectangle to start on the first bar on the chart all the way to the left, that would be the value of CurrentBar for the startBarsAgo.

    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hi Emily,

      Thank you for the helpful response. Is there some way for me to start a yhighlight at the first complete bar, and extend the highlight only to the right or for a defined length? That should do the trick just fine.

      Best regards,

      Ryan Beckmann

      Comment


        #4
        Hello Ryan,

        Thank you for your reply.

        It is not supported to extend an object into the future; the anchors for the object must be associated with a time/bar index that already exists on the chart or else you could experience unexpected behavior. Please provide an example of a "defined length" that you have in mind and I would be glad to provide a code snippet for you.

        I look forward to assisting you further.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          For example, if I draw a yhighlight in an OnBarClose program anchored at bar[0] (the first completed bar before a developing bar), is there some way to tell the yhighlight to only extend from the anchor point to the right? If not, Is there a way to tell the yhighlight to start at anchor point (bar[0]), and end on the developing bar? I am using a 1 minute chart, so maybe there is some way to set the end point to a predictable value such as 1 minute in the future, or 1 bar index to the right? Thank you for the help

          Comment


            #6
            Originally posted by rbeckmann05 View Post
            For example, if I draw a yhighlight in an OnBarClose program anchored at bar[0] (the first completed bar before a developing bar), is there some way to tell the yhighlight to only extend from the anchor point to the right? If not, Is there a way to tell the yhighlight to start at anchor point (bar[0]), and end on the developing bar? I am using a 1 minute chart, so maybe there is some way to set the end point to a predictable value such as 1 minute in the future, or 1 bar index to the right? Thank you for the help
            The region highlight y tool extends indefinitely to the left and the right. You could draw a rectangle that has an areaBrush color and sets areaOpacity to the desired transparency, and this would allow you to have a filled in rectangle that highlights a specific area with startY and endY values as well as a startBarsAgo and endBarsAgo value that allows you to define which bars for it to start and end on.

            For example, the following rectangle would be drawn from the first bar on the left of the chart up until the current bar. The startY value is the current day's high and the endY value is the current day's low:
            Code:
            Draw.Rectangle(this, "tag", false, CurrentBar, CurrentDayOHL().CurrentHigh[0], 0, CurrentDayOHL().CurrentLow[0], Brushes.Blue, Brushes.Blue, 30);
            This uses the following syntax, which includes values for areaBrush and areaOpacity to fill in the rectangle:
            Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, Brush areaBrush, int areaOpacity)

            Please let us know if we may be of further assistance.
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            14 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,983 views
            3 likes
            Last Post jhudas88  
            Working...
            X