Zero volume on any day shows no bars in volume chart

Sometimes a chart has zero volume in any of the candles, the volume chart is entirely blank. Once i modify it to any value other than zero, volume chart shows bars. Is it possible to ignore zero volume days and show bars?

Below are snapshots and my volume afl.



_SECTION_BEGIN("Pocket Pivot Volume");
// Declarations
// https://in.tradingview.com/script/JkB0iCFp-Simple-Volume-with-Pocket-Pivots/
VolumeMA = 50;

// Calculating highest down volume day.
LookBack = Param( "LookBack", 10, 9, 15, 1 ); // Look back periods
RedCandle = Close < Open;
GreenCandle = Close > Open;
RedVolume =  IIf( RedCandle, Volume, 0 );
TopRedV = HHV( RedVolume, LookBack );
RevPP = LLV(Volume, LookBack);

// Pocket pivot condition

PPBar = IIf( Volume > TopRedV AND Close > Open, True, False );

// Calculating bar colours
RedBar = IIf( Volume > MA(Volume, VolumeMA)  AND RedCandle, True, False );
GreenBar = IIf( Volume > MA(Volume, VolumeMA)  AND GreenCandle, True, False );
OrangeBar = IIf(Volume <= RevPP, True, False);
VolumeColor = IIf(PPBar, colorBlue, IIf(RedBar, colorRed,IIf(GreenBar, colorGreen, IIf(OrangeBar, colorOrange,colorGrey50))));



//Plot (Volume, _DEFAULT_NAME(),VolumeColor, styleHistogram|styleThick);
Plot (Volume, _DEFAULT_NAME(),VolumeColor, styleHistogram);

_SECTION_END();

_SECTION_BEGIN( "MA" );
P = ParamField( "Price field", -1 );
Periods = Param( "Periods", 10, 2, 50, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle( "Style" ) );
_SECTION_END();

_SECTION_BEGIN( "MA1" );
P = ParamField( "Price field", -1 );
Periods = Param( "Periods", 40, 2, 100, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle( "Style" ) );
_SECTION_END();

VolMul = 50;
_SECTION_BEGIN( "UpDownRatio" );
VolDays = 30;
RedCandle = Close < Ref( Close, -1 );
RedVolume =  IIf( RedCandle, Volume, 0 );
GreenCandle = Close > Ref( Close, -1 );
GreenVolume =  IIf( GreenCandle, Volume, 0 );
RedVolSum = Sum( RedVolume, VolDays );
GreenVolSum = Sum( GreenVolume, VolDays );

UpDownRatio = GreenVolSum / RedVolSum;
_SECTION_END();

_SECTION_BEGIN( "Highest Volume" );
HVE = Highest(Volume);
HV1Y = HHV(Volume, 252);
HV1YClose = ValueWhen(HHV(Volume, 252), Close);
_SECTION_END();

// Volume in Millions
Mills = 1000000;


// Setting chart title
Title = Name() + "  -   " +
        //EncodeColor( colorGreen ) + "Volume =" +  EncodeColor( colorWhite ) + NumToStr( (Volume * Close / CR), 10.2, True, True ) + " CR" + ",  " +
        //EncodeColor( colorBlue ) + "HVE = " +  EncodeColor( colorWhite ) + NumToStr( HVE * Close / CR , 10.2, True, True ) + " CR"+ ", " +
        //EncodeColor( colorLightOrange ) + "Prev HV1Y=" +  EncodeColor( colorWhite ) + NumToStr( Ref(HV1Y, -1) * HV1YClose / CR , 10.2, True, True ) + " CR"+ ",  " +
        //EncodeColor( colorLightOrange ) + "MA (V, 10) =" +  EncodeColor( colorWhite ) + NumToStr( MA( Volume, 10 ) * Close / CR , 10.2, True, True ) + " CR"+ ",  " +
        //EncodeColor( colorBlue ) + "MA (V, 50) = " +  EncodeColor( colorWhite ) + NumToStr( MA( Volume, 50 ) * Close / CR , 10.2, True, True ) + " CR"+ ",  " +
		EncodeColor( colorGreen ) + "Volume =" +  EncodeColor( colorWhite ) +  Prec(Volume / Mills,2) + " M" + ",  " +
        EncodeColor( colorBlue ) + "HVE = " +  EncodeColor( colorWhite ) + Prec(HVE / Mills, 2) + " M" + ",  " +
        EncodeColor( colorLightOrange ) + "Prev HV1Y=" +  EncodeColor( colorWhite ) + Prec(HV1Y / Mills, 2) + " M" + ",  " +
        EncodeColor( colorAqua ) + "Vol Multiple = " +  EncodeColor( colorWhite ) + NumToStr( Volume / MA( Volume, VolMul ), 3.2, True, False ) + " (" + NumToStr( VolMul, 2.0, True, False ) + " MA)" + ",  " +
        EncodeColor( colorWhite ) + "UDR = " +  EncodeColor( colorOrange ) + Prec( UpDownRatio, 2 )
        ;


Ok, little bit of digging around on the chart showed that my volume chart had log enabled. Once unselected, all the bars are displayed. I would still like to know what was happening there?

It's impossible to plot the number zero on a log chart.

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.