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

Draw Region question

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

    Draw Region question

    Hello,
    Using the CCI. I'm trying to color the area between the CCI value and the zeroline. Green if CCI is above the zeroline and Red if below the zeroline.
    I tried this but it doesnt compile.
    Any ideas how I could do this?

    Thanks.

    if (CCI(Close,Period)[0] > 0)
    {
    DrawRegion(
    "tag1", CurrentBar, 0, CCI(Period)[0], 0, Color.Empty, Color.Green, 2);
    }

    if (CCI(Close,Period)[0] < 0)
    {
    DrawRegion(
    "tag1", CurrentBar, 0, CCI(Period)[0], 0, Color.Empty, Color.Red, 2);
    }

    #2
    dwalls,

    If things don't compile please provide the error. Thank you.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh.
      I get these two errors.

      1) The best overloaded method match for 'NinjaTrader.Indicator.IndicatorBase.DrawRegion(st ring, int, int, NinjaTrader.Data.IDataSeries, double, System.Drawing.Color, System.Drawing.Color, int)' has some invalid arguments CS1502 - click for info 182 5

      2) Argument '4': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' NT1503 - click for info 182 39

      Comment


        #4
        It is as the second error states it then. You should not be using a double value, but rather the DataSeries. Please remove the [0] indexing.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh,
          Ok, it will compile now but it plots the same color (Green) weather it is above the "0" line or below it.
          It should plot one color (Green) when above the "0" line and another color (Red) when below the "0" line.
          Can you see why it does not do this?

          if (CCI(Close,Period)[0] > 0)
          {
          DrawRegion(
          "tag1", CurrentBar, 0, CCI(Period), 0, Color.Empty, Color.Green, 2);
          }

          if (CCI(Close,Period)[0] < 0)
          {
          DrawRegion(
          "tag1", CurrentBar, 0, CCI(Period), 0, Color.Empty, Color.Red, 2);
          }

          Comment


            #6
            That's because you are using the exact same string name.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Is the string name the CCI(Period)?
              Could you please give an example of different string names that might be used in this code.

              Thanks

              Comment


                #8
                String name is your current "tag1". Name them differently.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks Josh,
                  That didnt work. This is what I have now and it still colors above/below zeroline all green.
                  Seems like it should work.

                  if (CCI(Close,Period)[0] > 0)
                  {
                  DrawRegion(
                  "AboveZero", CurrentBar, 0, CCI(Period), 0, Color.Empty, Color.Green, 2);
                  }

                  if (CCI(Close,Period)[0] < 0)
                  {
                  DrawRegion(
                  "BelowZero", CurrentBar, 0, CCI(Period), 0, Color.Empty, Color.Red, 2);
                  }

                  Comment


                    #10
                    dwalls,

                    You need to debug it your if-statements as well as adjust your startBarsAgo/endBarsAgo. You are drawing the painting the whole region regardless of if it is above or below. Right now your code says, paint the whole thing green if current CCI > 0. Paint the whole thing red if current CCI < 0.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello,
                      I guess I need more help or ideas. I can't figure it out.
                      Any help would be much appreciated.
                      Just trying to shade the areas between the CCI value and the zeroline using Draw Region.
                      Color the entire region above the zeroline (Green) when the CCI values close above the "0" line and color the entire region below the zeroline (Red) when CCI values close below the "0" line. So instead of green bars above and red bars below the zeroline...use the green and red Draw Region instead.

                      Thanks

                      Comment


                        #12
                        Not running NT now to test but try this:

                        DrawRegion("AboveZero" + CurrentBar, 1, 0, CCI(Period), 0, Color.Empty, Color.Green, 2);
                        eDanny
                        NinjaTrader Ecosystem Vendor - Integrity Traders

                        Comment


                          #13
                          Thx eDanny.
                          Getting alot closer now.
                          Now the problem is just when it crosses the zeroline.
                          How can I make it color green only above the zeroline and red below it.
                          See attached screenshot.

                          Thanks
                          Attached Files

                          Comment


                            #14
                            dwalls,

                            That is what happens when you are switching between the two coloring regions. You are connecting between two data points and if you use such spaced out bars it is very prominent.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Kaledus, Today, 01:29 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post Kaledus
                            by Kaledus
                             
                            Started by PaulMohn, Today, 12:36 PM
                            1 response
                            15 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by yertle, Yesterday, 08:38 AM
                            8 responses
                            36 views
                            0 likes
                            Last Post ryjoga
                            by ryjoga
                             
                            Started by rdtdale, Today, 01:02 PM
                            1 response
                            6 views
                            0 likes
                            Last Post NinjaTrader_LuisH  
                            Started by alifarahani, Today, 09:40 AM
                            3 responses
                            18 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Working...
                            X