I am trying to code ""Cumulative Volume Delta" in AFL. My code is as follows -
It is not giving desired result. Can anyone here please fix this? Thanks for your time. Regards.
Code:
_SECTION_BEGIN("Cumulative Volume Delta");
uw= IIf(C>O, H-C, H-O);
lw= IIf(C>O, O-L, C-L);
spread= (H-L);
bl= (spread - (uw-lw));
puw= (uw/spread);
plw= (lw/spread);
pbl= (bl/spread);
x= (pbl+(puw+plw)/2*Volume);
y= ((puw+plw)/2*Volume);
bv= IIf(C>O, x, y);
sv= IIf(C<O, x, y);
cl= Param("Cumulative Length", 14, 10, 100);
cbv= EMA(bv, cl);
csv= EMA(sv, cl);
cvd= (cbv-csv);
cvd_color= IIf(cvd>0, colorGreen, colorRed);
Plot(cvd, "Cumulative Volme Delta", cvd_color, styleHistogram | styleThick, width=3);
_SECTION_END();