Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting histogram

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

    Plotting histogram

    I'm trying to plot a simple histogram, the difference of two moving averages.

    Diff.Set(MA2[0] - MA3[0]);

    if (Diff[0] > Diff[1] ) {
    BullBar.Set(Diff[0]);
    }
    else if (Diff[0] < Diff[1]){
    BearBar.Set(Diff[0]);
    }

    I need some help figuring out why I'm getting these problems (see attachment):
    * Green & Red bars are plotted together
    * Declining Red Bars and Rising Green Bars are not plotted consistently
    * Once I refresh the chart, all these issues are gone until it reappears with new plots

    Thanks in advance.
    Attached Files

    #2
    Hello 2Look4me,

    Thank you for your post.

    Try setting the opposite plot to zero:
    Code:
    Diff.Set(MA2[0] - MA3[0]);
    
    if (Diff[0] > Diff[1] ) {
    BullBar.Set(Diff[0]);
    BearBar.Set(0);
    } 
    else if (Diff[0] < Diff[1]){
    BullBar.Set(0);
    BearBar.Set(Diff[0]);
    }

    Comment


      #3
      Thanks Patrick, I worked on that for hours, but it didn't cross my mind.

      Comment


        #4
        You just need a single plot and no additional DataSeries.

        Code:
        private Color upColor = Color.Lime;
        private Color downColor = Color.Red;
        Diff.Set(MA2[0] - MA3[0]);
        if(Diff[0] > Diff[1])
           PlotColors[0][0] = upColor;
        else if (Diff[0] < DIff[1])
           PlotColors[0][0] = downColor;
        else
           PlotColors[0][0] = PlotColors[0][1];

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        574 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        333 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X