Someone on my yahoo board asked for this.
ELD attached.
Code: Select all
{ _SMAA_TRIX_2Line }
{Attn: TradeStation
if this indicator is posted on the TradeStation Forum, I, TheRumpledOne, did NOT post it there,
so I can't be blamed for this indicator having my contact info.}
{MODIFYING Programmer: Avery T. Horton, Jr. aka TheRumpledOne,
gifts and donations accepted, PO Box 43575, Tucson, AZ 85733 }
{ © Copyright 2006 Avery T. Horton, Jr.}
{ 2-Line TRIX indicator for Jongseon Kim's TAOSC article
"When and When Not To Trade", TAOSC - Jan. 2004 }
inputs:
TRIXLength( 5 ),
SigLineXMALen( 3 ) ;
Inputs:
iMsgLong("LONG"),
iMsgShort("SHORT"),
iMsgFlat("FLAT"),
iMsgXAbove("XA"),
iMsgXBelow("XB"),
iDecimals(2);
variables:
EMA1( 0 ),
EMA2( 0 ),
EMA3( 0 ),
TRIXLine( 0 ),
SignalLine( 0 ) ;
variables:
xPeriods(60),
xInterval(0),
sFirstPass(true),
xBars(0),
xInd(0),
tMsg(""),
tAlert("");
variables:
FG1(white),
BG1(black),
fg2(white),
bg2(black),
fg3(white),
bg3(black),
fg4(white),
bg4(black);
{commentary variables}
variables:
xcomm(0),
oComm1( "" ),
oComm2( "" ),
oComm3( "" ),
oComm4( "" ),
oComm5( "" ),
oComm6( "" ),
oComm7( "" ),
oComm8( "" ),
oComm9( "" ),
oComm10( "" );
variables:
xDate(0),
xTime(0),
xOpen(0),
xClose(0),
xHigh(0),
xLow(0);
{first time through}
if sFirstPass
then begin
sFirstPass = false;
{bar test}
If bartype = 4
then xInterval = 94
else
If bartype = 3
then xInterval = 93
else
If bartype = 2
then xInterval = 92
else
If bartype = 1
then begin
xInterval = BarInterval;
end; { If bartype = 1 }
end; {if sFirstPass}
{ INITIALIZE }
FG1 = WHITE;
BG1 = BLACK;
fg2 = WHITE;
bg2 = BLACK;
fg3 = WHITE;
bg3 = BLACK;
fg4 = WHITE;
bg4 = BLACK;
tMsg = "";
tAlert = "";
xDate = Date ;
xTime = Time ;
xOpen = Open;
xClose = Close;
xHigh = High;
xLow = Low;
{ PROCESSING }
EMA1 = XAverage( Close, TRIXLength ) ;
EMA2 = XAverage( EMA1, TRIXLength ) ;
EMA3 = XAverage( EMA2, TRIXLength ) ;
if EMA3[1] <> 0
then TRIXLine = 10 * ( EMA3 - EMA3[1] ) / EMA3[1] ;
SignalLine = XAverage( TRIXLine, SigLineXMALen ) ;
{ Alert criteria }
If TRIXLine CROSSES ABOVE SignalLine
then begin
xBars = 1;
Fg3 = BLACK;
Bg3 = yellow;
tMsg = iMsgXAbove ;
end
else
If TRIXLine CROSSES below SignalLine
then begin
xBars = 1;
Fg3 = red;
Bg3 = yellow;
tMsg = iMsgXBelow ;
end
else
If TRIXLine > SignalLine
then begin
xBars = xBars + 1;
Fg3 = BLACK;
Bg3 = green;
tMsg = iMsgLong ;
end
else
If TRIXLine < SignalLine
then begin
xBars = xBars + 1;
Fg3 = BLACK;
Bg3 = red;
tMsg = iMsgShort ;
end
else begin
xBars = xBars + 1;
Fg3 = white;
Bg3 = BLACK;
tMsg = iMsgFlat;
end;
tAlert = tMsg ;
If TRIXLine CROSSES ABOVE 0
then begin
Fg1 = BLACK;
Bg1 = yellow;
end
else
If TRIXLine CROSSES below 0
then begin
Fg1 = red;
Bg1 = yellow;
end
else
If TRIXLine > 0
then begin
Fg1 = BLACK;
Bg1 = green;
end
else
If TRIXLine < 0
then begin
Fg1 = BLACK;
Bg1 = red;
end
else begin
Fg1 = white;
Bg1 = BLACK;
end;
If SignalLine CROSSES ABOVE 0
then begin
Fg2 = BLACK;
Bg2 = yellow;
end
else
If SignalLine CROSSES below 0
then begin
Fg2 = red;
Bg2 = yellow;
end
else
If SignalLine > 0
then begin
Fg2 = BLACK;
Bg2 = green;
end
else
If SignalLine < 0
then begin
Fg2 = BLACK;
Bg2 = red;
end
else begin
Fg2 = white;
Bg2 = BLACK;
end;
{ Alert }
if tAlert <> ""
and tAlert <> tAlert[1]
then Alert( tAlert ) ;
{ PLOT }
Plot1( TRIXLine, "TRIXLine", fg1 ) ;
SetPlotBGColor( 1, bg1);
Plot2( SignalLine, "SignalLine" , fg2 ) ;
SetPlotBGColor( 2, bg2);
Plot3( tMsg , "Msg", fg3 ) ;
SetPlotBGColor( 3, bg3 );
Plot4( xBars , "Trend", fg3 ) ;
SetPlotBGColor( 4, bg3 );
xComm = _fCommentary(oComm1, oComm2, oComm3, oComm4, oComm5, oComm6, oComm7, oComm8, oComm9, oComm10);
CommentaryCl(oComm1 );
CommentaryCl(oComm2 );
CommentaryCl(oComm3 );
CommentaryCl(oComm4 );
CommentaryCl(oComm5 );
CommentaryCl(oComm6 );
CommentaryCl(oComm7 );
CommentaryCl(oComm8 );
CommentaryCl(oComm9 );
CommentaryCl(oComm10 );
{
CommentaryCl( "Open_AvgCost: ", NumToStr( Open_AvgCost , iDecimals) );
CommentaryCl( "xInd: ", NumToStr( xInd , iDecimals) );
CommentaryCl( "xFreeShares: ", NumToStr( xFreeShares , 0 ) );
}