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 WNorton, Today, 11:23 AM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Spencer  
                    Started by stafe, Today, 10:43 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post stafe
                    by stafe
                     
                    Started by UltraNIX, Today, 09:13 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post UltraNIX  
                    Started by Tuxstuff215, Today, 06:32 AM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by carlot, Today, 08:10 AM
                    2 responses
                    24 views
                    0 likes
                    Last Post carlot
                    by carlot
                     
                    Working...
                    X