conert ts code to amibroker

#1
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 ;
 
#2
FastLen, MMLen, SlowLen, Length, StDv, Average1, Average2, Smooth, i: integer;
xAvg1, bbMacd, xAvg21, xAvg22, xAvg23, xAvg31, xAvg32, xAvg33: TSeries; xAvg1, bbMacd, xAvg21, xAvg22, xAvg23, xAvg31, xAvg32, xAvg33: tseries;
sDev, upperBand, lowerBand, t3Trnd, t3TrndSmth: TSeries; sDev, upper band, lower band, t3Trnd, t3TrndSmth: tseries;
begin beginning
FastLen := 12; FastLen: = 12;
MMLen := 34; MMLen: = 34;
SlowLen := 26; SlowLen: = 26;
Length := 10; Length: = 10;
StDv := 1; StDv: = 1;
Average1 := 32; Average1: = 32;
Average2 := 5; Average2: = 5;
Smooth := 5; Smooth: = 5;

{ Indicator eigenschappen } Indicator properties {}
with Indicator do do with Indicator
begin beginning
RequiredBars := 5*(SlowLen+Length+Average1+Average2); required bars: = 5 * (Length + + SlowLen Average1 Average2 +);
end; end;

{ Berekening } {Calculation}
bbMacd := MACD(Close, FastLen, SlowLen); bbMacd: = MACD (Close, FastLen, SlowLen);
xAvg1 := MA(bbMacd, maExponential, Length); xAvg1: = MA (bbMacd, maExponential, Length);
sDev := StdDev(bbMacd, Length); sDev: = StdDev (bbMacd, Length);
upperBand := AddSeries(xAvg1, MultiplySeriesBy(sDev, StDv)); upper band: AddSeries = (xAvg1, MultiplySeriesBy (sDev, StDv));
lowerBand := SubtractSeries(xAvg1, MultiplySeriesBy(sDev, StDv)); lower band: SubtractSeries = (xAvg1, MultiplySeriesBy (sDev, StDv));

xAvg21 := MA(Momentum(Close, 1), maExponential, Average1); xAvg21: = MA (Momentum (Close, 1), maExponential, Average1);
xAvg22 := MA(xAvg21, maExponential, Average2); xAvg22: = MA (xAvg21, maExponential, Average2);
xAvg23 := MA(xAvg22, maExponential, 1); xAvg23: = MA (xAvg22, maExponential, 1);
xAvg31 := MA(AbsSeries(Momentum(Close, 1)), maExponential, Average1); xAvg31: = MA (AbsSeries (Momentum (Close, 1)), maExponential, Average1);
xAvg32 := MA(xAvg31, maExponential, Average2); xAvg32: = MA (xAvg31, maExponential, Average2);
xAvg33 := MA(xAvg32, maExponential, 1); xAvg33: = MA (xAvg32, maExponential, 1);

t3Trnd := DivideSeries(xAvg23, xAvg33); t3Trnd: = divide series (xAvg23, xAvg33);
t3TrndSmth := MA(t3Trnd, maExponential, Smooth); t3TrndSmth: = MA (t3Trnd, maExponential, Smooth);
for i:=0 to BarCount-1 do for i: = 0 to BarCount-1 do
begin beginning
if IsValid(t3TrndSmth) and IsValid(bbMacd) then if isvalid (t3TrndSmth ) and isvalid (bbMacd ) then
begin beginning
SetBarColor(0, i, clLime); SetBarColor (0, i, clLime);
if (t3Trnd <= t3TrndSmth) AND (bbMacd < upperBand) THEN if (t3Trnd <= t3TrndSmth ) AND (bbMacd <upper band ) THEN
SetBarColor(0, i, clRed); SetBarColor (0, i, clRed);
end; end;
end; end;

{ Weergave } {Display}
with CreateLine(bbMacd) do line with CreateObject (bbMacd) do
begin beginning
Name := 'bbMacd'; Name: = 'bbMacd';
Color := clWhite; Color: = clWhite;
end; end;
with CreateLine(upperBand) do CreateObject line with (upper band) do
begin beginning
Name := 'upperBand'; Name: = 'upper band;
Color := clYellow; Color: = clYellow;
end; end;
with CreateLine(lowerBand) do line with CreateObject (lower band) do
begin beginning
Name := 'lowerBand'; Name: = "lower band";
Color := clAqua; Color: = clAqua;
end; end;
end. end.

can someone correct this one
 

Similar threads