Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot or draw a marker or highlight when an event occurs

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

    Plot or draw a marker or highlight when an event occurs

    Hi there, I am developing a strategy that looks for various signals. Two examples would be
    1) when Swing() is showing me higher highs and higher lows. I would also like to highlight the region where the condition is true, and
    2) when an EMA(20) crosses an EMA(50), and stays crossed for 5 bars. After the 5th bar, I would like to add a marker on the chart, let's say it's a ^. .

    This isn't limited to these two cases. I plan to incorporate it for various signals.

    I have tried Draw.RegionHighlightX(). It works for the most recent instance, however, it does not work for anything in the past. For instance, if my intention is to highlight higher highs, then it will do so, but only if they're occurring right now. As I scroll back through my chart, they are not highlighted. I want these signals to jump out at me visually as I scroll back through charts so ensure my code is behaving as intended.

    Please help me understand what is the best path forward to plot these markers on my charts. Thank you.
    Attached Files

    #2
    Hello Nate G,

    You can set the BackBrush to change the background of the chart for that bar.


    You can use Draw.RegionHighlightX() to highlight the background of the chart as well.


    You can draw rectangle on the chart to highlight an area.


    You can use Draw.Region() to color the area between two plot series.



    "I have tried Draw.RegionHighlightX(). It works for the most recent instance, however, it does not work for anything in the past. "

    Are you ensuring you are using unique tag names for each new drawing object?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Ahhh the unique tag name was the issue! Thank you!

      Messing with these, BackBrush seems to be the ticket. Appreciate your help, Chelsea

      Comment


        #4
        Hi Chelsea,
        I have a question regarding smart/efficient practices on with drawing objects on charts across multiple time frames.
        My indicator identifies a particular region between two price leves using data on a 240-minute chart. It also plots a rectangle there just fine. It performs its calculations inside a BarsInProgress = 2 bracket, where my second BarsInProgress is this 240-minute interval. Currently my indicator draws a rectangle inside this bracket as I intend.

        Same indicator, and there's a BarsInProgress = 3, that's my 15-minute world. I want to be able to open a separate chart with a 15-minute bar interval, and have the same indicator running there. The desired function is to use the calculations from the 240-minute BarsInProgress, and draw a rectangle on the 15-minute chart. I can do this, but it only draws the rectangle on every 16th bar (240-min / 15-min = 16).
        So my next attempt was to the Draw.Rectangle(blah, blah, blah) line of code from my BarsInProgress = 2 (240-min world) and move it to the BarsInProgress = 3 brackets (15-minute world). So it draws it as I'd like here, however, it takes a long time to load. Not too too long... but long enough to where it feels like it can certainly be done more efficiently. The other issue is, when I go back to the 240-minute chart, It plots, but it's doing something I don't want: it plots 16 rectangles on top of each other, (again 240/15 = 16). Then my pretty opaqueness of 10% then becomes 160%.
        While this is seemingly an aesthetic concern, having it be this clunky will slow me down as I develop/debug. Can you direct me down a path that would get me something that highlights these bands, and does so efficiently? One thought is to just add Plots in the State.SetDefaults section of OnStateChange(). I could get an upper limit and lower limit Plot that would represent the top and bottom of the rectangle I was trying to plot. This would be OK, but is there a way to make a nice rectangle (or Highlighted region) that shows me that zone in the 15-minute chart?

        Thank you for hour help.

        Nathan.
        Attached Files

        Comment


          #5
          Hello Nathan,

          Drawing objects can only be drawn the primary series BarsInProgress 0. So it makes sense to only call the Draw method in BarsInProgress 0 while referencing the information from the other bars series (such as Closes[2][0] etc).
          Less calls to the Draw method would be more efficient as it doesn't have to update the object as much.

          Setting plots would be a fine way to highlight a region.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          633 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X