Skip to main content

Volume flow indicator for Amibroker (AFL)

tobefriend 5 months ago Amibroker (AFL)

  • Rating:
    0 / 5 (Votes 0)
  • Tags:

Translate from Pine scrip of trading view dedicated to Mr. Lazy Bear

Indicator / Formula

Copy & Paste Friendly
// ===== Parameters =====
Length        = Param("VFI Length", 130, 10, 500, 1);
Coef          = Param("Coef", 0.2, 0.01, 1, 0.01);
VCoef         = Param("Max Vol Cutoff", 2.5, 0.5, 10, 0.1);
SignalLength  = Param("Signal Length", 5, 1, 50, 1);
SmoothVFI     = ParamToggle("Smooth VFI", "Off|On", 0);
ShowHisto     = ParamToggle("Show Histogram", "Off|On", 0);

// ===== Calculations =====
Typical = (H + L + C) / 3;
Inter  = Log(Typical) - Ref(Log(Typical), -1);
VInter = StDev(Inter, 30);
Cutoff = Coef * VInter * C;
VAve = Ref(MA(V, Length), -1);

VMax = VAve * VCoef;

VC = Min(V, VMax);
MF = Typical - Ref(Typical, -1);
VCP = IIf(MF > Cutoff, VC,
      IIf(MF < -Cutoff, -VC, 0));
RawVFI = Sum(VCP, Length) / VAve;
VFI = IIf(SmoothVFI, MA(RawVFI, 3), RawVFI);

// signal line
VFIMA = EMA(VFI, SignalLength);

// histogram difference
D = VFI - VFIMA;

// ===== Plotting =====

if (ShowHisto)
{
    Plot(D, "Histogram", colorGrey40,
         styleHistogram | styleThick);
}



vfi_color = IIf(vfi > Ref(vfi,-1), colorGreen, 
IIf(vfi < Ref(vfi, -1), colorRed, colorGrey50));
Plot( vfi, "vfi", vfi_color, styleLine, Null, Null, 0, 0, 2);
Plot(VFIMA, "EMA of VFI", colorOrange, styleLine);

if ( showHisto ) 

Plot(d,"d",IIf(d>Ref(d,-1),colorGreen,IIf(d<Ref(d,-1),colorOrange,0)),stylehistogram);
Plot(d,"d",IIf(d>0,colorlime,IIf(d<0,colorOrange,0)),stylehistogram);
Plot(d,"d",IIf(d>Ref(d,-1),colorLime,IIf(d<Ref(d,-1),colorOrange,0)),styleLine);
PlotGrid(0, colorGrey50, 1, 1, True);

0 comments

Leave Comment

Please login here to leave a comment.