Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD histogram

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

    MACD histogram

    Hello

    I'm developing a simple indicator that paints the background panel:
    • green color when MACD Histogram is rising
    • red color when MACD Histogram is falling

    This is the code:

    Code:
    if (MACD1.Diff[0] > MACD1.Diff[1])
    {
    
    BackBrushes[0] = Brushes.Green;
    }
    
    
    if (MACD1.Diff[0] < MACD1.Diff[1])
    {
    
    BackBrushes[0] = Brushes.Red;
    
    }


    My surprise is that it works totally the other way around as I expected. Please see image here attached. It is red when the MACD histogram is rising and green when going down.

    Click image for larger version

Name:	macd.PNG
Views:	587
Size:	51.9 KB
ID:	1148143



    What's wrong with this sentence? As far as I understand, it is stated very clear that MACD is rising, isn't it?

    Code:
    (MACD1.Diff[0] > MACD1.Diff[1])
    thank you very much for your assistance,

    regards

    Albert

    Attached Files

    #2
    Hello AlbertP,

    Thank you for your reply.

    I've created a test indicator that uses your code snippet that you've posted, and I'm seeing this change the background color as I'd expect. If you test with the attached test script, do you see it paint green when the Diff values rise and red when they go down?

    Thanks in advance; I look forward to assisting you further.
    Attached Files

    Comment


      #3
      Dear Kate

      thanks for your prompt reply.

      Your indicator works properly. Check below:

      Click image for larger version

Name:	macd2.PNG
Views:	540
Size:	62.5 KB
ID:	1148160

      Then, I really don't know what's going on... could you please check attached file?

      [ATTACH]n1148161[/ATTACH]

      best regards,

      Albert

      Comment


        #4
        Hello Albert,

        Thank you for your reply.

        You've got your fast and slow settings reversed - fast should be a lower number and slow a higher number. Default for the MACD would be 12 fast, 26 slow and 9 smooth - you've got 26 fast, 12 slow and 9 smooth, so you're essentially reversing the calculation, resulting in the reversed background colors.

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Dear Kate

          ops! I see. Solved.

          thank you very much

          best regards

          Albert


          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