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

CCI Color Shading Problem

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

    CCI Color Shading Problem

    Hello,

    I'm trying to make a simple modified CCI indicator.
    The function is to shade the area between CCI and level 100.
    But the output seems it drift to the left.
    Could anyone give me some advice?
    Thanks for any help

    The Drawing Part Code:
    Plot0[0] = CCI(Period)[0];
    top[0] = Plot0[0];
    if(top[0] < -100)
    {
    Draw.Region(this, "Region" + CurrentBar,1, 0, top, -100, Brushes.Red, 70);
    }
    else if(top[0] > 100)
    {
    Draw.Region(this, "Region" + CurrentBar,1, 0, top, 100, Brushes.Green, 70);
    }
    Attached Files

    #2
    Hello daiyqchenyh,

    Thank you for writing in. Please make sure to keep NinjaTrader 8 inquiries in the NinjaTrader 8 section of the forum: http://ninjatrader.com/support/forum...splay.php?f=57

    To make sure the full segment gets covered, you cannot be drawing the region using bars. It will rarely happen where the first bar will line up with the beginning of the region. I recommend drawing using the DateTime override:
    Code:
    Draw.Region(NinjaScriptBase owner, string tag, DateTime startTime,
             DateTime endTime, ISeries<double> series, double price, Brush areaBrush, int areaOpacity)
    As an example, for the first bar of a red segment, where CCI(Period)[0] < -100 && CCI(Period)[1] >= -100, you need to do some math to determine the actual DateTime where the CCI would hit -100. This will usually be in between bars.

    Then you would use a similar procedure for the first green segment, and the lest red and green segments.

    Please let me know if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thanks MichaelM,

      I'll try your suggestion and goes to Ninjatrader 8 section.
      Thanks a lot for your help.

      Comment


        #4
        Apologies for dragging up an old thread.

        I'm trying to follow up on the advice from Michael M: As an example, for the first bar of a red segment, where CCI(Period)[0] < -100 && CCI(Period)[1] >= -100, you need to do some math to determine the actual DateTime where the CCI would hit -100. This will usually be in between bars.

        Is anyone able to provide an explanation or an example of how one would actually perform that calculation?

        Thanks!

        Comment


          #5
          Hello poorhatsoap,

          Thank you for your patience.

          I wanted to let you know I am looking into this on my end and will be following up here when I have an update.

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello poorhatsoap,

            Thank you for your patience.

            I wanted to let you know I am looking into this on my end and will be following up here when I have an update.
            PatrickH, Hi

            I can't recall exactly where but a little while ago Harry discussed the same situation in which there is a shift in shading region between two lines unless the correct mathematical crossover is used by Ninja.

            Harry has already resolved this issue for his own work, however I think he proposed the method he used as a way for Ninja to improve the Draw.Region method.

            I do not recall any followup by Ninja or whether that was considered as a feature improvement for NT8.

            A potential Feature Improvement Request is to have Draw.Region method based on actual X-overs.

            Cheers.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello poorhatsoap,

              Thank you for your patience.

              I wanted to let you know I am looking into this on my end and will be following up here when I have an update.
              Hi PatrickH,

              Is it safe to assume you are still looking into this?

              Cheers!

              Comment


                #8
                Originally posted by poorhatsoap View Post
                Hi PatrickH,

                Is it safe to assume you are still looking into this?

                Cheers!
                Hello poorhatsoap,

                Thank you for your response.

                Yes, although I do not have an update at this time.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ScottWalsh, Today, 04:29 PM
                0 responses
                3 views
                0 likes
                Last Post ScottWalsh  
                Started by rtwave, 04-12-2024, 09:30 AM
                2 responses
                21 views
                0 likes
                Last Post rtwave
                by rtwave
                 
                Started by tsantospinto, 04-12-2024, 07:04 PM
                5 responses
                69 views
                0 likes
                Last Post tsantospinto  
                Started by cre8able, Today, 03:20 PM
                0 responses
                7 views
                0 likes
                Last Post cre8able  
                Started by Fran888, 02-16-2024, 10:48 AM
                3 responses
                49 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Working...
                X