Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRegion - Need to Change Color Based On Indicator

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

    DrawRegion - Need to Change Color Based On Indicator

    I want to change the color of my DrawrRegion depending on the slope of one of my indictors. So if my indicator is rising I want the region to be blue but red if the indicator is falling.

    I am using the (non-working) construct:

    if(SmoothMidBandPlot[0]>SmoothMidBandPlot[1])
    {
    DrawRegion("tag1", 1, 0, OuterUpperPlot, SmoothMidBandPlot, Color.Empty, Color.RoyalBlue, 2);
    }
    else
    {
    DrawRegion("tag1", 1, 0, OuterUpperPlot, SmoothMidBandPlot, Color.Empty, Color.Salmon, 2);
    }

    I also tried drawing from CurrentBar to 1. How can I get the desired result?

    #2
    You are not changing the tag, so recreating same drawregion of 1 bar length each time....

    Try channging this ;

    DrawRegion("tag1"+CurrentBar,


    Regards,


    Pablo
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    Comment


      #3
      dkrumholz, as pmaglio has pointed out, if you keep the tag the same, it will be redrawn every time the DrawRegion() method is called. Please try changing the tag on every bar ("tag1"+CurrentBar) and see if you get the behavior you want.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Pablo - yes, thanks!! That slipped my mind.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        42 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        157 views
        2 likes
        Last Post CaptainJack  
        Working...
        X