I have ts code of modified macdbb .can anybody pl convert it to afl.
here is the code- =============#TT Trend for futures only as Trend Director=================
[LegacyColorValue = true];
{
***** Study name: 'TT Trend'
}
{ ***** DLLs Section ***** }
{ ***** INPUTs Section *****}
Inputs: Length(52),upColor(green), dnColor(magenta);
{ ***** VARs Section ***** }
Variables: tactivator(0),mm(0),mm2(0);
{ ***** ARRAYs Section *****}
{ ***** CODE Section ***** }
tactivator = ((xaverage(VOLUME, Length)-xaverage (OPENINT, Length))*1.800000)/1000;
Plot4(tactivator, "S Trend");
Plot5(tactivator, "SB");
PLOT6 (tactivator, "TT Trend") ;
IF (PLOT6 >= 0) THEN SETPLOTCOLOR (6, upColor) ELSE SETPLOTCOLOR (6, dnColor) ;
Plot7 (0, "Zero") ;
=============#TT UTrend as Trend Director=========================
[LegacyColorValue = true];
{
***** Study name: 'TT - UTrend'
}
{ ***** INPUTs Section *****}
{ ***** VARs Section ***** }
Variables: FastLen(12), MMLen(34), SlowLen(26), Length(10), StDv(1), MidLine(0);
Variables: Average1(32), Average2(5), Smooth(5), PosColor(cyan), NegColor(magenta);
Variables: bbMacd(0), avg(0), sDev(0), upperBand(0), lowerBand(0);
Variables: bbHi(0), bbLo(0), t3Trnd(0), t3TrndSmth(0), smthFactor(2/(Smooth+1));
Variables: smooth01(0), smooth02(0), smooth1(0), smooth21(0);
Variables: smooth22(0), smooth23(0), price2(0), price3(0), xAvg01(0);
Variables: xAvg02(0), xAvg1(0), xAvg21(0), xAvg22(0), xAvg23(0);
Variables: xAvg31(0), xAvg32(0), xAvg33(0), sumSqr(0), mean(0);
Variables: ii(0);
{ ***** ARRAYs Section *****}
{ ***** CODE Section ***** }
IF true THEN
BEGIN
price2 = CLOSE-CLOSE[1] ;
price3 = ABSVALUE (price2) ;
IF (CURRENTBAR = 1) THEN
BEGIN
smooth01 = 2/(FastLen+1) ;
smooth02 = 2/(SlowLen+1) ;
smooth1 = 2/(Length+1) ;
smooth21 = 2/(Average1+1) ;
smooth22 = 2/(Average2+1) ;
smooth23 = 1 ;
xAvg01 = CLOSE ;
xAvg02 = CLOSE ;
xAvg1 = 0 ;
xAvg21 = price2 ;
xAvg22 = price2 ;
xAvg23 = price2 ;
xAvg31 = price3 ;
xAvg32 = price3 ;
xAvg33 = price3 ;
END ELSE
BEGIN
xAvg01 = xAvg01[1]+smooth01*(CLOSE-xAvg01[1]) ;
xAvg02 = xAvg02[1]+smooth02*(CLOSE-xAvg02[1]) ;
bbMacd = xAvg01-xAvg02 ;
xAvg1 = xAvg1[1]+smooth1*(bbMacd-xAvg1[1]) ;
xAvg21 = xAvg21[1]+smooth21*(price2-xAvg21[1]) ;
xAvg22 = xAvg22[1]+smooth22*(xAvg21-xAvg22[1]) ;
xAvg23 = xAvg23[1]+smooth23*(xAvg22-xAvg23[1]) ;
xAvg31 = xAvg31[1]+smooth21*(price3-xAvg31[1]) ;
xAvg32 = xAvg32[1]+smooth22*(xAvg31-xAvg32[1]) ;
xAvg33 = xAvg33[1]+smooth23*(xAvg32-xAvg33[1]) ;
END ;
sDev = 0 ;
IF (Length > 0) THEN
BEGIN
mean = 0 ;
sumSqr = 0 ;
FOR ii = 0 TO Length-1
BEGIN
mean = mean+bbMacd[ii] ;
END ;
mean = mean/Length ;
FOR ii = 0 TO Length-1
BEGIN
sumSqr = sumSqr+SQUARE (bbMacd[ii]-mean) ;
END ;
sDev = SQUAREROOT (sumSqr/Length) ;
END ;
avg = xAvg1 ;
upperBand = avg+StDv*sDev ;
lowerBand = avg-StDv*sDev ;
bbHi = bbMacd ;
bbLo = bbMacd ;
FOR ii = MMLen-1 DOWNTO 1
BEGIN
IF (bbHi < bbMacd[ii]) THEN bbHi = bbMacd[ii] ;
IF (bbLo > bbMacd[ii]) THEN bbLo = bbMacd[ii] ;
END ;
PLOT1 (bbMacd, "UTrend") ;
PLOT2 (bbMacd, "UTrend S") ;
PLOT3 (upperBand, "upper") ;
PLOT4 (lowerBand, "lower") ;
PLOT5 (0, "ZeroLine") ;
PLOT6 (0, "ZeroLine S") ;
PLOT7 (bbMacd, "UTrend H") ;
PLOT8 (bbMacd, "UTrend Line") ;
IF bbMacd < 0 then setplotcolor (5,NegColor);
IF bbMacd > 0 then setplotcolor (5,PosColor);
IF (xAvg33 <> 0) THEN t3Trnd = 100*xAvg23/xAvg33 ELSE t3Trnd = 0 ;
IF (CURRENTBAR = 1) THEN t3TrndSmth = t3Trnd ELSE t3TrndSmth = t3TrndSmth[1]+smthFactor*(t3Trnd-t3TrndSmth[1]) ;
IF (t3Trnd >= t3TrndSmth) AND (bbMacd > lowerBand) THEN SETPLOTCOLOR (1, PosColor) ;
IF (t3Trnd <= t3TrndSmth) AND (bbMacd < upperBand) THEN SETPLOTCOLOR (1, NegColor) ;
END ;
here is the code- =============#TT Trend for futures only as Trend Director=================
[LegacyColorValue = true];
{
***** Study name: 'TT Trend'
}
{ ***** DLLs Section ***** }
{ ***** INPUTs Section *****}
Inputs: Length(52),upColor(green), dnColor(magenta);
{ ***** VARs Section ***** }
Variables: tactivator(0),mm(0),mm2(0);
{ ***** ARRAYs Section *****}
{ ***** CODE Section ***** }
tactivator = ((xaverage(VOLUME, Length)-xaverage (OPENINT, Length))*1.800000)/1000;
Plot4(tactivator, "S Trend");
Plot5(tactivator, "SB");
PLOT6 (tactivator, "TT Trend") ;
IF (PLOT6 >= 0) THEN SETPLOTCOLOR (6, upColor) ELSE SETPLOTCOLOR (6, dnColor) ;
Plot7 (0, "Zero") ;
=============#TT UTrend as Trend Director=========================
[LegacyColorValue = true];
{
***** Study name: 'TT - UTrend'
}
{ ***** INPUTs Section *****}
{ ***** VARs Section ***** }
Variables: FastLen(12), MMLen(34), SlowLen(26), Length(10), StDv(1), MidLine(0);
Variables: Average1(32), Average2(5), Smooth(5), PosColor(cyan), NegColor(magenta);
Variables: bbMacd(0), avg(0), sDev(0), upperBand(0), lowerBand(0);
Variables: bbHi(0), bbLo(0), t3Trnd(0), t3TrndSmth(0), smthFactor(2/(Smooth+1));
Variables: smooth01(0), smooth02(0), smooth1(0), smooth21(0);
Variables: smooth22(0), smooth23(0), price2(0), price3(0), xAvg01(0);
Variables: xAvg02(0), xAvg1(0), xAvg21(0), xAvg22(0), xAvg23(0);
Variables: xAvg31(0), xAvg32(0), xAvg33(0), sumSqr(0), mean(0);
Variables: ii(0);
{ ***** ARRAYs Section *****}
{ ***** CODE Section ***** }
IF true THEN
BEGIN
price2 = CLOSE-CLOSE[1] ;
price3 = ABSVALUE (price2) ;
IF (CURRENTBAR = 1) THEN
BEGIN
smooth01 = 2/(FastLen+1) ;
smooth02 = 2/(SlowLen+1) ;
smooth1 = 2/(Length+1) ;
smooth21 = 2/(Average1+1) ;
smooth22 = 2/(Average2+1) ;
smooth23 = 1 ;
xAvg01 = CLOSE ;
xAvg02 = CLOSE ;
xAvg1 = 0 ;
xAvg21 = price2 ;
xAvg22 = price2 ;
xAvg23 = price2 ;
xAvg31 = price3 ;
xAvg32 = price3 ;
xAvg33 = price3 ;
END ELSE
BEGIN
xAvg01 = xAvg01[1]+smooth01*(CLOSE-xAvg01[1]) ;
xAvg02 = xAvg02[1]+smooth02*(CLOSE-xAvg02[1]) ;
bbMacd = xAvg01-xAvg02 ;
xAvg1 = xAvg1[1]+smooth1*(bbMacd-xAvg1[1]) ;
xAvg21 = xAvg21[1]+smooth21*(price2-xAvg21[1]) ;
xAvg22 = xAvg22[1]+smooth22*(xAvg21-xAvg22[1]) ;
xAvg23 = xAvg23[1]+smooth23*(xAvg22-xAvg23[1]) ;
xAvg31 = xAvg31[1]+smooth21*(price3-xAvg31[1]) ;
xAvg32 = xAvg32[1]+smooth22*(xAvg31-xAvg32[1]) ;
xAvg33 = xAvg33[1]+smooth23*(xAvg32-xAvg33[1]) ;
END ;
sDev = 0 ;
IF (Length > 0) THEN
BEGIN
mean = 0 ;
sumSqr = 0 ;
FOR ii = 0 TO Length-1
BEGIN
mean = mean+bbMacd[ii] ;
END ;
mean = mean/Length ;
FOR ii = 0 TO Length-1
BEGIN
sumSqr = sumSqr+SQUARE (bbMacd[ii]-mean) ;
END ;
sDev = SQUAREROOT (sumSqr/Length) ;
END ;
avg = xAvg1 ;
upperBand = avg+StDv*sDev ;
lowerBand = avg-StDv*sDev ;
bbHi = bbMacd ;
bbLo = bbMacd ;
FOR ii = MMLen-1 DOWNTO 1
BEGIN
IF (bbHi < bbMacd[ii]) THEN bbHi = bbMacd[ii] ;
IF (bbLo > bbMacd[ii]) THEN bbLo = bbMacd[ii] ;
END ;
PLOT1 (bbMacd, "UTrend") ;
PLOT2 (bbMacd, "UTrend S") ;
PLOT3 (upperBand, "upper") ;
PLOT4 (lowerBand, "lower") ;
PLOT5 (0, "ZeroLine") ;
PLOT6 (0, "ZeroLine S") ;
PLOT7 (bbMacd, "UTrend H") ;
PLOT8 (bbMacd, "UTrend Line") ;
IF bbMacd < 0 then setplotcolor (5,NegColor);
IF bbMacd > 0 then setplotcolor (5,PosColor);
IF (xAvg33 <> 0) THEN t3Trnd = 100*xAvg23/xAvg33 ELSE t3Trnd = 0 ;
IF (CURRENTBAR = 1) THEN t3TrndSmth = t3Trnd ELSE t3TrndSmth = t3TrndSmth[1]+smthFactor*(t3Trnd-t3TrndSmth[1]) ;
IF (t3Trnd >= t3TrndSmth) AND (bbMacd > lowerBand) THEN SETPLOTCOLOR (1, PosColor) ;
IF (t3Trnd <= t3TrndSmth) AND (bbMacd < upperBand) THEN SETPLOTCOLOR (1, NegColor) ;
END ;