Unable to view the volume based candle colors as given in code

Hello,

I am using the code below to view the 5min charts but the candle colors which need to change as per the volumes are not happening, can anyone guide me on this? Thanks in advance :slight_smile:
ami

_SECTION_BEGIN("Avg Volume");
AvgVol = Param ("Avg Vol", 100000, 0, 10000000, 1);
Buffer1 = Param ("Avg vol Buffer1", 1.5, 0.1, 5 ,0.1);
Buffer2 = Param ("Avg vol Buffer2", 2.0, 0.1, 5 ,0.1);
Buffer3 = Param ("Avg vol Buffer3", 2.5, 0.1, 5 ,0.1);

Condition_For_Color = V > avgvol;
diff_color1 = (V - avgvol) > (AvgVolBuffer1);
diff_color2 = (V - avgvol) > (AvgVol
Buffer2);
diff_color3 = (V - avgvol) > (AvgVol*Buffer3);

Candle_Colour=IIf(Close>Open AND Condition_For_Color,colorGreen,
IIf(Close<Open AND Condition_For_Color,colorRed,
IIf(Close>Open,ColorRGB(145,207,77),ColorRGB(255,140,140))));

Plot( C, "Close", Candle_Colour, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
PlotShapes( IIf( diff_color1 , shapesmallCircle, shapeNone ), colorBlack, 0, H, Offset = -5 );
PlotShapes( IIf( diff_color2 , shapesmallCircle, shapeNone ), colorBlack, 0, H, Offset = -15 );
PlotShapes( IIf( diff_color3 , shapesmallCircle, shapeNone ), colorBlack, 0, H, Offset = -25 );

_SECTION_END();

_SECTION_BEGIN("Chart Patterns");
dist = 1.5*ATR(10);

MDS = Ref(Close,-2)<Ref(Open,-2) AND Ref(Open,-1) < Ref(Close,-2)
AND Ref(Close,-1) < Ref(Close,-2) AND Open > Ref(Close,-1) AND Close > Ref(Close,-1) AND Close > (Ref(Close,-2)+Ref(O,-2))/2
AND (Ref(Open,-1) > Ref(Close,-1) OR Ref(Open,-1) < Ref(Close,-1) OR Ref(Open,-1) == Ref(Close,-1)) AND O<C;

EDS = Ref(Close,-2)>Ref(Open,-2) AND Ref(Open,-1) > Ref(Close,-2)
AND Ref(Close,-1) > Ref(Close,-2) AND Open < Ref(Close,-1) AND Close < Ref(Close,-1) AND Close < (Ref(Close,-2)+Ref(O,-2))/2
AND (Ref(Open,-1) > Ref(Close,-1) OR Ref(Open,-1) < Ref(Close,-1) OR Ref(Open,-1) == Ref(Close,-1)) AND O>C;

/Body Colors/
whiteBody=C>=O;
blackBody=O>C;

/Body Size/
smallBodyMaximum=0.0025;//less than 0.25%
LargeBodyMinimum=0.01;//greater than 1.0%
smallBody=(O>=C*(1-smallBodyMaximum) AND whiteBody) OR (C>=O*(1-smallBodyMaximum) AND blackBody);
largeBody=(C>=O*(1+largeBodyMinimum) AND whiteBody) OR C<=O*(1-largeBodyMinimum) AND blackBody;
mediumBody=NOT LargeBody AND NOT smallBody;
identicalBodies=abs(abs(Ref(O,-1)-Ref(C,-1))-abs(O-C)) < abs(O-C)*smallBodyMaximum;
realBodySize=abs(O-C);

/Gaps/
upGap= IIf(Ref(blackBody,-1)AND whiteBody AND O>Ref(O,-1),1,
IIf(Ref(blackbody,-1) AND blackBody AND C>Ref(O,-1),1,
IIf(Ref(whiteBody,-1) AND whiteBody AND O>Ref(C,-1),1,
IIf(Ref(whiteBody,-1) AND blackBody AND C>Ref(C,-1),1,0))));

downGap=IIf(Ref(blackBody,-1)AND whiteBody AND C<Ref(C,-1),1,
IIf(Ref(blackbody,-1) AND blackBody AND O<Ref(C,-1),1,
IIf(Ref(whiteBody,-1) AND whiteBody AND C<Ref(O,-1),1,
IIf(Ref(whiteBody,-1) AND blackBody AND O<Ref(O,-1),1,0))));

MHT= HHV(H,5)==H;
MHY= HHV(H,5)==Ref ( H, -1);
MLT= LLV(L,5)==L;
MLY= LLV(L,5)==Ref(L,-1);

EDS1=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND Ref(upGap,-1) AND NOT Ref(largeBody,-1) AND blackBody AND NOT smallBody AND (MHT OR MHY);
MDS1 =Ref(largeBody,-2) AND Ref(blackBody,-2) AND Ref(downGap,-1) AND whiteBody AND LargeBody AND C>Ref(C,-2) AND MLY;

HangingMan = (((H-L)>4*(O-C)) AND ((C-L)/(0.001+H-L)>= 0.75) AND ((O-L)/(0.001+H-L)>= 0.75)) AND O>C;
Hammer = (((H-L)>3*(O-C)) AND ((C-L)/(0.001+H-L)>0.6) AND ((O-L)/(0.001+H-L)>0.6)) and C>O;
InvertedHammer = (((H-L)>3*(O-C)) AND ((H-C)/(0.001+H-L)>0.6) AND ((H-O)/(0.001+H-L)>0.6)) and C>O;
ShootingStar = (((H-L)>4*(O-C)) AND ((H-C)/(0.001+H-L)>= 0.75) AND ((H-O)/(0.001+H-L)>= 0.75)) AND O>C;

PlotShapes( IIf( MDS, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );
PlotShapes( IIf( EDS, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );
PlotShapes( IIf( MDS1, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );
PlotShapes( IIf( EDS1, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );

PlotShapes( IIf( HangingMan AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );
PlotShapes( IIf( Hammer AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );
PlotShapes( IIf( InvertedHammer AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );
PlotShapes( IIf( ShootingStar AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );

for( i = 0; i < BarCount; i++ )
{
if( MDS[i] ) PlotText( "MS\n", i-1, L[ i ]-dist[i], colorBlue );
if( EDS[i] ) PlotText( "ES\n", i-1, H[ i ]+dist[i], colorBlue );
if( MDS1[i] ) PlotText( "MS1\n", i-1, L[ i ]-dist[i], colorBlue );
if( EDS1[i] ) PlotText( "ES1\n", i-1, H[ i ]+dist[i], colorBlue );
if( HangingMan[i] AND Condition_For_Color[i]) PlotText( "HM\n", i, H[ i ]+dist[i], colorBlue );
if( Hammer[i] AND Condition_For_Color[i]) PlotText( "H\n", i, H[ i ]+dist[i], colorBlue );
if( InvertedHammer[i] AND Condition_For_Color[i] ) PlotText( "IH\n", i, L[ i ]-dist[i], colorBlue );
if( ShootingStar[i] AND Condition_For_Color[i] ) PlotText( "SS\n", i, L[ i ]-dist[i], colorBlue );
}

_SECTION_END();

It is changing. Check with volume chart at bottom

_SECTION_BEGIN("Avg Volume");
AvgVol = Param ("Avg Vol", 100000, 0, 10000000, 1);
Buffer1 = Param ("Avg vol Buffer1", 1.5, 0.1, 5 ,0.1);
Buffer2 = Param ("Avg vol Buffer2", 2.0, 0.1, 5 ,0.1);
Buffer3 = Param ("Avg vol Buffer3", 2.5, 0.1, 5 ,0.1);

Condition_For_Color = V > avgvol;
diff_color1 = (V - avgvol) > (Buffer1);
diff_color2 = (V - avgvol) > (Buffer2);
diff_color3 = (V - avgvol) > (AvgVol*Buffer3);

Candle_Colour=IIf(Close>Open AND Condition_For_Color,colorGreen,
IIf(Close<Open AND Condition_For_Color,colorRed,
IIf(Close>Open,ColorRGB(145,207,77),ColorRGB(255,140,140))));

Plot( C, "Close", Candle_Colour, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
PlotShapes( IIf( diff_color1 , shapesmallCircle, shapeNone ), colorBlack, 0, H, Offset = -5 );
PlotShapes( IIf( diff_color2 , shapesmallCircle, shapeNone ), colorBlack, 0, H, Offset = -15 );
PlotShapes( IIf( diff_color3 , shapesmallCircle, shapeNone ), colorBlack, 0, H, Offset = -25 );

_SECTION_END();

_SECTION_BEGIN("Chart Patterns");
dist = 1.5*ATR(10);

MDS = Ref(Close,-2)<Ref(Open,-2) AND Ref(Open,-1) < Ref(Close,-2)
AND Ref(Close,-1) < Ref(Close,-2) AND Open > Ref(Close,-1) AND Close > Ref(Close,-1) AND Close > (Ref(Close,-2)+Ref(O,-2))/2
AND (Ref(Open,-1) > Ref(Close,-1) OR Ref(Open,-1) < Ref(Close,-1) OR Ref(Open,-1) == Ref(Close,-1)) AND O<C;

EDS = Ref(Close,-2)>Ref(Open,-2) AND Ref(Open,-1) > Ref(Close,-2)
AND Ref(Close,-1) > Ref(Close,-2) AND Open < Ref(Close,-1) AND Close < Ref(Close,-1) AND Close < (Ref(Close,-2)+Ref(O,-2))/2
AND (Ref(Open,-1) > Ref(Close,-1) OR Ref(Open,-1) < Ref(Close,-1) OR Ref(Open,-1) == Ref(Close,-1)) AND O>C;


whiteBody=C>=O;
blackBody=O>C;


smallBodyMaximum=0.0025;//less than 0.25%
LargeBodyMinimum=0.01;//greater than 1.0%
smallBody=(O>=C*(1-smallBodyMaximum) AND whiteBody) OR (C>=O*(1-smallBodyMaximum) AND blackBody);
largeBody=(C>=O*(1+largeBodyMinimum) AND whiteBody) OR C<=O*(1-largeBodyMinimum) AND blackBody;
mediumBody=NOT LargeBody AND NOT smallBody;
identicalBodies=abs(abs(Ref(O,-1)-Ref(C,-1))-abs(O-C)) < abs(O-C)*smallBodyMaximum;
realBodySize=abs(O-C);


upGap= IIf(Ref(blackBody,-1)AND whiteBody AND O>Ref(O,-1),1,
IIf(Ref(blackbody,-1) AND blackBody AND C>Ref(O,-1),1,
IIf(Ref(whiteBody,-1) AND whiteBody AND O>Ref(C,-1),1,
IIf(Ref(whiteBody,-1) AND blackBody AND C>Ref(C,-1),1,0))));

downGap=IIf(Ref(blackBody,-1)AND whiteBody AND C<Ref(C,-1),1,
IIf(Ref(blackbody,-1) AND blackBody AND O<Ref(C,-1),1,
IIf(Ref(whiteBody,-1) AND whiteBody AND C<Ref(O,-1),1,
IIf(Ref(whiteBody,-1) AND blackBody AND O<Ref(O,-1),1,0))));

MHT= HHV(H,5)==H;
MHY= HHV(H,5)==Ref ( H, -1);
MLT= LLV(L,5)==L;
MLY= LLV(L,5)==Ref(L,-1);

EDS1=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND Ref(upGap,-1) AND NOT Ref(largeBody,-1) AND blackBody AND NOT smallBody AND (MHT OR MHY);
MDS1 =Ref(largeBody,-2) AND Ref(blackBody,-2) AND Ref(downGap,-1) AND whiteBody AND LargeBody AND C>Ref(C,-2) AND MLY;

HangingMan = (((H-L)>4*(O-C)) AND ((C-L)/(0.001+H-L)>= 0.75) AND ((O-L)/(0.001+H-L)>= 0.75)) AND O>C;
Hammer = (((H-L)>3*(O-C)) AND ((C-L)/(0.001+H-L)>0.6) AND ((O-L)/(0.001+H-L)>0.6)) and C>O;
InvertedHammer = (((H-L)>3*(O-C)) AND ((H-C)/(0.001+H-L)>0.6) AND ((H-O)/(0.001+H-L)>0.6)) and C>O;
ShootingStar = (((H-L)>4*(O-C)) AND ((H-C)/(0.001+H-L)>= 0.75) AND ((H-O)/(0.001+H-L)>= 0.75)) AND O>C;

PlotShapes( IIf( MDS, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );
PlotShapes( IIf( EDS, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );
PlotShapes( IIf( MDS1, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );
PlotShapes( IIf( EDS1, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );

PlotShapes( IIf( HangingMan AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );
PlotShapes( IIf( Hammer AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, H, Offset = 15 );
PlotShapes( IIf( InvertedHammer AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );
PlotShapes( IIf( ShootingStar AND Condition_For_Color, shapeStar, shapeNone ), Candle_Colour, 0, L, Offset = -15 );

for( i = 0; i < BarCount; i++ )
{
if( MDS[i] ) PlotText( "MS\n", i-1, L[ i ]-dist[i], colorBlue );
if( EDS[i] ) PlotText( "ES\n", i-1, H[ i ]+dist[i], colorBlue );
if( MDS1[i] ) PlotText( "MS1\n", i-1, L[ i ]-dist[i], colorBlue );
if( EDS1[i] ) PlotText( "ES1\n", i-1, H[ i ]+dist[i], colorBlue );
if( HangingMan[i] AND Condition_For_Color[i]) PlotText( "HM\n", i, H[ i ]+dist[i], colorBlue );
if( Hammer[i] AND Condition_For_Color[i]) PlotText( "H\n", i, H[ i ]+dist[i], colorBlue );
if( InvertedHammer[i] AND Condition_For_Color[i] ) PlotText( "IH\n", i, L[ i ]-dist[i], colorBlue );
if( ShootingStar[i] AND Condition_For_Color[i] ) PlotText( "SS\n", i, L[ i ]-dist[i], colorBlue );
}

_SECTION_END();
3 Likes

thank you so much :slight_smile: actually i needed to change a small setting in the preferences & it worked - thanks once again :pray: