Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Waxavi, Today, 02:00 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by elirion, Today, 01:36 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post elirion
                    by elirion
                     
                    Started by gentlebenthebear, Today, 01:30 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post gentlebenthebear  
                    Started by samish18, Yesterday, 08:31 AM
                    2 responses
                    9 views
                    0 likes
                    Last Post elirion
                    by elirion
                     
                    Started by Mestor, 03-10-2023, 01:50 AM
                    16 responses
                    391 views
                    0 likes
                    Last Post z.franck  
                    Working...
                    X