Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

To Fill zone between MACD lines

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

    To Fill zone between MACD lines

    Good Morning,

    I'm trying to fill the zone between MACD signal and average

    It is filled but it does not always respect the colors

    The condition I use is Diff> 0 and I have verified that it is true without problem

    Can there be an error in these lines?

    ...
    if (Diff[0] >= 0)
    {
    Draw.Region(this, "ColorUP", CurrentBar, 0, MACD(Fast, Slow, Smooth), MACD(Fast, Slow, Smooth).Avg, null, Brushes.Lime, 30);
    }

    else

    {
    Draw.Region(this, "ColorDOWN", CurrentBar, 0, MACD(Fast, Slow, Smooth).Avg, MACD(Fast, Slow, Smooth), null, Brushes.Red, 50);
    }

    ...

    Thank you

    Click image for larger version

Name:	MACDZones.JPG
Views:	368
Size:	23.1 KB
ID:	1057747

    #2
    Hello Mestor,

    Thanks for your post.

    The reason that the regions look as they do is that you are actually drawing two regions (ColorUP and ColorDOWN) both starting from the beginning of historical data to the current bar on top of each other, so you are seeing a blended color based on the colors choices and transparency setting.

    You would need to draw regions based on the crossover and would need to create a new region at each crossover point (Diff >= 0, or Diff < 0) this basically would involve saving the bar number of when the cross first occurs and continuing to draw that same region updating it from that saved bar to the current bar until the next crossover occurs and then drawing a new region with the other color.


    Comment


      #3
      Thank you very much for your help

      I understand what you say but I do not know how to do it

      Could you give me some indication or example please?

      Thank you

      Comment


        #4
        Hello Mestor,

        Thanks for your reply.

        I coded something similar in the NT8 conversion of the Bollinger_TripleState indicator which had 3 possible differently colored regions. I used a bool for each condition and an int variable to save the first bar of the new condition and would continue to redraw that region on each new bar until a new condition occurs.

        Here is a link to the indicator: https://ninjatraderecosystem.com/use...plestate_v4-2/ Please note: The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

        Comment


          #5

          Draw.Region(this,"TagName"+ CurrentBar.ToString(),tTimecrossed,Time[0],Plot1,Plot2,pRegionBrush,pRegionBrush,nEntryExitR egionOpacity);

          pRegionBrush can be changed when going up or down

          ie
          pRegionBrush = Brushes.Red;
          pRegionBrush = Brushes.Green;

          tTimecrossed is the time the macd lines crossed.

          Comment


            #6
            One error is the CurrentBar, Get a specific count in order to reduce objects

            Draw.Region(this,"TagName"+ nCount.ToString(),tTimecrossed,Time[0],Plot1,Plot2,pRegionBrush,pRegionBrush,nEntryExitR egionOpacity);

            Comment


              #7
              Thanks but I can not do it

              I attach the code in case someone can help me and fix it

              Thank you

              MACDColorZones.cs

              Comment


                #8
                Hello Mestor,

                Thanks for your reply.

                Please note that we do not provide coding/debugging services.

                If you would like the indicator created for you, an option to consider would be hiring a programmer and if requested we can provide references to 3rd party programmer who would be able to assist.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                601 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                347 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                559 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                558 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X