January 2004
TRADERS' TIPS

Here is this month's selection of Traders' Tips, contributed by various developers of technical analysis software to help readers more easily implement some of the strategies presented in this and other issues.

You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply "select" the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose "copy" from the browser menu. The copied text can then be "pasted" into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open Web page, data can be transferred with ease.

This month's tips include formulas and programs for:

TRADESTATION: HOLDING OVERNIGHT POSITIONS
TRADESTATION: TRIX
METASTOCK: HOLDING OVERNIGHT POSITIONS
METASTOCK: TRIX
AMIBROKER: HOLDING OVERNIGHT POSITIONS
AMIBROKER: TRIX
eSIGNAL: HOLDING OVERNIGHT POSITIONS
eSIGNAL: TRIX
AIQ EXPERT DESIGN STUDIO: HOLDING OVERNIGHT POSITIONS
AIQ EXPERT DESIGN STUDIO: TRIX
Wealth-Lab: Holding Overnight Positions
Wealth-Lab: TRIX
NEUROSHELL TRADER: HOLDING OVERNIGHT POSITIONS
NEUROSHELL TRADER: TRIX
Prophet.Net: TRIX
NeoTicker: HOLDING OVERNIGHT POSITIONS
TradingSolutions: TRIX
Investor/RT: TRIX
SMARTrader: TRIX
TechniFilter Plus: Trading in Tempo
StockWiz: TRIX
Financial Data Calculator: HOLDING OVERNIGHT POSITIONS
Financial Data Calculator: TRIX
or return to January 2004 Contents


TRADESTATION: HOLDING OVERNIGHT POSITIONS

Anthony Trongone's article "Holding Overnight Positions" describes a trading strategy called rising darkness, in which trade entries for the cubes (AMEX: QQQ) are based on the one-day percentage change in QQQ price and a comparison of the present day's QQQ volume to historical volume.

