Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing DrawRegion?

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

    #16
    Nope. Please refer to my previous post. If you want alternating color ranges you need to manually submit all the different regions. Check the syntax on DrawRegion(). You are constantly overriding the complete range. CurrentBar all the way to bar 0. This is why the whole range is being colored.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      OK I think I see, so I need to set a variable or something like that to plot the colors from that point onwards (instead of using CurrentBar)..thanks I think I understand now.

      Comment


        #18
        I've setup the following code:

        if(BLUE_ZONE == -1){BLUE_ZONE = CurrentBar; YELLOW_ZONE = -1;} Print("BLUE_ZONE: = " + BLUE_ZONE);
        DrawRegion("MYREGION", BLUE_ZONE, 0, Bollinger(2, 14).Upper, Bollinger(2, 14).Lower, Color.Empty, Color.Blue, 2);

        I'm sure the logic and syntax are correct, however it is still painting going back from the first bar on the chart. I'm sure this is because the value for "BLUE_ZONE" is being set by using the "CurrentBar" command...as this will instruct to start at first bar on chart. My question is how to get around this? Is there some other command to use to substitute for "CurrentBar" in situations like these that involve "Bars Ago" instrucitons?

        Comment


          #19
          You can do this with math. Just mark the ending bar. Set the next starting bar at the previous ending bar. You may need to fudge it by 1 to not overlap (didn't try). This will create distinct regions that don't color over each other.
          Josh P.NinjaTrader Customer Service

          Comment


            #20
            Converting double to IDataSeries for DrawRegion()

            Hello.

            I'm calculating the upper and lower bounds of Bollinger Bands using the following code :

            Values[3].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] + stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);

            Values[4].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] - stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);

            When I try to use those values in DrawRegion() I run into problems because its looking for two iDataSeries values. The compiler complains that the above values are 'double', which they are.

            DrawRegion("Area", CurrentBar, 0, EMA(MACD(...))[0], EMA(MACD(...))[0], Color.Empty, Color.Blue, 2)

            Question. How do I convert the calculated 'double' values into idataseries values so it will be accepted in DrawRegion() by the compiler ?

            Regards,
            R. C. Singleton

            Comment


              #21
              DrawRegion("Area", CurrentBar, 0, EMA(MACD(...)), EMA(MACD(...)), Color.Empty, Color.Blue, 2)
              RayNinjaTrader Customer Service

              Comment


                #22
                DrawRegion()

                Hello again.

                I got this to compile :

                Values[3].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] + stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);

                Values[4].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] - stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);

                DrawRegion("Area", CurrentBar, 0, Values[3],Values[4],Color.Empty,Color.Gray, 6);

                But its not drawing in the area between the BB bands. It looks like its not doing anything.

                Also, if I replace Values[3] and Values[4] with your suggestion in the last post, I get compiler error CS109. Can't use '*' operator with int stDV and function StdDev.

                Regards,
                R. C. Singleton

                Comment


                  #23
                  See my reference sample in post #11 and use this as a starting point.
                  RayNinjaTrader Customer Service

                  Comment


                    #24
                    Thank you for the response, I'll give it a try.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    558 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    324 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
                    545 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    547 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X