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:	603
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:	555
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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          44 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          58 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          35 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          95 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          59 views
          0 likes
          Last Post PaulMohn  
          Working...
          X