I am trying to modify chaikin money flow afl like following picture where upward bar will green color and downed bar will red color in histogram. here is the code where it shows same color for up and down. please help me out.
function CMF(r1)
{
//Graph0=(AD(C,H,L,V,r1)*V)/ Sum(V,r1);
Graph0=Sum(IIf( H>L && V>0,((( C-L )-( H-C )) / ( H-L ))*V,0),r1) / Sum
(V,r1);
dynamic_color = IIf( Graph0> 0, colorGreen, colorRed );
Plot(Graph0, "Chaikin Money Flow ("+r1+")", ParamColor( "Color",
colorCycle ), styleHistogram | styleThick);
}
r1=Param("Periods", 21);
CMF(r1);
function CMF(r1)
{
//Graph0=(AD(C,H,L,V,r1)*V)/ Sum(V,r1);
Graph0=Sum(IIf( H>L && V>0,((( C-L )-( H-C )) / ( H-L ))*V,0),r1) / Sum
(V,r1);
dynamic_color = IIf( Graph0> 0, colorGreen, colorRed );
Plot(Graph0, "Chaikin Money Flow ("+r1+")", ParamColor( "Color",
colorCycle ), styleHistogram | styleThick);
}
r1=Param("Periods", 21);
CMF(r1);
Attachments
-
21.8 KB Views: 387