Hi there!
Here is the formula for Buff Dormeier Trend Thrust Indicator:
inputs: price(close), Fastlen(12), Slowlen(26), W(9), volToday(true);
variables: fastavg(0), slowavg(0), sprd(0), avgsprd(0), sLOW(0), vavg(0), FAST(0),
Vfactor(0), IVfactor(0), m(0), sprdiff(0), mcad(0), VD(0);
fastavg = bd.vwma(Price, FastLen, volToday);
slowavg = bd.vwma(Price, slowLen, volToday);
m = xaverage(close, fastlen) - xaverage(close, slowlen);
if xaverage(volume,slowlen) <> 0 then
Vfactor = (bd.vwma(volume,fastlen,voltoday)/xaverage(volume,slowlen))*10;
if xaverage(volume,fastlen) <> 0 then
IVfactor = (bd.vwma(volume,slowlen,voltoday)/xaverage(volume,fastlen))*10;
if ivfactor <> 0 and vfactor <> 0 then
FAST = FASTAVG/(VFACTOR/IVFACTOR);
if ivfactor <> 0 and vfactor <> 0 then
SLOW = (IVFACTOR/VFACTOR)* SLOWavg;
sprd = (fast - slow);
Vavg = BD.VWMA (vfactor,fastlen,voltoday)/xaverage (ivfactor,slowlen) *W;
avgsprd = round (bd.vwma(sprd,vavg,voltoday),3);
sprdiff = (sprd - avgsprd);
mcad = xaverage((m),(w));
vd = sprdiff-mcad;
plot1 (sprd, "sprd");
plot2 (avgsprd, "avg sprd");
plot3 (vd, "Buff diff");
VWMA function (volume-weighted simple moving average)
[LegacyColorValue = true];
{***************************************************************************************
// fileName: BD.VWMA
// Logic by Buff Dormeier
// Programming code written by:
Fred G. Schutzman, CMT
27 Briarwood Drive
New City, NY 10956
Tel: (914) 634-2978
Fax: (914) 634-1890
Email: FredSchutzman@attglobal.net
Internet: www.fredschutzman.com
// Function returns a Volume Weighted SMA
// futures volume is always reported 1-day late
// therefore, this function has the ability to calculate a MA with an offset of 1
// Date last changed: January 30, 2000
****************************************************************************************}
Inputs: price(numericSeries), { data to be averaged; e.g. close }
length(numericSimple), { length of moving average }
volToday(trueFalse); { true = volume is available for today (e.g. stocks)
false = volume is NOT available for today (e.g.futures) }
Vars: beg(0), { days back to begin working with for average }
sumOfVol(0), { sum of volume }
vwPx(0), { volume weighted price }
vwMa(0), { volume weighted moving average }
counter(0); { counter }
{ initialize/reset first 4 variables }
if currentBar = 1 then begin
if volToday = true then
beg = 0
else if volToday = false then
beg = 1;
end;
sumOfVol = 0;
vwPx = 0;
vwMa = 0;
{ update sumOfVol variable on each bar }
for counter = beg to (length-1+beg) begin
sumOfVol = sumOfVol + volume[counter];
end;
{ update vwPx and vwMa variables on each bar }
for counter = beg to (length-1+beg) begin
if sumOfVol > 0 then
vwPx = price[counter] * volume[counter] / sumOfVol;
vwMa = vwMa + vwPx;
end;
{ return the VWMA if enough data is present, else return 0 }
if length >= 1 and volume[length-1+beg] > 0 then
BD.VWMA = vwMa
else
BD.VWMA = 0;
Could you compile a MT4 version please brother?
Cheers!