PureBytes Links
Trading Reference Links
|
Can anyone help me to convert the following Tradestation code to Amibroker.Other Indicators I could convert to Afl.
Regards
Trend for All Markets - is a updated version of T3 - MACD BB
Is interesting that Roy kelly Trend Indicator is equal to this, the only differences is the bands.
[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 ;
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|