Four different combinations of price and volume are used as trade entry triggers. When certain conditions are met, this strategy enters trades at the end of the day. (It should be noted that Trongone's article describes entering in the afterhours market, though no exact entry time is specified.) The strategy always exits on the following day's open.

Our code for the rising darkness strategy has two user inputs: "Sample Window" and "TradeType." SampleWindow sets the number of historical days to be used in determining the relative rank of today's volume. The user input "TradeType" determines which of four possible entry-generating combinations of price and volume will be used.

Two versions are provided, one for daily bars and one for intraday bars. A sample chart is in Figure 1.

FIGURE 1: TRADESTATION, RISING DARKNESS. Here's a sample TradeStation chart demonstrating the rising darkness indicator as described in Anthony Trongone's article in this issue.
Strategy: Rising Darkness (for backtesting purposes)
{ Rising Darkness strategy based on Anthony Trongone's
'Holding Positions Overnight', TAOSC - Jan. 2004 }
inputs:
 SampleWindow( 375 ),
 TradeType( 1 ) ;
{
TradeType1 = significantly decreasing volume,
 significant price rise
TradeType2 = significantly decreasing volume,
 significantly price decline
TradeType3 = significantly increasing volume,
 significantly price rise
TradeType4 = significantly increasing volume,
 significantly price decline
}
variables:
 Counter( 0 ),
 MA8Vol( 0 ),
 VolPctChg( 0 ),
 PriPctChg( 0 ),
 Rank( 0 ),
 RankPct( 0 ),
 DayType( 0 ) ;
MA8Vol = Average( Volume, 8 ) ;
if MA8Vol[1] > 0 then
 VolPctChg = ( MA8Vol - MA8Vol[1] ) / MA8Vol[1] ;
if Close[1] > 0 then
 PriPctChg = 100 * ( Close - Close[1] ) / Close[1] ;
Rank = 0 ;
for Counter = 1 to SampleWindow
 begin
 if VolPctChg > VolPctChg[ Counter ] then
  Rank = Rank + 1 ;
 end ;
RankPct = 100 * Rank / SampleWindow ;
if RankPct <= 30 and PriPctChg > 1 then
 DayType = 1
else if RankPct <= 30 and PriPctChg < -1 then
 DayType = 2
else if RankPct >= 70 and PriPctChg > 1 then
 DayType = 3
else if RankPct >= 70 and PriPctChg < -1 then
 DayType = 4
else
 DayType = 0 ;
if TradeType = DayType then
 begin
 Buy this bar at close ;
 Sell next bar at market ;
 end ;
Strategy: Rising Darkness - RT
{ Real Time version of Rising Darkness strategy based
on Anthony Trongone's  'Holding Positions Overnight',
TAOSC - Jan. 2004 }
inputs:
 SampleWindow( 375 ),
 TradeType( 1 ),
  MyExitTime( 935 ),
    MyEntryTime( 1600 ) ;
{
TradeType1 = significantly decreasing volume,
 significant price rise
TradeType2 = significantly decreasing volume,
 significantly price decline
TradeType3 = significantly increasing volume,
 significantly price rise
TradeType4 = significantly increasing volume,
 significantly price decline
}
variables:
 Counter( 0 ),
 MA8Vol( 0 ),
 VolPctChg( 0 ),
 PriPctChg( 0 ),
 Rank( 0 ),
 RankPct( 0 ),
 DayType( 0 ),
  MyVolume( 0 ),
    OldMA8Vol( 0 ) ;
array:
 MyDailyVol[8](0),
 MyMA8VolArray[375](0);
if Time = SessionEndTime(0,1) then
 begin
 For Value1 = 2 to 6
  begin
  MyDailyVol[8 - Value1 ] = MyDailyVol[ 7 - Value1] ;
  end ;
 MyDailyVol[1] = MyVolume ;
 MyVolume = 0 ;
 end
else
 MyVolume = MyVolume + Ticks ;
if Time = MyEntryTime then
 begin
 OldMa8Vol = MA8Vol ;
 Value2 = 0 ;
 For Value1 = 1 to 7
   begin
  Value2 = Value2 + MyDailyVol[Value1] ;
  end ;
 MA8Vol = ( MyVolume + Value2 ) / 8 ;
 if OldMA8Vol > 0 then
  begin
  VolPctChg = ( MA8Vol - OldMA8Vol ) / OldMA8Vol ;
  For Value1 = 2 to SampleWindow - 2
   begin
   MyMA8VolArray[SampleWindow - Value1] =
    MyMA8VolArray[SampleWindow -1 - Value1] ;
   end ;
  MyMA8VolArray[1] = VolPctChg ;
  end ;
 if Close[1] > 0 then
  PriPctChg = 100 * ( CloseD(0) - CloseD(1) ) / CloseD(1) ;
 Rank = 0 ;
 for Counter = 1 to SampleWindow - 1
  begin
  if VolPctChg > MyMA8VolArray[ Counter + 1 ] then
   Rank = Rank + 1 ;
  end ;
 RankPct = 100 * Rank / SampleWindow ;
 
 if RankPct <= 30 and PriPctChg > 1 then
  DayType = 1
 else if RankPct <= 30 and PriPctChg < -1 then
  DayType = 2
 else if RankPct >= 70 and PriPctChg > 1 then
  DayType = 3
 else if RankPct >= 70 and PriPctChg < -1 then
  DayType = 4
 else
  DayType = 0 ;
{ print(Date ," ", Date[1] ," ",time," ",
  Daytype," ",MA8Vol," ",OldMA8Vol," ",VolPctchg," ",Rank," ",Rankpct," ",
  MyVolume," ",MyDailyvol[1]," ",MyDailyVol[2]);}
 end ;
if TradeType = DayType and Time = MyEntryTime then
 Buy this bar at close ;
if MarketPosition = 1 and Time = MyExitTime then
 Sell next bar at market ;


An ELD file will be available for download from the EasyLanguage Library on www.tradestationworld.com. Look for the file "RisingDarkness.Eld."

--Mark Mills
MarkM@TSSec at www.TradeStationWorld.com
EasyLanguage Questions Forum
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.


GO BACK


TRADESTATION: TRIX

In his article "Trading In Tempo With TRIX," Jongseon Kim proposes some trading strategies based on the TRIX indicator. Code is provided for both Kim's version of the TRIX indicator and for the strategies he proposes. The indicator, named "Trix (2-Line)," takes two user inputs: TrixLength and SigLineXMALen. These are the length values to be used for the calculation of Kim's TRIX and "Signal Line," respectively.

The TradeStation strategy, also named "Trix (2-Line)," has four inputs: TrixLength, SigLineXMALen, EntrySignal, and ExitSignal. The TrixLength and SigLineXMALen inputs perform the same function in the strategy as they do in the indicator. The EntrySignal input, if set to 1, causes entries to occur on golden crosses. If EntrySignal is set to 2, then entries occur on TRIX bounces. The ExitSignal input, if set to 1, causes exits on TRIX falls. If ExitSignal is set to 2, then exit will occur on a dead cross. A sample chart is in Figure 2.

 
FIGURE 2: TRADESTATION, TRIX. Here's a sample TradeStation chart of TRIX (triple exponential smoothing oscillator).
Indicator: TRIX (2 Line)
{ 2-Line TRIX indicator for Jongseon Kim's TAOSC article
"When and When Not To Trade", TAOSC - Jan. 2004 }
inputs:
 TRIXLength( 5 ),
 SigLineXMALen( 3 ) ;
 
variables:
 EMA1( 0 ),
 EMA2( 0 ),
 EMA3( 0 ),
 TRIXLine( 0 ),
 SignalLine( 0 ) ;
EMA1 = XAverage( Close, TRIXLength ) ;
EMA2 = XAverage( EMA1, TRIXLength ) ;
EMA3 = XAverage( EMA2, TRIXLength ) ;
if EMA3[1] <> 0 then
 { Ensure not about to divide by zero }
 TRIXLine = 10 * ( EMA3 - EMA3[1] ) / EMA3[1] ;
SignalLine = XAverage( TRIXLine, SigLineXMALen ) ;
Plot1( TRIXLine, "TRIXLine" ) ;
Plot2( SignalLine, "SignalLine" ) ;
Strategy: TRIX (2 Line)
{ 2-Line TRIX strategy for Jongseon Kim's TAOSC article
"When and When Not To Trade", TAOSC - Jan. 2004 }
inputs:
 TRIXLength( 5 ),
 SigLineXMALen( 3 ),
 EntrySignal( 1 ),
  { 1 = Golden Cross, 2 = TRIX Bounce }
 ExitSignal( 1 ) ;
 { 1 = TRIX Fall, 2 = Dead Cross }
variables:
 EMA1( 0 ),
 EMA2( 0 ),
 EMA3( 0 ),
 TRIXLine( 0 ),
 SignalLine( 0 ) ;
EMA1 = XAverage( Close, TRIXLength ) ;
EMA2 = XAverage( EMA1, TRIXLength ) ;
EMA3 = XAverage( EMA2, TRIXLength ) ;
if EMA3[1] <> 0 then
 { Ensure not about to divide by zero }
 TRIXLine = 10 * ( EMA3 - EMA3[1] ) / EMA3[1] ;
 { Mult. by 10 to scale per author's charts. }
SignalLine = XAverage( TRIXLine, SigLineXMALen ) ;
if EntrySignal = 1
 and TRIXLine crosses above SignalLine then
  buy ( "GC" ) this bar on Close
  { Enter on Golden Cross. }
else if EntrySignal = 2 and TRIXLine > TRIXLine[1] then
 buy ( "TB" ) this bar on Close ;
 { Enter on TRIX Bounce }
if ExitSignal = 1 and TRIXLine < TRIXLine[1] then
 sell ( "TF" ) this bar on Close
 { Exit on TRIX Fall. }
else if ExitSignal = 2
 and TRIXLine crosses below SignalLine then
  sell this bar on Close ;
  { Exit on Dead Cross. }


An ELD file will be available for download from the EasyLanguage Exchange on www.tradestationworld.com. Look for the file "TRIX by Kim.Eld."

--Mark Mills
MarkM@TSSec at www.TradeStationWorld.com
EasyLanguage Questions Forum
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
GO BACK


METASTOCK: HOLDING OVERNIGHT POSITIONS

Anthony Trongone's "Holding Overnight Positions" defines four conditions which, paired up, will indicate a greater chance of a successful overnight trade. MetaStock can scan for these conditions over a group of securities, and report those making the appropriate pairings. This is done with an exploration.

To create this exploration, in MetaStock, go to Tools and select the Explorer. Click "New" and enter a name ("Rising Darkness"). Then enter the following formulas in the corresponding tabs:
 

Rising Darkness
     COLUMN FORMULAS
         ColumnA: 30 dn V
             mav:=Mov(V,8,S);
             vr:=(mav-Ref(mav,-1))/Ref(mav,-1);
             volrank:=LastValue((Cum(vr>LastValue(vr))/Cum(IsDefined(vr)))*100);
             volrank >= 70
 
         ColumnB: 30 up V
             mav:=Mov(V,8,S);
             vr:=(mav-Ref(mav,-1))/Ref(mav,-1);
             volrank:=LastValue((Cum(vr>LastValue(vr))/Cum(IsDefined(vr)))*100);
             volrank <= 30
 
         ColumnC: up price
             ROC(C,1,%)>1
 
         ColumnD: dn price
             ROC(C,1,%)<-1
 
     FILTER
         Formula:
             (colA OR colB) AND (colC OR colD)
--William Golson
Equis International
www.equis.com


GO BACK


METASTOCK: TRIX

In his article "Trading In Tempo With TRIX," Jongseon Kim presents a trading system based on the TRIX indicator. This indicator is built into MetaStock and does not need to be defined in a custom formula. The formulas that follow create an exploration and a system test based on his conditions.

To create this exploration in MetaStock, go to Tools and select the Explorer. Click "New" and enter a name ("Trix system"). Then enter the following formulas in the corresponding tabs:
 

TRIX system
     COLUMN FORMULAS
         ColumnA: gold X
             tx:=TRIX(5);
             sig:=Mov(tx,3,E);
             Cross(tx,sig)
 
         ColumnB: Fall
             tx:=TRIX(5);
             Cross(0,ROC(tx,1,$))
 
     FILTER
         Formula:
             colA OR colB


To recreate the system test in MetaStock, go to Tools and select System Tester. Click "New" and enter a name ("Trix system"). Under the corresponding tabs, enter the following formulas:
 

TRIX System
         Enter Long:
             tx:=TRIX(5);
             sig:=Mov(tx,3,E);
             Cross(tx,sig)
 
         Close Long:
             tx:=TRIX(5);
             Cross(0,ROC(tx,1,$))


Using the four conditions defined, it is also possible to create an expert advisor. Figure 3 shows a chart with such an expert attached.

FIGURE 3: METASTOCK. Here is the TRIX system plotted with the expert advisor.


To recreate this expert, in MetaStock, go to Tools and select Expert Advisor. Click "New" and enter a name ("Trix system"). Select the Symbols tab and click "New." Enter the name of the symbol. Then enter the formula. Click the Graphic tab and select the desire symbol, the color you would like it displayed in, and the text to be displayed. On this screen, you also specify the location of the symbol and the text in relation to the price bars. Here are the formulas and the selections used in the example expert:
 

Name: Gold Cross
Formula:
tx:=TRIX(5);
sig:=Mov(tx,3,E);
Cross(tx,sig)
Graphic: Buy Arrow
Size:  Medium
Color: Dk Yellow
Label: GC
Symbol position:  below price
Label position: below symbol
Name: Dead Cross
Formula:
tx:=TRIX(5);
sig:=Mov(tx,3,E);
Cross(sig,tx)
Graphic: Sell Arrow
Size:  Medium
Color: Dk Red
Label: DC
Symbol position:  above price
Label position: above symbol
Name: Bounce
Formula:
tx:=TRIX(5);
Cross(ROC(tx,1,$),0)
Graphic: Exit Sign
Size:  Medium
Color: Blue
Label: B
Symbol position:  above price
Label position: above symbol
Name: Fall
Formula:
tx:=TRIX(5);
Cross(0,ROC(tx,1,$))
Graphic: Exit Sign
Size:  Medium
Color: Dk Green
Label: F
Symbol position:  below price
Label position: below symbol


--William Golson
Equis International
www.equis.com


GO BACK


AMIBROKER: HOLDING OVERNIGHT POSITIONS

In "Holding Overnight Positions," Anthony Trongone presents a system for active traders looking for a way to trade in the overnight hours. Implementation of this trading system in AmiBroker involves calculating an eight-day simple moving average of volume, ranking volume changes, and combining ranks with price movement. The key part of this system: Determining volume ranks can be easily implemented using the built-in Percentile() function.

Listing 1 shows ready-to-use code that can be applied in the automatic analysis window (for backtesting and scanning). By changing the sys parameter, one can choose the combination of signals to be evaluated. The code can be run in either exploration or backtest modes. In the exploration mode, it produces a table similar to one found in the article.
 

LISTING 1
// compute 1-day rate of change of 8-day volume moving average
VMAC = ROC( MA( Volume, 8 ), 1 );
// Finding top 30% and bottom 30% ranks during last 130 bars
Top30V = Percentile( VMAC, 130, 70 ) ;
Bot30V = Percentile( VMAC, 130, 30 ) ;
// strong increase/decrease in volume
VolUp = VMAC >= Top30V;
VolDown = VMAC <= Bot30V;
// one-day rate of change bigger or lower than 1/-1 %
Rise = ROC( C, 1 ) > 1;
Fall = ROC( C, 1 ) < -1;
InRange = DateNum() > 1020101;
sys = Param("Sys", 2, 0, 3, 1 );
Buy = IIf( sys == 0, Rise AND VolUp,
ººººººIIf( sys == 1, Fall AND VolUp,
ººººººIIf( sys == 2, Rise AND VolDown,
ºººººººººººººººººººº Fall AND VolDown ) ) );
Buy = Buy AND InRange;
BuyPrice = Close;
Sell = Ref( Buy, -1 ); // sell next day
SellPrice = Open;
Diff = Sell * ( O-Ref(C,-1) );
Profit = 100 * Diff;
AddColumn( sys, "Comb.", 1.0 );
AddColumn( 100 * Cum( Diff )/Cum(Buy), "avg. gain (cents)", 1.4 );
AddColumn( Cum( Buy ), "# trades", 1.0 );
AddColumn( Cum( Diff > 0 ), "# positive", 1.0 );
AddColumn( Cum( Diff < 0 ), "# negative", 1.0 );
AddColumn( Max( 0, Cum( Profit ) ), "Profit long", 1.0 );
AddColumn( Max( 0, Cum( -Profit ) ), "Profit short", 1.0 );
Filter = BarIndex() == LastValue(BarIndex());
 A downloadable version of this code is available from Amibroker.com.
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
GO BACK


AMIBROKER: TRIX

In "Trading In Tempo With TRIX," Jongseon Kim discusses a technique based on the TRIX indicator that helps to identify good trading periods. Calculation of TRIX involves triple exponential smoothing of prices and then calculating the rate of change of a triple EMA.

This can be easily implemented using AmiBroker Formula Language. Listing 1 shows ready-to-use code that can be applied in Indicator Builder (for charts) and the automatic analysis window (for backtesting and scanning).
 

LISTING 1
function Trix2( array, period )
{
ºººtmp = EMA( EMA( EMA( array, period ), period ), period );
ºººresult = (tmp - Ref( tmp , -1 ))/Ref( tmp, -1 ) ;
ºººreturn result;
}
 
Trixline = Trix2( (O+C)/2, 5 );
TrixSignal = EMA( Trixline, 3 );
 
Plot( Trixline, "TRIX(5)", colorRed );
Plot( TrixSignal, "EMA(TRIX,3)", colorBlue );
 
GoldenCross = Cross( TrixLine, TrixSignal );
TrixFall = Trixline < Ref( Trixline, -1 ) AND Ref( Trixline, -1 ) > Ref( Trixline, -2 );
 
Buy = GoldenCross;
Sell = TrixFall;
Plot( Flip( Buy, Sell ), "Trade", colorPaleGreen, styleArea | styleOwnScale, 0, 1 );


 A downloadable version of this code is available from AmiBroker's website. A sample chart is in Figure 4.

FIGURE 4: AMIBROKER, TRIX. This AmiBroker chart demonstrates TRIX.
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com


GO BACK


eSIGNAL: HOLDING OVERNIGHT POSITIONS

This eSignal formula is based on "Holding Overnight Positions" by Anthony Trongone in this issue. A sample eSignal chart is shown in Figure 5.


FIGURE 5: eSIGNAL, RISING DARKNESS. This eSignal chart demonstrates the rising darkness indicator as described by Anthony Trongone in his article," Holding Overnight Positions."
/********************************************
Provided By : eSignal. (c) Copyright 2003
Indicator: Rising Darkness
Notes:
    Requires at least 50 bars of data and a daily chart interval.
    Bottom row of arrows are Price symbols.
    Top row of arrows are Volume symbols.
********************************************/
function preMain() {
    setStudyTitle("Rising Darkness ");
    setCursorLabelName("Vol \%Chg", 0);
    setCursorLabelName("Price \%Chg", 1);
    setDefaultBarThickness(5, 0);
    setDefaultBarThickness(3, 1);
    setDefaultBarFgColor(Color.navy, 0);
    setDefaultBarFgColor(Color.aqua, 1);
    setPlotType(PLOTTYPE_HISTOGRAM, 0);
    setPlotType(PLOTTYPE_HISTOGRAM, 1);
    addBand(0, PS_SOLID, 1, Color.black, "zero");
 
}
var aVolChg = new Array(50);
var aVol = new Array(8);
var vVol = null;    // Today's volume
var vAvg = null;    // Today's avg volume
var vAvg1 = null;   // Yesterday's avg volume
var vVolChg = null;
var bLabels = false;
var nImageCntr = 0;
function main() {
    if (getInterval() != "D") {
        drawTextAbsolute(-1, 10, "Formula requires Daily interval.",
            Color.red, Color.black, Text.BOLD|Text.RIGHT, null,
            12, "error");
        return;
    }
    // Remove the code block above to enable all intervals.
 
    if (bLabels == false) {
        drawTextAbsolute(2, 2, "-- Price Symbols", Color.black,
            null, Text.BOLD|Text.RELATIVETOBOTTOM, null,
            10, "price label");
        drawTextAbsolute(2, 14, "-- Volume Symbols", Color.black,
            null, Text.BOLD|Text.RELATIVETOBOTTOM, null,
            10, "volume label");
        bLabels = true;
    }
 
    var nState = getBarState();
    var vRank = null;
    var c = close();
    var c1 = close(-1);
    if (c1 == null) return;
    if (nState == BARSTATE_NEWBAR && vVol != null) {
        nImageCntr += 1;
        if (nImageCntr > 200) nImageCntr = 0;
        aVol.pop();
        aVol.unshift(vVol);
        vAvg1 = vAvg;
        if (vVolChg != null) {
            aVolChg.pop();
            aVolChg.unshift(vVolChg);
        }
    }
 
    vVol = volume();
    aVol[0] = vVol;
 
    if (aVol[7] == null) return;
 
    vAvg = calcMA();
 
    if (vAvg1 == null) return;
 
    vVolChg = (((vAvg - vAvg1) / vAvg1) * 100).toFixed(4) *1;
    aVolChg[0] = vVolChg;
 
    if (aVolChg[49] != null) {
        vRank = getRank(aVolChg);
    }
 
    var vPriceChg = (((c - c1) / c) * 100).toFixed(2) *1;
 
    // Draw Volume and Price Symbols
    var nVol = 0;   // 0 = no signal, 1 = positive, 2 = negative
    var nPrc = 0;
    if (vRank/50 >= 0.70) {
        nVol = 1;
    } else if (vRank/50 <= 0.30) {
        nVol = 2;
    }
    if (vPriceChg >= 1.00) {
        nPrc = 1;
    } else if (vPriceChg <= -1.00) {
        nPrc = 2;
    }
    if (nVol > 0 && nPrc > 0) {
        if (nVol == 1) {
            drawShapeRelative(0, 12, Shape.UPARROW, null,
                Color.green, Shape.RELATIVETOBOTTOM,
                "vol"+nImageCntr);
        } else if (nVol == 2) {
            drawShapeRelative(0, 12, Shape.DOWNARROW, null,
                Color.red, Shape.RELATIVETOBOTTOM,
                "vol"+nImageCntr);
        }
        if (nPrc == 1) {
            drawShapeRelative(0, 1, Shape.UPARROW, null,
                Color.green, Shape.RELATIVETOBOTTOM,
                "prc"+nImageCntr);
        } else if (nPrc == 2) {
            drawShapeRelative(0, 1, Shape.DOWNARROW, null,
                Color.red, Shape.RELATIVETOBOTTOM,
                "prc"+nImageCntr);
        }
    } else {
        removeShape("vol"+nImageCntr);
        removeShape("prc"+nImageCntr);
    }
    return new Array(vVolChg, vPriceChg);
}
/*** Functions ***/
function calcMA() {
    var dSum = 0.0;
    var i = 0;
    for(i = 0; i < 8; i++) {
        dSum += aVol[i];
    }
    return (dSum / 8);
}
function getRank(aRank) {
    var i = 0;
    var cntr = 0;
    for (i = 0; i < 50; ++i) {
        if (vVolChg >= aRank[i]) cntr += 1;
    }
    return cntr;
}
--eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignal.com
GO BACK


eSIGNAL: TRIX

This eSignal formula is based on "Trading In Tempo With TRIX" by Jongseon Kim in this issue. A sample eSignal chart is shown in Figures 6 and 7.

FIGURE 6: eSIGNAL, TRIX. This eSignal chart demonstrates the TRIX indicator, showing only long positions, similar to the daily chart example in Jongseon Kim's article. However, the eSignal formula includes the reverse logic for the short side.


FIGURE 7: eSIGNAL, TRIX. The sample chart includes the short positions as well. The user can enable/disable or change the entry and exit signals for the TRIX formula through the "Edit Studies" option in eSignal.

/*****************************************************
Provided By : eSignal. (c) Copyright 2003

Indicator: TRIX

Formula Parameters:               Defaults:
   TRIX Length                         5
   Signal Length                       3
   Long Entry Signal (GC, B, Disable)  GC
   Long Exit Signal (DC, F)            F
   Short Entry Signal (DC, F, Disable) DC
   Short Exit Signal (GC, B)           B

Notes:
   GC = Golden Cross
   DC = Dead Cross
   F = Fall
   B = Bounce
   *Requires Daily, Weekly or Monthly chart interval.
*****************************************************/

function preMain() {
   setStudyTitle("TRIX ");
   setCursorLabelName("TRIX", 0);
   setCursorLabelName("Signal", 1);
   setDefaultBarFgColor(Color.black, 0);
   setDefaultBarFgColor(Color.red, 1);
   setDefaultBarThickness(2, 0);
   setDefaultBarThickness(2, 1);

   var fp1 = new FunctionParameter("nLength",
       FunctionParameter.NUMBER);
   fp1.setName("TRIX Length");
   fp1.setLowerLimit(2);
   fp1.setDefault(5);

   var fp2 = new FunctionParameter("nSLength",
       FunctionParameter.NUMBER);
   fp2.setName("Signal Length");
   fp2.setLowerLimit(2);
   fp2.setDefault(3);

   var fp3 = new FunctionParameter("sLEntry",
       FunctionParameter.STRING);
   fp3.setName("Long Entry Signal");
   fp3.addOption("GC");
   fp3.addOption("B");
   fp3.addOption("Disable");
   fp3.setDefault("GC");

   var fp4 = new FunctionParameter("sLExit",
       FunctionParameter.STRING);
   fp4.setName("Long Exit Signal");
   fp4.addOption("DC");
   fp4.addOption("F");
   fp4.setDefault("F");

   var fp5 = new FunctionParameter("sSEntry",
       FunctionParameter.STRING);
   fp5.setName("Short Entry Signal");
   fp5.addOption("DC");
   fp5.addOption("F");
   fp5.addOption("Disable");
   fp5.setDefault("DC");

   var fp6 = new FunctionParameter("sSExit",
       FunctionParameter.STRING);
   fp6.setName("Short Exit Signal");
   fp6.addOption("GC");
   fp6.addOption("B");
   fp6.setDefault("B");
}

var bEdit = true;
var vMax = null;
var vMin = null;
var nCntr = 0;
var EMA1 = null;
var EMA2 = null;
var EMA3 = null;
var vTRIX = null;
var aTrix = null;
var vSignal = null;
var vSignal1 = null;
var dPercent = 0.0;
var bPrimed = false;
var vPosition = null;
var bEntry = false;
var nSpace = null;

function main(nLength, nSLength, sLEntry, sLExit, sSEntry, sSExit) {
   if (isDWM() == false) {
       drawTextAbsolute(-1, 10, "Formula requires Daily, Weekly or Monthly interval.",
           Color.red, Color.black,
           Text.BOLD|Text.RIGHT|Text.RELATIVETOBOTTOM, null, 12, "error");
       return;
   }

   var nState = getBarState();
   nSLength = Math.round(nSLength);

   if (bEdit == true || EMA1 == null) {
       aTrix = new Array(nSLength);
       nLength = Math.round(nLength);
       EMA1 = new MAStudy(nLength, 0, "Close", MAStudy.EXPONENTIAL);
       EMA2 = new MAStudy(nLength, 0, EMA1, MAStudy.MA, MAStudy.EXPONENTIAL);
       EMA3 = new MAStudy(nLength, 0, EMA2, MAStudy.MA, MAStudy.EXPONENTIAL);
       if (nSpace == null) {
           var vInt = getInterval();
           if (vInt == "D") nSpace = 0.001;
           if (vInt == "W") nSpace = 0.003;
           if (vInt == "M") nSpace = 0.02;
       }
       bEdit = false;
   }

   if (nState == BARSTATE_NEWBAR && vTRIX != null) {
       nCntr += 1;
       bEntry = false;
       aTrix.pop();           // remove last array element
       aTrix.unshift(vTRIX);  // insert new array element [0]
   }

   var vEMA3 = EMA3.getValue(MAStudy.MA);
   var vEMA3_1 = EMA3.getValue(MAStudy.MA, -1);
   if (vEMA3 == null || vEMA3_1 == null) return;

   vTRIX = (vEMA3 - vEMA3_1) / vEMA3_1;
   if (vTRIX == null) return;
   aTrix[0] = vTRIX;

   if (aTrix[nSLength-1] == null) return;

   vSignal = EMA(nSLength, aTrix);

   // draw signals
   var retData1 = ref(-1);  // retData1[0] = TRIX, retData1[1] = Signal
   var retData2 = ref(-2);  // retData2[0] = TRIX, retData2[1] = Signal
   if (retData1 != null && retData2 != null) {
       var vT_1 = retData1[0];
       var vS_1 = retData1[1];
       var vT_2 = retData2[0];
       var vS_2 = retData2[1];
       // Long
       if (bEntry == false && vPosition == null && sLEntry == "GC") {
           if (vTRIX > vSignal && vT_1 < vS_1) {  // GC - Golden Cross entry
               drawTextRelative(0, vSignal-.001, "Long", Color.lime, Color.black,
                   Text.BOLD|Text.ONTOP|Text.TOP, null, 11,
                   "GC_long"+nCntr);
               vPosition = "long";
               bEntry = true;
           } else {
               removeText("GC_long"+nCntr);
               vPosition = null;
           }
       } else if (bEntry == false && vPosition == null && sLEntry == "B") {
           if (vTRIX > vT_1 && vT_1 < vT_2) {  // B - Bounce entry
               drawTextRelative(0, vTRIX-.001, "Long", Color.lime, Color.black,
                   Text.BOLD|Text.ONTOP|Text.CENTER, null, 11,
                   "B_long"+nCntr);
               vPosition = "long";
               bEntry = true;
           } else {
               removeText("B_long"+nCntr);
               vPosition = null;
           }
       } else if (vPosition == "long" && sLExit == "DC") {
           if (vTRIX < vSignal && vT_1 > vS_1) {  // DC - Dead Cross exit
               vPosition = null;
           } else {
               removeText("DC_long"+nCntr);
               vPosition = "long";
           }
       } else if (vPosition == "long" && sLExit == "F") {
           if (vTRIX < vT_1 && vT_1 > vT_2) {  // F - Fall exit
               vPosition = null;
           } else {
               removeText("F_long"+nCntr);
               vPosition == "long";
           }
       }
       // Short
       if (bEntry == false && vPosition == null && sSEntry == "DC") {
           if (vTRIX < vSignal && vT_1 > vS_1) {  // DC - Dead Cross entry
               drawTextRelative(0, vSignal+.001, "Short", Color.red, Color.black,
                   Text.BOLD|Text.ONTOP|Text.BOTTOM, null, 11,
                   "DC_short"+nCntr);
               vPosition = "short";
               bEntry = true;
           } else {
               removeText("DC_short"+nCntr);
               vPosition = null;
           }
       } else if (bEntry == false && vPosition == null && sSEntry == "F") {
           if (vTRIX < vT_1 && vT_1 > vT_2) {  // F - Fall entry
               drawTextRelative(0, vTRIX+.001, "Short", Color.red, Color.black,
                   Text.BOLD|Text.ONTOP|Text.BOTTOM, null, 11,
                   "F_short"+nCntr);
               vPosition = "short";
               bEntry = true;
           } else {
               removeText("F_short"+nCntr);
               vPosition = null;
           }
       } else if (vPosition == "short" && sSExit == "GC") {
           if (vTRIX > vSignal && vT_1 < vS_1) {  // GC - Golden Cross exit
               vPosition = null;
           } else {
               removeText("GC_short"+nCntr);
               vPosition = "short";
           }
       } else if (vPosition == "short" && sSExit == "B") {
           if (vTRIX > vT_1 && vT_1 < vT_2) {  // B - Bounce exit
               vPosition = null;
           } else {
               removeText("B_short"+nCntr);
               vPosition == "short";
           }
       }
       if (vPosition == "long") setBarBgColor(Color.green);
       if (vPosition == "short") setBarBgColor(Color.maroon);
   }

   setMaxMin();

   return new Array(vTRIX.toFixed(4)*1, vSignal.toFixed(4)*1);
}

/**** Functions ****/

function setMaxMin() {
   if (vMax == null) {
       vMax = vTRIX + nSpace;
   } else {
       vMax = Math.max(vMax, vTRIX+nSpace);
   }
   if (vMin == null) {
       vMin = vTRIX - nSpace;
   } else {
       vMin = Math.min(vMin, vTRIX-nSpace);
   }

   setStudyMax(vMax);
   setStudyMin(vMin);
   return;
}

function EMA(nLength, nArray) {
   var nBarState = getBarState();
   var dSum = 0.0;
   var dRef;

   if(nBarState == BARSTATE_ALLBARS || bPrimed == false) {
       dPercent = (2.0 / (nLength + 1.0));
       bPrimed = false;
   }

   if (nBarState == BARSTATE_NEWBAR) {
       vSignal1 = vSignal;
   }

   if(bPrimed == false) {
       for(i = 0; i < nLength; i++) {
           dSum += nArray[i];
       }
       bPrimed = true;
       return (dSum / nLength);
   } else {
       return (((aTrix[0] - vSignal1) * dPercent) + vSignal1);
   }
}

 
--eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignal.com


GO BACK


AIQ EXPERT DESIGN STUDIO: HOLDING OVERNIGHT POSITIONS

Here is the AIQ TradingExpert code based on "Holding Overnight Positions" by Anthony Trongone in this issue.
 

!HOLDING OVERNIGHT POSITIONS based on article by Anthony Trongone
!Coded by Rich Denning 11/9/03
!Test of overnight hold using QQQ
!The tests will run faster if you create a list with just the QQQ in the list and
!  enter the list in the "properties" dialogue box
!To run this test on other stocks, remove the "and symbol()="QQQ"" from all of the lines and
!  use a list of stocks that are to be tested
!Tests of each of the four cases must be run using Portfolio Manager in simulation mode
!  and can not be run using the Expert Design Studio due to the every other day limitation
Define LB 1173.   !This is the full period available for the QQQs
Price  is [close].
Price1 is val([close],1).
Open1 is val([open],1).
Data is hasdatafor(LB).
VolAvg8  is simpleavg([volume],8).
V8Chg is (VolAvg8 - valresult(VolAvg8,1)) / valresult(VolAvg8,1) * 100.
PriceChg is (Price - Price1) / Price1 * 100.
Define  UCut 2.65.  !!!!Find by trial and error to make PctDaysI = 30. Use the data on the VRpt.
Define  LCut -2.2.    !!!!Find by trial and error to make PctDayD = 30. Use the data on the VRpt.
HiV8C  is highresult(V8Chg,Data).
LoV8C  is lowresult(V8Chg,Data).
CtV8Ci is countof(V8Chg > 0,Data).
CtV8Ci2 is countof(V8Chg > UCut,Data).
CtV8Cd is countof(V8Chg < 0,Data).
CtV8Cd2 is countof(V8Chg < LCut,Data).
PctDaysI is CtV8Ci2 / Data * 100.
PctDaysD is CtV8Cd2 / Data * 100.
Error1 is iff(PctDaysI >29 and PctDaysI <31, "NoErrors","Chg UCut").
Error2 is Iff(PctDaysD >29 and PctDaysD <31, "No Errors","Chg LCut").
VRrpt  if symbol()="QQQ".
Top30V if V8Chg > UCut.
Bot30V  if V8Chg < LCut.
IPDV if  PriceChg > 1 and V8Chg < LCut and symbol()="QQQ".
IPIV if  PriceChg > 1 and V8Chg > UCut and symbol()="QQQ".
DPIV if  PriceChg < -1 and V8Chg > UCut and symbol()="QQQ".
DPDV if  PriceChg < -1 and V8chg < Lcut and symbol()="QQQ".
NPNV if ((PriceChg <= 1 and PriceChg >= -1) or (V8Chg >=UCut and V8Chg <= LCut)) and symbol()="QQQ".
ONS is [open] - val([close],1).
ONchg is ONS / val([close],1) * 100.


 A sample chart is shown in Figure 8.

FIGURE 8: AIQ, RISING DARKNESS. Here is a sample AIQ chart demonstrating the rising darkness indicator.
--Mike Kaden
AIQ Systems
www.aiq.com


GO BACK


AIQ EXPERT DESIGN STUDIO: TRIX

Here is the AIQ TradingExpert code based on "Trading In Tempo With TRIX" by Jongseon Kim in this issue. A sample chart is shown in Figure 9.

FIGURE 9: AIQ, TRIX. Here is a sample AIQ chart demonstrating the TRIX indicator.
!!!  Stocks and Commodities January 2004 - article written by Jongseon Kim
ema1 is expavg([close], 5).
ema2 is expavg(ema1, 5).
ema3 is expavg(ema2, 5).
TRIX is (ema3 - valresult(ema3, 1)) / (valresult(ema3, 1)).
SignalTrix is expavg(trix, 3).
GoldenCross if valresult(trix, 1) < valresult(signaltrix, 1) and trix > signaltrix.
--Mike Kaden
AIQ Systems
www.aiq.com


GO BACK


WEALTH-LAB: HOLDING OVERNIGHT POSITIONS

We enjoyed taking the rising darkness system, described in this issue by Anthony Trongone in "Holding Overnight Positions," into our simulation lab. Making keen observations in a quick spreadsheet analysis provides just the guidance needed to form the specific trading system requirements. Once coded in Wealth-Lab Developer, the system can be taken to the next analytical level with graphical feedback and real-world simulation options such as trading costs and position sizing.

We implemented each of the four entry rules using BuyAtClose or ShortAtClose orders as suggested for best profitability. Positions are exited using a one-day time-based automatic exit at market open. We plotted the price and average volume percent change price series and colored the histogram green or red when the objectives were met. Our price data was provided by RealTick (Figure 10).

With a little coding trickery, we also show how the user can selectively choose an entry condition or combination of entries within the same simulation. Each type of entry is a mutually exclusive condition; therefore we assign a letter to each one. The program prompts the user for a string of letters, which can be any combination of a, b, c, and d corresponding to the rising darkness entry logic presented by the author.

We arbitrarily chose a 1,000-share size, though one could investigate the effects of sizing positions dynamically -- perhaps based on a "confidence" factor weighted by the amplitude of price change and/or volume contraction/expansion.

Since the first three entries are profitable individually over the testing period, we combined them in the simulation by entering the string "abc" as shown in Figure 10. Out of 100 round-trips, the system produced a win rate of 60% with a net profit of $6,680.01 after deducting $10 per trade in commissions. Before applying any system in the real world, however, we would encourage a broader testing period to gain more confidence.

FIGURE 10: WEALTH-LAB, HOLDING OVERNIGHT POSITIONS. Run a trading simulation with any combination of the rising darkness entry rules using the Wealth-Lab ChartScript.


WealthScript code
 

var Bar, ROCvPane, ROCpPane, j, cnt, Rule: integer;
var lstVolChg: TList;
{ Integer 'handles' for indicators }
var hVolChgPct, hPrcChgPct, h30VInc, h30VDec, hAvgVol: integer;
var StrIn, s: string;
StrIn := Input('Which entry rule(s)? e.g., abcd' );
for j := 1 to Length(StrIn) do
begin
  s := Copy(StrIn, j, 1 );
  case s of
    'a', 'A': Rule := Rule + 1;
    'b', 'B': Rule := Rule + 2;
    'c', 'C': Rule := Rule + 4;
    'd', 'D': Rule := Rule + 8;
  end;
end;
{ The Rate Of Change function creates a series with the percentage change }
hAvgVol := SMASeries( #Volume, 8 );
hVolChgPct := ROCSeries( hAvgVol, 1 );
hPrcChgPct := ROCSeries( #Close, 1 );
{ Plot the percentage changes }
ROCvPane := CreatePane( 75, true, true );
ROCpPane := CreatePane( 75, true, true );
PlotSeriesLabel( hVolChgPct, ROCvPane, 0, #ThickHist, 'Vol Chg Pct (avg)' );
PlotSeriesLabel( hPrcChgPct, ROCpPane, 0, #ThickHist, 'Pce Chg Pct' );
PlotSeriesLabel( hAvgVol, 1, #Blue, #Thick, '8-day avg volume' );
DrawLabel( 'Entry string: ' + Uppercase(StrIn), 0 );
{ Create an indicator series of the top 30% incr/decrease
  volume days; as of the current day }
lstVolChg := TList.Create;
h30VInc := CreateSeries;
h30VDec := CreateSeries;
for Bar := 8 to BarCount - 1 do
begin
  lstVolChg.Add( @hVolChgPct[ Bar ] );
  cnt := lstVolChg.Count;
  j := Trunc( cnt * 0.30 );
  if j > 0 then
  begin
    lstVolChg.SortNumeric;   // sorts from smallest to largest
    if @hVolChgPct[ Bar ] < lstVolChg.Item( j - 1 ) then
    begin
      @h30VDec[ Bar ] := 1;
      SetSeriesBarColor( Bar, hVolChgPct, #Red );
    end;
    if @hVolChgPct[ Bar ] > lstVolChg.Item( cnt - j ) then
    begin
      @h30VInc[ Bar ] := 1;
      SetSeriesBarColor( Bar, hVolChgPct, #Green );
    end;
  end;
  if @hPrcChgPct[ Bar ] > 1.0 then
    SetSeriesBarColor( Bar, hPrcChgPct, #Green )
  else if @hPrcChgPct[ Bar ] < -1.0 then
    SetSeriesBarColor( Bar, hPrcChgPct, #Red );
end;
InstallTimeBasedExit( 1 );
{ -------------------------------------- Main Trading loop }
for Bar := 8 to BarCount - 1 do
begin
  ApplyAutoStops( Bar );  { Automatic Exit }
  if Rule and 1 = 1 then // A: Rising Prices, Expanding Vol
    if @hPrcChgPct[ Bar ] > 1.0 then
      if @h30VInc[ Bar ] = 1 then
        ShortAtClose( Bar, 'A' );
  if Rule and 2 = 2 then // B: Rising Prices, Contracting Vol
    if @hPrcChgPct[ Bar ] > 1.0 then
      if @h30VDec[ Bar ] = 1 then
        BuyAtClose( Bar, 'B' );
  if Rule and 4 = 4 then // C: Falling Prices, Expanding Vol
    if @hPrcChgPct[ Bar ] < -1.0 then
      if @h30VInc[ Bar ] = 1 then
        BuyAtClose( Bar, 'C' );
  if Rule and 8 = 8 then // D: Falling Prices, Contracting Vol
    if @hPrcChgPct[ Bar ] < -1.0 then
      if @h30VDec[ Bar ] = 1 then
        BuyAtClose( Bar, 'D' );
end;
--Robert Sucher, Wealth-Lab, Inc.
www.wealth-lab.com


GO BACK


WEALTH-LAB: TRIX

You can recreate the TRIX indicator and system setup described by Jongseon Kim in "Trading In Tempo With TRIX" using our WealthScript language. The completed script can be run in Wealth-Lab Developer or on the free Wealth-Lab.com website. We created the script using a combination of drag and drop tools and manual script coding in Wealth-Lab Developer 3.0.

Wealth-Lab Developer 3.0 contains a wizard that allows you to create trading systems by dragging and dropping rules and conditions. New wizard rules and conditions can be created by the Wealth-Lab community and added to the wizard. Whenever new rules and conditions are available, you can add them to the wizard by selecting "Community/Download ChartScripts" from the Wealth-Lab Developer 3.0 menu. In Figure 11 we see that the Trix rules are now added to our wizard.

FIGURE 11: WEALTH-LAB, TRIX. New wizard rules for the TRIX indicator are downloaded and installed into Wealth-Lab Developer 3.0.


We can then create a simple trading system based on TRIX by dragging and dropping the TRIX rules using the ChartScript wizard (see Figure 12). This creates the complete code for the trading system, which can then be fine-tuned manually if desired.

FIGURE 12: WEALTH-LAB, TRIX. We use the TRIX rules to develop the trading system by drag and drop.


Although the ChartScript wizard already plots the TRIX indicator and its signal line, you can also easily add these indicators onto any chart. Simply drag the Trix indicator from the Indicator List onto the chart. The TRIX will be plotted in a new pane. To create the signal line, drag the EMA indicator and drop it on top of the already plotted TRIX.

With our skeleton code in place, we refined the code to annotate the chart whenever one of the four TRIX patterns described in the article appears. We also colored the background of the chart to reflect the "rest" periods described by the author (see Figure 13).

FIGURE 13: WEALTH-LAB, TRIX. The completed script annotates the chart to point out the four TRIX patterns and the rest periods.
const Period = 3;
const Smooth = 3;
var Bar, TrixPane, Trx, Signal: integer;
var Rest: boolean;
{ These custom functions identify the Trix Patterns }
function GC: boolean;
begin
  Result := CrossOver( Bar, Trx, Signal );
end;
function DC: boolean;
begin
  Result := CrossUnder( Bar, Trx, Signal );
end;
function B: boolean;
begin
  Result := TurnUp( Bar, Trx );
end;
function F: boolean;
begin
  Result := TurnDown( Bar, Trx );
end;
{ Plot the Trix and Signal Line on the Chart }
EnableTradeNotes( false, false, true );
UseUpdatedEMA( true );
TrixPane := CreatePane( 75, true, true );
Trx := TRIXSeries( #Close, 3 );
PlotSeriesLabel( Trx, TrixPane, 538, #Thick, 'Trix(#Close,3)' );
Signal := EMASeries( Trx, 3 );
PlotSeriesLabel( Signal, TrixPane, 000, #Thin, 'EMA(Trix,3)' );
Rest := false;
for Bar := 15 to BarCount - 1 do
begin
{ Annotate Bounces and Falls }
  if B then
  begin
    AnnotateBar( 'B', Bar, true, #Black, 8 );
    SetBarColor( Bar, 595 );
  end
  else if F then
  begin
    AnnotateBar( 'F', Bar, true, #Black, 8 );
    SetBarColor( Bar, 955 );
  end;
{ Annotate Golden Crosses and Trix Falls }
  if GC then
  begin
    AnnotateBar( 'GC', Bar, false, #Black, 8 );
    SetBarColor( Bar, #Green );
  end
  else if DC then
  begin
    AnnotateBar( 'DC', Bar, false, #Black, 8 );
    SetBarColor( Bar, #Red );
  end;
{ Display Rest Periods }
  if Rest then
  begin
    if GC then
      Rest := false;
  end
  else if F then
    Rest := true;
  if Rest then
    if Bar < BarCount - 1 then
      SetPaneBackgroundColor( Bar + 1, 0, 987 );
{ Implement Trading System Rules }
  if MarketPosition = 0 then
  begin
    if GC then
      BuyAtMarket( Bar + 1, '' );
  end
  else
  begin
    if F then
      SellAtMarket( Bar + 1, LastPosition, '' );
  end;
end;
--Dion Kurczek, Wealth-Lab, Inc.
www.wealth-lab.com


GO BACK


NEUROSHELL TRADER: HOLDING OVERNIGHT POSITIONS

Overnight systems, in which positions are entered after the 4:00 pm close and are closed at the next day's open, can be easily implemented in NeuroShell Day Trader. To create the overnight systems described in Anthony Trongone's "Holding Overnight Positions" article, create a 30-minute after-hours QQQ chart and the following trading strategies.

To create a trading strategy, select "New Trading Strategy ..." from the Insert menu and enter the appropriate long and short entry conditions:
 

Rising Prices, Expanding Volume System
  Generate a sell short MARKET order if ONE of the following are true:
        Time=X( Date, 4:00:00 PM )
        A>B ( %Change( IfThenElse(Time=X(Date,4:00:00 PM,Close,*), 1 ), 1 )
        A>B ( Percent Above( IfThenElse(Time=X(Date,4:00:00 PM,Volume,*) ), 70 )
  Generate a cover short MARKET order if ONE of the following are true:
         Time=X( Date, 9:30:00 AM )
Rising Prices, Contracting Volume System
  Generate a buy long MARKET order if ONE of the following are true:
        Time=X( Date, 4:00:00 PM )
        A>B ( %Change( IfThenElse(Time=X(Date,4:00:00PM,Close,*), 1 ), 1 )
        A<B ( Percent Above( IfThenElse(Time=X(Date,4:00:00PM,Volume,*) ), 30 )
  Generate a sell long MARKET order if ONE of the following are true:
         Time=X( Date, 9:30:00 AM )
Falling Prices, Expanding Volume System
  Generate a buy long MARKET order if ONE of the following are true:
        Time=X( Date, 4:00:00 PM )
        A<B ( %Change( IfThenElse(Time=X(Date,4:00:00PM,Close,*), 1 ), -1 )
        A>B ( Percent Above( IfThenElse(Time=X(Date,4:00:00PM,Volume,*) ), 70 )
  Generate a sell long MARKET order if ONE of the following are true:
         Time=X( Date, 9:30:00 AM )
Falling Prices, Contracting Volume System
  Generate a sell short MARKET order if ONE of the following are true:
        Time=X( Date, 4:00:00 PM )
        A<B ( %Change( IfThenElse(Time=X(Date,4:00:00PM,Close,*), 1 ), -1 )
        A<B ( Percent Above( IfThenElse(Time=X(Date,4:00:00PM,Volume,*) ), 30 )
  Generate a cover short MARKET order if ONE of the following are true:
         Time=X( Date, 9:30:00 AM )


Note that the percent above indicator is a custom indicator that simply determines the percentage of previous bar values that are greater than the current bar's value. Unlike the volume ranking described in the article, the percent above indicator analyzes volume ranks based on previous bars only, so that a system is more realistic of actual trading in which you don't know the value of future bars.

After backtesting the trading strategies, use the "Detailed Analysis ..." button to view the backtest and trade-by-trade statistics for the overnight system.

Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download a sample chart that includes the percent above indicator and the overnight trading systems chart (Figure 14).

FIGURE 14: NEUROSHELL TRADER, OVERNIGHT SYSTEM. Here's a sample NeuroShell Trader chart demonstrating the percent above indicator and the overnight trading system.
--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com


GO BACK


NEUROSHELL TRADER: TRIX

In his article "Trading In Tempo With TRIX," Jongseon Kim provides us with a method of trading using several indicators called TRIX and the TRIX signal. The Trix indicator can easily be created in NeuroShell Trader by combining a few simple indicators from the library of more than 800 indicators.

Once you've created the TRIX indicator, you can apply an exponential moving average to create the TRIX signal (Figure 15). We've created these indicators as custom indicators that you may download from the NeuroShell Trader free technical support website.

FIGURE 15: NEUROSHELL TRADER, TRIX. A NeuroShell Trader chart that graphically displays the TRIX indicators and trading strategy that Kim describes.


To insert the TRIX indicators (after downloading them):

1. Select "New Indicator ..." from the Insert menu.
2. Select the Custom Indicators category and select Next button.
3. Select the TRIX and TRIX Signal indicators and select Next button.
4. Select any of the parameters that you wish to modify.
5. Press the Set Parameter button and set the parameter to the desired value.
6. Select the Finished button.


To create the Trading Strategy that Kim describes:

 1. Select "New Trading Strategy ..." from the Insert menu.
 2. Select the No Template and select Next button.
 3. On the Long Entry tab, select the Add Condition(s) button.
a. Select the Indicator button.
b. Select the Crossover & Breakout Identification category and select Next button.
c. Select the Crossover Above indicator and select then Next button.
d. Set the parameters to create the indicator: CrossoverAbove(TRIX, TRIX Signal).
e. Select the Finished button.
4. On the Long Exit tab, select the Add Condition(s) button.
a.  Select the Indicator button.
b.  Select the Relational category and select Next button.
c.  Select the A<B indicator and select then Next button.
d.  Set the parameters to create the indicator: A<B(Momentum(TRIX,1), 0).
e.  Select the Finished button.
5. Select the Next button.
6. After backtesting and reviewing the results, select the Finished button to view the Trading Strategy on your chart.


You can easily insert either of these indicators or combine them with any of our 800 built-in indicators into a chart, prediction, or trading strategy. In addition, if you decide to use these indicators in a prediction or a trading strategy, the coefficients may be optimized by the Genetic Algorithm built into NeuroShell Trader Professional and NeuroShell DayTrader Professional.

Users of NeuroShell Trader may go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download a copy of any Traders' Tips.

For more information on NeuroShell Trader, visit www.NeuroShell.com.

--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com


GO BACK


PROPHET.NET: TRIX

The TRIX indicator described by Jongseon Kim this month is available on the Prophet.Net website to all premium members. No coding is required on the part of the user.

The TRIX indicator is available in the advanced studies suite in JavaCharts, found here:
 

  Prophet.Net : Analyze : JavaCharts
  https://www.prophet.net/analyze/javacharts.jsp


Click on the Tools menu (which you can also access by right-clicking anywhere on a chart) and choose Apply Studies from the Studies menu item.

There are two TRIX indicators available in JavaCharts. The one labeled "Trix (2 lines)" is especially useful, since it displays an up arrow for the golden cross (GC) event and a red down arrow for the fall (F) event. As the article states, the periods between a fall and the next golden cross are rest periods.

Within the Technical Studies dialog box, you can set the bar period for the indicator; the figure you enter will be shown parenthetically with the indicator itself (Figure 16).

FIGURE 16: PROPHET.NET, TRIX. This chart of the Nasdaq 100 shows eight tradable instances (the periods between the golden cross and the fall).


For example, the chart of the Nasdaq 100 shown in Figure 16 shows eight tradable instances (the periods between the golden cross and the fall).

By using the zoom feature (simply drag across the time frame you wish to view), coupled with the data line (showing  the date, open, high, low, close, and volume wherever the cursor is pointing), you can pinpoint specific entry and exit points.

Premium memberships at Prophet.Net start at $14.95 per month; real-time market data is available for equities, options, and futures. A seven-day, risk-free trial is available by following this link; this will provide immediate access to the Trix study: https://www.prophet.net/tasc.

--Prophet.net


GO BACK


NEOTICKER: HOLDING OVERNIGHT POSITIONS

To implement in NeoTicker the concept presented in "Holding Overnight Positions" by Jongseon Kim, first create an indicator called ntrix with two integer parameters, period and signal line. This indicator returns two plots with TRIX as the first plot and signal line as the second plot (Listing 1). Then create the testing system call trix_cross with the same set of parameters, with a single plot showing the current equity of the system (Listing 2).
 

LISTING 1
xema3 := qc_xaverage(qc_xaverage(qc_xaverage(data1,param1),param1),param1);
plot1 := ROC(xema3,1);
plot2 := average(plot1, param2);
LISTING 2
trix_main := ntrix.Plot1(data1,param1,param2);
trix_signal := ntrix.Plot2(data1,param1,param2);
goldenx := xabove(trix_main, trix_signal);
trix_fall := trix_main(1) > trix_main;
LongAtMarket(goldenx, 1);
LongExitAtMarket(trix_fall, 1);
plot1 := CurrentEquity;


The ntrix indicator will plot the TRIX and the signal line in a new pane (Figure 18). If you are interested in system testing results, you can apply the trix_cross system to the yearly, monthly, or daily Nasdaq composite data. Then use the NeoTicker built-in performance viewer to see the detailed results.

FIGURE 17: PROPHET.NET, TRIX. Within the Technical Studies dialog box, you can set the bar period for the indicator; the figure you enter will be shown parenthetically with the indicator itself.


A downloadable version of this indicator is available from the Yahoo! NeoTicker user group file area at https://groups.yahoo.com/group/neoticker/.

--Kenneth Yuen, TickQuest Inc.
www.tickquest.com


GO BACK


TRADINGSOLUTIONS: TRIX

In his article "Trading In Tempo With TRIX," Jongseon Kim presents a trading system based on the TRIX indicator.

FIGURE 18: NEOTICKER, TRIX. The ntrix indicator will plot the TRIX and the signal line in a new pane.


This system is very similar to the TRIX system included with TradingSolutions. Both systems enter on a TRIX golden cross. However, the system presented by Jongseon Kim exits on a Trix fall and does not enter short.

The system can be entered as follows:
 

Name: TRIX System (Exit On Fall)
Inputs: Data, TRIX Period, Signal Period
Enter Long:
CrossAbove (TRIX (Data, TRIX Period), EMA (TRIX (Data, TRIX Period), Signal Period))
Exit Long:
Desc (TRIX (Data, TRIX Period))


 This system is available in a function file that can be downloaded from the TradingSolutions website in the Solution Library section. A sample chart is in Figure 19.

FIGURE 19: TRADINGSOLUTIONS, TRIX. Here's a sample chart displaying the TRIX system along with the TRIX and TRIX signal line.
--Gary Geniesse, NeuroDimension, Inc.
800 634-3327, 352 377-5144
www.tradingsolutions.com
GO BACK


INVESTOR/RT: TRIX

The system discussed in "Trading In Tempo With TRIX" by Jongseon Kim is easy to implement in Investor/RT. The four signals can be implemented as Investor/RT signals using the following syntax:
 

TRIX Golden Cross (GC):
TRIX > CI AND TRIX.1 <= CI.1
(Note: CI is the Custom Indicator token representing a custom indicator with syntax "MA(TRIX)")
TRIX Dead Cross (DC):
TRIX < CI AND TRIX.1 <= CI.1
TRIX Bounce (B):
TRIX > TRIX.1 AND TRIX.1 <= TRIX.2
TRIX Fall (F):
TRIX < TRIX.1 AND TRIX.1 >= TRIX.2


The golden cross and the fall signals can be used in buy and sell rules respectively to create a trading system in Investor/RT. This trading system can be seen historically using the new trading system indicator in Figure 20.

FIGURE 20: INVESTOR/RT, TRIX. This Investor/RT monthly chart shows the Nasdaq ($COMPQ) plotted as a connected line of closing prices.  In the upper pane, the trading system indicator is plotted, showing green markers for the TRIX golden cross entries, and red markers for the TRIX fall exits.  The golden/red band represents the profit band of each trade. The lower pane shows the TRIX as a histogram, overlaid with a line representing the smoothed TRIX.


The system calls for a long entry when the five-period TRIX crosses above its moving average, and an exit when TRIX swings downward (falls). This system tested very favorably on monthly data for Nasdaq. However, it tested very poorly on smaller periodicities, such as one-minute and five-minute data. Even after optimizing the system, ranging the TRIX period from 3 to 8 (step 1), the smoothing period from 2 to 5 (step 1), and the periodicity from one- to five-minute (step 1), the optimal combination of these parameters showed an overall loss.

You can access additional information on the Investor/RT features of optimization, trading systems/backtesting, and Trix by visiting the following pages:

https://www.linnsoft.com/tour/optimization.htm
https://www.linnsoft.com/tour/techind/tsysi.htm
https://www.linnsoft.com/tour/tradingSystems.htm
https://www.linnsoft.com/tour/techind/trix.htm
 

--Chad Payne, Linn Software
800-546-6842, info@linnsoft.com
www.linnsoft.com
GO BACK


SMARTRADER: TRIX

Creating the TRIX indicator described in Jongseon Kim's article requires four rows in our specsheet (Figure 21).

FIGURE 21: SMARTRADER, TRIX. Here is the SmarTrader specsheet for the TRIX indicator.


Row 9 is an exponential moving average, EMA1, of the Close price. Row 10, EMA2, is an EMA (exponential moving average) of Ema1. Row 11, EMA3, is an EMA of EMA2. We then create a user formula in row 12, TRIX, using the formula as it appears in the article.

Row 13, Signal, is a three-period EMA of TRIX. The crossing of TRIX above Signal is a simple buy signal. The reverse is a simple sell signal.

For the purpose of demonstrating the trades generated by the TRIX golden cross (GC) and TRIX bounce (B), we added row 14, buy, which is a conditional user row. If TRIX is above (greater than) Signal, we have the GC, a buy signal. In row 14, sell, if TRIX is below (less than) Signal, we have the B, a sell signal.

The remaining rows track the trades generated by TRIX. Short trades are omitted in this example. The bottom window shows the gain in equity for closed-out positions. On the bar chart, red arrows indicate buy, and black arrows indicate sell.

A sample chart is in Figure 22.

FIGURE 22: SMARTRADER, TRIX. Here's a SmarTrader specsheet for calculating the TRIX indicator as described by Jongseon Kim in this issue.
--Jim Ritter, Stratagem Software
504 885-7353, Stratagem1@aol.com
GO BACK


TechniFilter Plus: Trading in Tempo

Here are formulas for TechniFilter Plus based on Jongseon Kim's article "Trading In Tempo." The TRIX indicator is included with TechniFilter Plus as a standard formula.

The TechniFilter formulas given here can be used to add the indicators to any chart, or they can be used in Filter Reports to scan through the market for signals, or in the Strategy Tester to backtest the signals.
 

NAME: Trix
SWITCHES: multiline
PARAMETERS: 5,3
FORMULA: [1]: ((CU9)X&1X&1X&1-TY1)*10000 {c}{Ntrix}{a} {nc} {Trix}
[2]: [1]X&2 {c} {NSig}          {Trix Signal}
NAME: Trix_crs_Signal
SWITCHES: multiline
PARAMETERS: 5,3
FORMULA: [1]: ((CU9)X&1X&1X&1-TY1)*10000
[2]: [1]X&2
[3]: ([1]-[2])U2-Ty1       {Returns 1 for a golden cross or -1 for a dead cross}
NAME: Trix_Reversal
SWITCHES: multiline
PARAMETERS: 5,3
FORMULA: [1]: ((CU9)X&1X&1X&1-TY1)*10000
[2]: ([1]>TY1)-TY1        {Returns 1 for a Bounce or -1 for a Fall}


The following is a TechniFilter trading strategy test as discussed in "Trading In Tempo" by Jongseon Kim.
 

NAME: TradingInTempo
TEST TYPE: equal
DATE RANGE: 01/02/95
POSITION LIMIT: none
ENTRY FEE: 0
EXIT FEE: 0
ISSUES: ndcnz
INITIAL INVESTMENT: 10000
FORMULAS----------------------------------
  [1] Date
  [2] Trix_crs(5,3)
       [1]: ((CU9)X&1X&1X&1-TY1)*10000 {c}{Ntrix}{a} {nc} {rgb#0}
       [2]: [1]X&2 {c} {NSig}  {rgb#255}
       [3]: ([1]-[2])U2-Ty1
  [3] Trix_Reversal(5,3)
       [1]: ((CU9)X&1X&1X&1-TY1)*10000
       [2]: ([1]>TY1)-TY1
RULES----------------------------------
  r1: BuyLong
       buy long all on Close
       at signal: Buy     [2] = 1 & Shares=0
 r2: StopLong
       sell long all on Close
       at signal: Stop     [3] = -1


The TRIX chart in Figure 23 includes the various signals discussed in the article.

FIGURE 23: TECHNIFILTER PLUS, TRIX. Bars are colored red when the TRIX reverses direction upward (bounce) or blue when it reverses direction downward (fall). The red arrow indicates the golden cross, when TRIX breaks up through the signal line. A blue arrow indicates the dead cross , when the TRIX falls through the signal line.
Visit the new home of TechniFilter Plus at www.technifilter.com to download these formulas and get the latest TechniFilter news.
--Benzie Pikoos, Brightspark
Tel +61 8 9375-1178, sales@technifilter.com
www.technifilter.com


GO BACK


STOCKWIZ: TRIX

Here are StockWiz formulas based on "Trading In Tempo With TRIX" by Jongseon Kim in this issue. A sample chart is in Figure 24.

FIGURE 24: STOCKWIZ, TRIX. This StockWiz chart displays the five-day TRIX indicator with its three-day signal line (dashed).
FORMULA:
--------------------------------------------------
# STOCKWIZ: WHEN AND WHEN NOT TO TRADE
# This StockWiz formula generates a graph with prices and the
# TRIX indicator with its Signal line, as described in this issue's
# article "When And When Not To Trade" by Jongseon Kim.
     (GCLEAR)
     (SOURCE "WORKSHEET")
#-------------- User Modifiable Variables ------------------
     (SET ma_days 20)     # Length of the Simple and Exponential MA's of price
     (SET trix_days 5)    # Length of the EMA's in the TRIX indicator
     (SET signal_days 3)  # Length of the Signal line of the TRIX indicator
#-------------------- Setup the Graph --------------------
     (SET indicator "TRIX and Signal line [dashed]")
     (ADJUST "ADJUST_FOR_SPLITS_AND_INTERPOLATE")
     (GOTO %SKIP (GSPLIT))
     (ADJUST "RAW_DATA")
     %SKIP: (NA)
     (SET DAYS (GDAYS))
     (SUBSETS 9)
     (SET name (GETSTRING "NAME"))
     (SET ttl name)
     (SAPPEND ttl " [")
     (SAPPEND ttl (CURRENT))
     (SAPPEND ttl "] - ")
     (SET lastCLOSE (LAST (GETVECTOR (CURRENT) "CLOSE")))
     (SAPPEND ttl (DOUBL2STR lastCLOSE "%.03f"))
     (TITLE ttl)
     (SET subttl "Bar Graph with ")
     (SAPPEND subttl (DOUBL2STR ma_days "%.0lf"))
     (SAPPEND subttl " day SMA [red] and EMA [blue] & ")
     (SAPPEND subttl (DOUBL2STR trix_days "%.0lf"))
     (SAPPEND subttl " day TRIX with ")
     (SAPPEND subttl (DOUBL2STR signal_days "%.0lf"))
     (SAPPEND subttl " day  Signal line [dashed]")
     (SUBTITLE subttl)
#-------------- Built the Vectors and the Graph --------------
     (SET OPEN   (GETVECTOR (CURRENT) "OPEN"))
     (SET HIGH   (GETVECTOR (CURRENT) "HIGH"))
     (SET LOW    (GETVECTOR (CURRENT) "LOW"))
     (SET CLOSE  (GETVECTOR (CURRENT) "CLOSE"))
     (SET SMA (MOVAVG CLOSE ma_days))
     (SET EMA (EMOVAVG CLOSE ma_days))
     (SET ZERO (VSMUL CLOSE 0))
     (SET EMA1 (EMOVAVG CLOSE trix_days))
     (SET EMA2 (EMOVAVG EMA1 trix_days))
     (SET EMA3 (EMOVAVG EMA2 trix_days))
     (SET TRIX (VPERCENT EMA3))
     (SET SIGNAL (EMOVAVG TRIX signal_days))
     (GRAPHSET 1 4 2 0.40 "LHOC")
     (GRAPHSET 2 1 2 0.60 "Line")
     (LABEL 1 "Price and MA's")
     (LABEL 2 indicator)
     (GRAPHADD 1 "GREEN" "THINSOLID" (VLAST LOW DAYS))
     (GRAPHADD 2 "GREEN" "THINSOLID" (VLAST HIGH DAYS))
     (GRAPHADD 3 "GREEN" "THINSOLID" (VLAST OPEN DAYS))
     (GRAPHADD 4 "GREEN" "THINSOLID" (VLAST CLOSE DAYS))
     (GRAPHADD 5 "RED"   "THINSOLID" (VLAST SMA DAYS))
     (GRAPHADD 6 "BLUE"  "THINSOLID" (VLAST EMA DAYS))
     (GRAPHADD 7 "PURPLE" "MEDIUMSOLID" (VLAST TRIX DAYS))
     (GRAPHADD 8 "GRAY"  "DASH" (VLAST SIGNAL DAYS))
     (GRAPHADD 9 "BLACK" "THINSOLID" (VLAST ZERO DAYS))
     (SHOW)


--StockWiz
 

GO BACK


FINANCIAL DATA CALCULATOR: HOLDING OVERNIGHT POSITIONS

In "Holding Overnight Positions" by Anthony Trongone, four trading conditions were specified as combinations of price and volume. We will call them (in the order in which they appeared in the article) uppdownv, uppupv, downpupv, and downpdownv. They use the macros upp, downp, upv, and downv. These are defined as follows:

For upp, open the macro wizard, choose "New macro," and enter the following code into the definition window:
 

c: close #r
((change c)/(c back 1))>.01
Save this macro as "upp."  Similarly, the code for the macro downp is:
c: close #r
((change c)/(c back 1))<-.01
The code for the macro upv is:
v: vol #r
a: 8 movave v
pct: (change a)/(a back 1)
pct >= 70 cumquantile pct
The code for the macro downv is:
v: vol #r
a: 8 movave v
pct: (change a)/(a back 1)
pct <= 30 cumquantile pct
Now we can define the main conditions. For uppdownv:
(upp #r) and (downv #r)
For uppupv:
(upp #r) and (upv #r)
For downpupv:
(downp #r) and (upv #r)
For downpdownv:
(downp #r) and (downv #r)
GO BACK


FINANCIAL DATA CALCULATOR: TRIX

The article "Trading In Tempo With TRIX" by Jongseon Kim introduces TRIX and four signals: TRIX golden cross (gcross),  TRIX dead cross (dcross),  TRIX bounce (bounce),  and TRIX fall (fall). To program these in FDC, do the following:

For "Trix," open the macro wizard, choose "New macro," and enter the following code into the definition window:

c: cl #R
bars: #L
ema1: bars expave  c
ema2: bars expave  ema1
ema3: bars expave  ema2
(change ema3)/ema3 back 1


Save this macro under the name "trix." It allows inputs for the number of bars and the target dataset.  For example, if you entered the line "3 Trix Ibm" in the FDC command window, the output would be the three-bar TRIX for the dataset IBM.
 

For "gcross," open the macro wizard, choose "New macro," and
 enter the following code into the definition window:
(#L expave trix  #R) crossup  #L trix #R
Then save as "gcross."
For "dcross," open the macro wizard, choose "New macro," and
 enter the following code into the definition window:
 (#L expave trix  #R) crossdn #L trix #R
Then save as "dcross."
For "bounce", open the macro wizard, choose new macro, and
 enter the following code into the definition window:
(change  #L trix  #R) crossup 0
Then save as "bounce."
For "fall," open the macro wizard, choose "New macro," and
 enter the following code into the definition window:
(change  #L trix  #R) crossup 0
Then save as "fall."
--Robert C. Busby
Futures Software Associates, 856 857-9088
www.financialdatacalculator.com


GO BACK


All rights reserved. © Copyright 2003, Technical Analysis, Inc.


Return to January 2004 Contents