Indicators: Better volume - page 2

oomeysh #:
i applied this indicator on mt5, but nothing showing.. up
Go to the indicator input settings and change the - Type Of Volume Used from Real volume to Tick Volume.
thku for your offer to public of this very good indicator and work u did. i wish u the best

I gave this to Claude Sonnet 5.5 and it said:

What's good

  • The buffer layout is correct: 3 buffers for 2 plots (histogram data + color index, plus the MA line).
  • The color list matches the classic Better Volume palette. The indexes 0 to 5 line up with the comments.
  • The equality checks like IntTimesRange == IntMaxTimesRange are safe here. The window maximum is computed with the identical expression, so the doubles match exactly when the current bar is the max.
  • Recalculating from prev_calculated - 1 correctly updates the forming bar.

Bugs, most serious first

1. Out-of-range crash on short histories (lines 63–69).
limit is only clamped on the first call. Say a weekly or monthly chart has 50 bars and minbars is 100. The first call skips the loop and returns rates_total . On the next tick, prev_calculated is 50, so limit is 49. The MA loop then reads n = -1 and the indicator dies with "array out of range". Fix:

mql5

if(rates_total <= minbars) return(0); limit = (prev_calculated == 0) ? minbars : MathMax(prev_calculated - 1, minbars);

2. Climax Churn (magenta) is lost on bearish bars (lines 116–121).
The "Climax Sell" block runs after "Climax Churn" and overwrites it. So a bar that is both a volume-range climax and a churn bar only shows magenta if it closed above the midpoint. If it closed below, it shows as plain white. The intended priority is that climax churn beats everything else.

3. The "additional churn check" can never fire (lines 123–125).
IntCandleRange > IntMiddlePrice * 2 expands to high - low > high + low , which is only true if low < 0 . For any normal instrument that condition is dead code. The intent was probably a comparison against an average range or similar, so it needs redefining rather than just fixing.

4. Hard-coded 20 ignores InpLookBack (line 105).
Everything else uses InpLookBack , but the low-volume test uses i - 19, 20 . Any value other than 20 makes the classes inconsistent. If InpLookBack is set above 20, low-volume detection still looks at only 20 bars.

5. Zero-volume data triggers false signals, and the default is a trap.

  • The default is VOLUME_REAL , which is 0 on most forex and CFD symbols.
  • With all-zero volume, IntTimesRange (0) == IntMaxTimesRange (0) and IntDividedRange (0) == IntMaxDividedRange (0) are both true. The chart fills with climax and climax-churn colors.
  • Guard the flags with > 0 , and default to VOLUME_TICK .

6. No input validation in OnInit .
InpMAPeriod <= 0 causes a divide by zero. InpLookBack <= 0 breaks the window logic. Return INIT_PARAMETERS_INCORRECT for these.

Smaller points

  • NormalizeDouble(..., 0) rounds the MA to an integer, which distorts the line on low-volume symbols. It isn't needed.
  • Bars before minbars are never written, and PLOT_DRAW_BEGIN isn't set. Set it and initialize the buffers so the early bars don't show garbage.
  • The MA can start at MAPeriod - 1 , not MAPeriod . Using a running sum instead of re-summing 100 bars per bar would also be faster.
  • The repeated InpVolumeType == VOLUME_TICK ? ... : ... ternaries would be cleaner as one small helper function.


    Claude-corrected and english translated version attached. (Click on "go to discussion" to see the file)
Files: