Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRegion

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

    DrawRegion

    Hi, I'm trying to code a simple color region and am having no luck at all. I am sure I am overlooking something simple, but can't see it. What I am trying to do is if the Stochastics is above 80, then shade the Stochastics area one color and if under 20 shade it a different color. So far, I can't get any shading at all. The code I have is below:

    double retvalue = Stochastics(Close, 5, 15,5).K[0];
    if(retvalue > 80) {
    DrawRegion("tag1",CurrentBar,0,Stochastics(5,15,5) .K,20,Color.ForestGreen, Color.ForestGreen, 5);
    }
    if(retvalue < 20) {
    DrawRegion("tag2",CurrentBar,0,Stochastics(5,15,5) .K,20,Color.Red , Color.Red, 5);
    }

    Any help would be greatly appreciated!

    Thanks,
    jrs

    #2
    Any error messages in the log?
    How about just starting off with a simple DrawRegion() call to ensure that this works. Then add some of the conditional logic.
    RayNinjaTrader Customer Service

    Comment


      #3
      No there are not any error messages pertaining to this (DrawRegion).
      As you suggested (good idea), I simplified it down to:

      DrawRegion("XMA Zone", CurrentBar, 0, EMA( High, 10 ), EMA( Low, 10 ), Color.Green, Color.Green, 2);

      And I do get a plot on the top graph (in the candlesticks). So that part does work, however, I think my problem may be it will not show in the subgraphs, in the actual Stochastic plotted area perhaps?

      Thanks!
      Jim

      Comment


        #4
        See the DrawOnPricePanel property.

        RayNinjaTrader Customer Service

        Comment


          #5
          Fixed

          Thanks Ray, works fine now.

          Comment


            #6
            DrawArrowUp and Down

            Question.

            I want to draw arrows on top of indicator bars in a second panel. Will that work if I set 'overlay = false' in the initialize section ?

            Is there a restriction such that only drawing objects can be placed on top of charts, or can they also be drawn on top of indicators bars ?

            Can you point me to any example code ?

            Regards,
            R. C.

            Comment


              #7
              Off the top of my head I believe on default the draw objects will appear in whichever panel your indicator is running on. You can change the draw objects to appear in the price panel by setting DrawOnPricePanel to true.

              If my memory is wrong then set DrawOnPricePanel to false and it will have the draw objects appear in the indicator panel.
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              579 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X