May 2007
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: Trongone moving average (TMA) system
METASTOCK: Trongone moving average (TMA) system
eSIGNAL: Trongone moving average (TMA) system
WEALTH-LAB: Trongone moving average (TMA) system
AMIBROKER: Trongone moving average (TMA) system
NEUROSHELL TRADER: Trongone moving average (TMA) system
AIQ: Trongone moving average (TMA) system
STRATASEARCH: Trongone moving average (TMA) system
TRADECISION: Trongone moving average (TMA) system
TRADE NAVIGATOR: Trongone moving average (TMA) system

or return to May 2007 Contents


Editor's note: This month's Traders' Tips are based on Anthony Trongone's article in this issue, "Moving Averages: Long On Talk, Short On Action."

Readers will find our Traders' Tips section in its entirety at the STOCKS & COMMODITIES website at www.Traders.com in the Traders' Tips area, from where the code can be copied and pasted into the appropriate program. In addition, the code for each program is usually available at the respective software company's website. Thus, no retyping of code is required for Internet users.

For subscribers, any other code found in the articles in this magazine is available from the Subscriber Area at www.Traders.com. Login is required.


TRADESTATION: Trongone moving average (TMA) system

Anthony Trongone's article in this issue, "Moving Averages: Long On Talk, Short On Action," outlines a moving average-based strategy that uses a volume-based filter.

Trades are taken at the day's open if all trade conditions are met, and are always closed at the same day's end. For a trade to occur, the current day's opening price must be above the 34-day average of closing prices; volume for the previous day must be over one million shares; and the previous day's close must be higher than the current day's open. The following code translates this strategy into EasyLanguage. To download the code for the Trongone moving average (TMA) system, go to the Support Center at TradeStation.com and search for the file "Tma.Eld." TradeStation does not endorse or recommend any particular strategy.

FIGURE 1: TRADESTATION, TRONGONE MOVING AVERAGE STRATEGY. The blue line is the 34-day simple moving average. The subgraph shows daily volume.
Strategy:  TMA

inputs:
    AvgLength( 34 ),
    VolumeThreshold( 100000000 ),
    Quantity( 1000 ) ;

variables:
    Avg( 0 ) ;

if BarType <> 2 then
    RaiseRuntimeError( "Invalid bar interval.  Apply
" +
      "to daily bars only." ) ;

Avg = Average( Close, AvgLength ) ;

if Open next bar > Avg
    and Volume > VolumeThreshold
    and Open next bar < Close
then
    Buy Quantity shares next bar market ;

SetExitOnClose ;
--Mark Mills
TradeStation Securities, Inc.
www.TradeStation.com
GO BACK

METASTOCK: Trongone moving average (TMA) system

Anthony Trongone's article in this issue, "Moving Averages: Long On Talk, Short On Action," presents a trading system with no overnight positions. It is possible to replicate this test in MetaStock, but it requires a slightly unusual setup, as follows:
 

1. Select Tools > the Enhanced System Tester.
2. Click New.
3. Enter a name, "Tma System"
4. Select the Buy Order tab and enter the following formula:

V>10000 AND
Ref(O,1)>Mov(C,34,s) AND
(C-Ref(O,1))<0;

5. Set the Order Type to "Stop Limit."
6. Select the Limit or Stop Price and enter the following formula:

Ref(O,1)

7. On the Strategic Delay (Bars) line, set Day to 1.
8. Select the Sell Order tab and enter the following formula:

1

9. Set the Order Type to "Stop Limit."
10. Select the Limit or Stop Price and enter the following formula:

C

11. Click OK to close the system editor.

Then, when running a trading simulation, you must also make one additional
setting change:

1. On the third screen (System Testing Options), click the More button in
the lower right corner. This brings up a new window.
2. Click the Trade Execution tab.
3. Make sure Realistic Market Prices is not checked.
4. Set the Delay Order Opening value to zero.
5. Click OK to close the window.
6. Continue setting up the simulation as you wish.


Once you have made this setting change, it will remain until you change it to something else.

--William Golson
MetaStock Support Representative
Equis International (A Reuters Company)
801 265-9998, www.metastock.com


GO BACK


eSIGNAL: Trongone moving average (TMA) system

For this month's Traders' Tips formula based on Anthony Trongone's article, "Moving Averages: Long On Talk, Short On Action," we've provided the eSignal formula "TrongoneMA.efs."

There are three formula parameters that may be configured through the Edit Studies option in the Advanced Chart to change the SMA periods (default: 34), Volume Trigger (default: 100,000,000) and Lot Size (default: 1000). The Lot Size parameter only applies to backtesting results. The formula is configured for backtesting and real-time analysis for daily or intraday intervals. The strategy logic is intended for QQQQ only and is also a long-only strategy as described in the article. To match the intended results on intraday intervals as described by Trongone, the time template settings of the Advanced Chart must have start and end times of 9:30-16:00 ET.

This eSignal formula highlights the entry bars on the eSignal chart, with a blue arrow and a light gray background color for bars where a long position is held. On intraday intervals, the exit bar will also display a red diamond. See Figure 2.

FIGURE 2: eSIGNAL, TRONGONE MOVING AVERAGE SYSTEM. The chart highlights the entry bars. A blue arrow and a light gray background show the bars where a long position is held. On intraday intervals, the exit bar will also display a red diamond.
/***************************************
Provided By : eSignal (c) Copyright 2007
Description:  Moving Averages: Long On Talk, Short On Action
             
by Anthony Trongone, PhD

Version 1.0  3/08/2007

Notes:
* May 2007 Issue of Stocks & Commodities Magazine
* Study requires version 8.0 or later.
* This system is designed for QQQQ only.
* This system is a long only system.
* This study is designed for real time analysis and back testing.
* Intra-day time template should be set to 09:30-16:00 ET
Formula Parameters:                
Default:
SMA Periods                            
34
Volume Trigger                         
100,000,000
*****************************************************************/

function preMain() {
    setPriceStudy(true);
    setStudyTitle("Trongone MA ");
    setShowTitleParameters(false);
    setCursorLabelName("TMA", 0);
    setCursorLabelName("Yesterday's Vol", 1);
    setCursorLabelName("Night Session", 2);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(2, 0);
 

    var fp1 = new FunctionParameter("Periods", FunctionParameter.NUMBER);
        fp1.setName("SMA Periods");
        fp1.setLowerLimit(1);
        fp1.setDefault(34);
    var fp2 = new FunctionParameter("V", FunctionParameter.NUMBER);
        fp2.setName("Volume Trigger");
        fp2.setLowerLimit(0);
        fp2.setDefault(100000000);
    var fp3 = new FunctionParameter("LotSize", FunctionParameter.NUMBER);
        fp3.setName("Lot Size");
        fp3.setLowerLimit(1);
        fp3.setDefault(1000);
}

// Global Variables
var bVersion  = null;    // Version flag
var bInit     = false;   // Initialization
flag
var xMA       = null;
var xVol      = null;
var vPosition = 0;      // 0 = flat,  1 = long
var nOpen     = null    // open of first
bar of the day
var bBT       = true;   // back test
flag

function main(Periods, V, LotSize) {
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;

    //Initialization
    if (bInit == false) {
        xMA = sma(Periods, inv("D"));
        xVol = volume(inv("D"));
        bInit = true;
    }

    if (isLastBarOnChart()) bBT = false;
 
    var nState = getBarState();
    var nMA    = xMA.getValue(0);
    var nVol_1 = xVol.getValue(-1);
    var sVol_1 = formatVol(nVol_1);
    var nNight = open(0, inv("D")) - close(-1, inv("D"));
 
    if (nMA == null || nVol_1 == null || nNight == null) return;

    if (nState == BARSTATE_NEWBAR && day(0) != day(-1))
{
        nOpen  = open(0);
        if (nVol_1 > V && nNight
< 0 && nOpen > nMA) {
            vPosition
= 1;
            setBarBgColor(Color.lightgrey);
            drawShape(Shape.UPARROW,
BelowBar1, Color.blue);
            Alert.playSound("ding.wav");
            Alert.addToList(getSymbol(),
"TMA Long", Color.blue, Color.white);
            if (bBT)
Strategy.doLong("TMA Long", Strategy.MARKET, Strategy.THISBAR, LotSize);
        }
    }

    if (vPosition == 1) {
        if (isDWM()) {
            if (nState
== BARSTATE_NEWBAR) {
               
vPosition = 0;
               
if (bBT) Strategy.doSell("Close TMA Long", Strategy.CLOSE, Strategy.THISBAR,
LotSize);
            }
        } else if (day(0) == day(-1))
{
            if (day(0)
!= day(1) && !isLastBarOnChart()) {
               
vPosition = 0;
               
drawShape(Shape.DIAMOND, AboveBar1, Color.red);
               
if (bBT) Strategy.doSell("Close TMA Long", Strategy.CLOSE, Strategy.THISBAR,
LotSize);
            }
        }
    }
 
    if (vPosition == 1) setBarBgColor(Color.lightgrey);
 
    return new Array(getSeries(xMA), sVol_1, nNight.toFixed(2));
}
function formatVol(n) {
    if (n == null) return;
 
    var sNum = "";
    var s = n.toFixed(0);
    var nLen = s.length;
    var nCount = 0;
 
    for (var i = nLen; i >= 0; i--) {
        nCount++;
        if (nCount > 3 && i
!= 0) {
            sNum =
"," + s.substr(i, 1) + sNum;
            nCount
= 1;
        } else {
            sNum =
s.substr(i, 1) + sNum;
        }
    }
 
    return sNum;
}
function verify() {
    var b = false;
    if (getBuildNumber() < 779) {
        drawTextAbsolute(5, 35, "This
study requires version 8.0 or later.",
            Color.white,
Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null,
13, "error");
        drawTextAbsolute(5, 20, "Click
HERE to upgrade.@URL=https://www.esignal.com/download/default.asp",
            Color.white,
Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null,
13, "upgrade");
        return b;
    } else {
        b = true;
    }
 
    return b;
}
To discuss this study or download a complete copy of the formula, please visit the EFS Library Discussion Board forum under the Forums link at www.esignalcentral.com. The eSignal formula scripts (EFS) are also available for copying and pasting from the STOCKS & COMMODITIES website at Traders.com.
--Jason Keck
eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignalcentral.com


GO BACK


WEALTH-LAB: Trongone moving average (TMA) system

Analyzing a set of trading rules as Anthony Trongone did in his article in this issue, "Moving Averages: Long On Talk, Short On Action," is relatively easy when using a tool that simulates historical trades and shows a summary of performance statistics: you just go through a "trial and error" workcycle, making adjustments to the rules and evaluating the new results until you're satisfied with them.

But sometimes, you can find useful shortcuts! This month, we present some WealthScript code that may be of help when doing such analyses by producing detailed reports for each possible rule combination at once.

The idea for this was borrowed from electrical engineering, where systematic methods (try an Internet search for "Karnaugh Maps") are used for minimizing the complexity of Boolean expressions (that is, minimizing the number of logic gates in a circuit).

Since trading rules can rely heavily on Boolean expressions, we would like to have the computer find its way among all possible combinations of the terms involved in those rules, so that a user should only provide a handful of indicators and comparison criteria, and the best combinations of those should be quickly identified without further intervention.

To accomplish this task, the software applies all user-provided tests at each historical bar, packing test results (that is, Boolean "truth values") into a unique code. Trades are then simulated at each bar, and their statistics are collected into separate bins, one for each possible code.

At the end of the simulation, a table is displayed that reports all those statistics: by seeing all distinct combinations at a glance, a user should now be able to quickly identify which cases are to be filtered out, or identify the ones that should be merged together.

For example, we configured the software to use the data that Anthony Trongone identified (opening price, its Sma(34), yesterday's close, and volume). Running it on QQQQ, we obtained the table shown in Figure 3 (note that some rows were already filtered out, since their reported profits/losses were marginal).



FIGURE 3: WEALTH-LAB, TMA SYSTEM RESULTS. Using the same data that Anthony Trongone uses in his article (opening price, its Sma(34), yesterday's close, and volume), here is the TMA system on the QQQQ. Some rows were filtered out, since their reported profits/losses were marginal.

As you can see, the "union" of all three rows in this table correspond to the final rules for the TMA system as presented in Trongone's article.

So far so good, but when we run the program again, this time over all available QQQQ bars, the table becomes what is shown in Figure 4. It shows the same three cases as before (that's good, since previous results were confirmed by out-of-sample data), plus a new one. That comes in handy for short entries!

FIGURE 4: WEALTH-LAB, TMA SYSTEM RESULTS. Here is the same TMA system, this time run on all available QQQQ bars. It shows the same three cases as before plus a new one.
Here is the final ChartScript code that implements all these rules (TMA plus shorting):
 
var Bar: integer;
for Bar := 34 to BarCount - 1 do
begin
  if PriceOpen(Bar) > SMA(Bar - 1, #Open, 34) then
    if Volume(Bar - 1) > 100000000 then
      if (PriceOpen(Bar) < PriceClose(Bar - 1))
      or (PriceOpen(Bar) < 1 + SMA(Bar, #Open,
34)) then
        if BuyAtMarket(Bar, '') then
          SellAtClose(Bar, LastPosition,
'');
  if PriceOpen(Bar) <= SMA(Bar - 1, #Open, 34) then
    if Volume(Bar - 1) <= 100000000 then
      if (PriceOpen(Bar) >= PriceClose(Bar -
1)) then
        if (PriceOpen(Bar) < 1 + SMA(Bar,
#Open, 34)) then
          if ShortAtMarket(Bar,
'') then
            CoverAtClose(Bar,
LastPosition, '');
end;
WealthScript code:

function UserDefinedConditions(CLst: TList): integer;
begin //feel free to change or add other conditions (up to 31 items!)
  CLst.Clear;
  var SMA34: integer = SMASeries(#Open, 34);
  //first argument is a data series, that will be used as a conditional
  //that is, its positive elements will translate to "true"
  //second argument is a "human-readable" description of such conditional
  CLst.AddData(SubtractSeries(#Open, OffsetSeries(SMA34, -1)), 'Open
> SMA34');
  CLst.AddData(SubtractSeriesValue(OffsetSeries(#Volume, -1), 1e8),
'Volume > 100M');
  CLst.AddData(SubtractSeries(OffsetSeries(#Close, -1), #Open), 'Open
< PrevClose');
  CLst.AddData(SubtractSeries(AddSeriesValue(SMA34, 1), #Open), 'Open
< 1$ + SMA34');
  Result := 34; //leading bars to be skipped (ensure stability of indicators
above)
end;

const WholeWatchList = false; //set to true, to analyze all symbols in watchlist

//some basic statistics to be collected
type TStat = class
  N, Winning: integer;
  Profits, Losses: float;
end;
var StatLst: TList = TList.Create;

EnableSynch(false);
var CLst: TList = TList.Create; //a list of conditionals, with their descriptions
var w, Bar, i, j: integer;
for w := 0 to WatchListCount - 1 do begin
  if WholeWatchList then
    try SetPrimarySeries(WatchListSymbol(w)); except continue;
end;
  for Bar := UserDefinedConditions(CLst) to BarCount - 1 do begin
    //at each Bar, evaluate all conditionals, building a unique
Code
    var Code: integer = 0;
    for j := CLst.Count - 1 downto 0 do Code := 2 * Code -
(@CLst.Item(j)[Bar] > 0);
    //update statistics associated to that Code
    i := StatLst.IndexOf(Code);
    if i < 0 then i := StatLst.AddObject(Code, TStat.Create);
    var Stat: TStat = StatLst.Object(i) as TStat;
    Stat.N := Stat.N + 1;
    if (PriceOpen(Bar) > 0) and (PriceClose(Bar) > 0)
then //avoid data errors
      if PriceClose(Bar) > PriceOpen(Bar) then
begin
        Stat.Winning := Stat.Winning +
1;
        //using logarithms of returns
(invariant wrt amount of invested money)
        Stat.Profits := Stat.Profits +
ln(PriceClose(Bar) / PriceOpen(Bar));
      end else
        Stat.Losses := Stat.Losses + ln(PriceClose(Bar)
/ PriceOpen(Bar));
  end;
  if not WholeWatchList then break;
  ClearExternalSeries(GetSymbol);
end;
StatLst.SortNumeric;

function AvgPct(SumLnRet: float; N: integer): string;
begin //convert logreturns to average percent return
  if N = 0 then N := 1;
  Result := FormatFloat('0.00%', 100 * exp(SumLnRet / N) - 100);
end;

AddCommentary('<' + 'table border=1 cellspacing=0 cellpadding=3 style=text-align:right');
AddCommentary('<' + 'tr>');
AddCommentary('<' + 'td>' + 'Condition' + '</' + 'td>');
AddCommentary('<' + 'td>' + 'Occurrences' + '</' + 'td>');
AddCommentary('<' + 'td>' + 'AvReturn%' + '</' + 'td>');
AddCommentary('<' + 'td>' + 'Winning' + '</' + 'td>');
AddCommentary('<' + 'td>' + 'AvProfit%' + '</' + 'td>');
AddCommentary('<' + 'td>' + 'Losing' + '</' + 'td>');
AddCommentary('<' + 'td>' + 'AvLoss%' + '</' + 'td>');
AddCommentary('</' + 'tr>');

procedure DumpStat(S: TStat);
begin //show fields of 'Stat' into columns of an HTML table
  AddCommentary('</' + 'td>');
  AddCommentary('<' + 'td>' + AsString(S.N) + '</' + 'td>');
  AddCommentary('<' + 'td>' + AvgPct(S.Profits + S.Losses, S.N)
+ '</' + 'td>');
  AddCommentary('<' + 'td>' + AsString(S.Winning) + '</' +
'td>');
  AddCommentary('<' + 'td>' + AvgPct(S.Profits, S.Winning) + '</'
+ 'td>');
  AddCommentary('<' + 'td>' + AsString(S.N - S.Winning) + '</'
+ 'td>');
  AddCommentary('<' + 'td>' + AvgPct(S.Losses, S.N - S.Winning)
+ '</' + 'td>');
  AddCommentary('</' + 'tr>');
end;

var Total: TStat = TStat.Create;
var GrandTotal: TStat = TStat.Create;
for i := 0 to StatLst.Count - 1 do begin //show collected statistics as an
HTML table
  var Stat: TStat = StatLst.Object(i) as TStat; //skip "worthless" cases
  if abs(Stat.Profits + Stat.Losses) / Stat.N > 0.16 / 100 then begin
    var Code: integer = StatLst.Item(i);
    AddCommentary('<' + 'tr>' + '<' + 'td>');
    for j := 0 to CLst.Count - 1 do begin
      if (Code and 1) = 1 then AddCommentary(CLst.Data(j)
+ '<' + 'br>')
               
else AddCommentary('not( ' + CLst.Data(j) + ' )<' + 'br>');
      Code := Code div 2;
    end;
    DumpStat(Stat);
    Total.N := Total.N + Stat.N; //update filtered summary
    Total.Winning := Total.Winning + Stat.Winning;
    Total.Profits := Total.Profits + Stat.Profits;
    Total.Losses := Total.Losses + Stat.Losses;
  end;
  GrandTotal.N := GrandTotal.N + Stat.N; //update running total
  GrandTotal.Winning := GrandTotal.Winning + Stat.Winning;
  GrandTotal.Profits := GrandTotal.Profits + Stat.Profits;
  GrandTotal.Losses := GrandTotal.Losses + Stat.Losses;
end;

AddCommentary('<' + 'tr>' + '<' + 'td>' + 'Total');
DumpStat(Total);

AddCommentary('<' + 'tr>' + '<' + 'td>' + 'Grand Total');
DumpStat(GrandTotal);
AddCommentary('</' + 'table>');
 
-- Giorgio Beltrame
www.wealth-lab.com


GO BACK


AMIBROKER: Trongone moving average (TMA) system

The AmiBroker coding for Anthony Trongone's system, the Trongone moving average (TMA), is very simple and is shown here. Comments inside the code make it self-explanatory. To use it, enter the code into Formula Editor and choose the Tools: Backtest menu.

The code can be copied from the STOCKS & COMMODITIES website at https://www.traders.com/Documentation/FEEDbk_docs/TradersTips/TradersTips.html or from the AmiBroker website.
 

Amibroker code for  Trongone moving average (Tma)
// enter if open is greater than yesterday's 34 day MA.
Buy = Open > Ref( MA( C, 34 ), -1 )
AND Ref( V, -1 ) > 100000000 // yesterdays volume > 100mil
AND Open - Ref( Close, -1 ) < 0;// overnight session < $0
BuyPrice = Open;
Sell = Buy; // sell the same day on close
SellPrice = Close;
SetOption("AllowSameBarExit", True ); // exit same EOD bar
SetPositionSize( 1000, spsShares ); // pos size 1K shares
 
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com


GO BACK


NEUROSHELL TRADER: Trongone moving average (TMA) system

The Trongone moving average (TMA) system can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader's 800+ indicators into a trading strategy.  To recreate the strategy, select "New Trading Strategy …" from the Insert menu and enter the following entry and exit conditions in the appropriate locations of the Trading Strategy Wizard:
 

Generate a buy long MARKET order if ALL of the following are true:
    A>B ( Lead(Open,1), MovAvg( Close, 34 ) )
    A>B ( Volume, 1000000 )
    A<B ( Subtract ( Lead(Open,1), Close ), 0 )

 Generate a sell long MARKET CLOSE order if ALL of the following are
true:
    A=B ( Close, Close )


If you have NeuroShell Trader Professional, you can also choose whether the system parameters should be optimized. After backtesting the trading strategy, use the "Detailed Analysis …" button to view the backtest and trade-by-trade statistics for the Trongone moving average system.

FIGURE 5: NEUROSHELL TRADER, TRONGONE MOVING AVERAGE. Here is an example of the Trongone moving average system implemented on a NeuroShell chart.
To trade this system in real time after the open, use the recalculate chart feature.
--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com


GO BACK


AIQ: Trongone moving average (TMA) system

The AIQ code for Anthony Trongone's moving average system for trading the QQQQ is given here.

Trongone shows how the addition of two filters to a moving average trading system can make a big improvement over the traditional way that moving averages are used in trading systems. He acknowledges that once the filters are added, the number of trading signals is reduced significantly.

Using the system on just the QQQQ does not utilize the capital sufficiently to give a satisfactory return on capital. One of the filters on the QQQQ system requires a fixed-volume cutoff of greater than 100 million shares. I try to avoid using fixed cutoffs whenever possible, because they are not adaptive to changing market conditions. In addition, I wanted to see whether a trading system could be developed that would show a more acceptable return on capital. To do that, I needed a flexible filter for the volume that would automatically adjust to different ETF trading volumes and also to changes in the general level of market volume.

Thus, in place of Trongone's volume filter, I substituted the rule that the prior's day volume must be 110% higher than the 50-day simple average of volume. To generate more signals, I needed to run the trading system on more than one ETF. The ETFs need to have sufficient liquidity to withstand a higher frequency of trading without excessive slippage. I scanned for ETFs that had traded a million shares over the most recent 50-day period and that also had data back to or before 10/18/2002, the beginning of the test period. There are 23 ETFs that passed this test: DIA, EWH, EWJ, EWM, EWS, EWW, IWD, IWF, IWM, IWN, IWO, MDY, QQQQ, SPY, XLB, XLE, XLF, XLI, XLK, XLP, XLU, XLV, and XLY.

I ran a long-only trading simulation using the AIQ Portfolio Simulator on the above list of ETFs over the test period 12/31/2002 to 3/12/2007. I put 100% of capital into each trade. When there was more than one signal to trade, I chose the one with the highest 30-day relative strength. All entries are at the opening price and all exits are at the closing price on the day of entry (no positions are held overnight). Commission of $0.005 per share was deducted. I did not factor in any slippage. The results of this test were favorable (see sample AIQ chart in Figure 6).

FIGURE 6: AIQ, MODIFIED TMA  SYSTEM. Shown here is a sample equity curve for the AIQ modified TMA system versus the NDX index using a list of 23 liquid ETFs with more than five years of trading history.
I also ran a simulation over the generally bearish market period from 12/31/1999 to 12/31/2002. The results of this period showed an average annual loss of 2.61% and a maximum drawdown of 23%. This compares favorably to the NASDAQ 100, which showed a 24.4% annual loss with a greater than 80% maximum drawdown.

The AIQ code for the TMA trading system including my modifications can be downloaded from the AIQ website at https://www.aiqsystems.com/S&C1.htm.

The code, writeup, and sample charts are also posted here: https://www.tradersedgesystems.com/traderstips.htm.
 

!! MOVING AVERAGES
! Author: Anthony Trongone, TASC May 2007
! Coded by: Richard Denning 3/12/07

! ABBREVIATIONS:
C    is [close].
C1    is valresult(C,1).
O    is [open].
L    is [low].
H    is [high].
V    is [volume].

! INDICATORS:
SMA34    is simpleavg(O,34).
Space    is O - SMA34.
ONS    is O - C1.
V1    is valresult(V,1).
MAV    is simpleavg(V,50).
MAV1    is valresult(simpleavg(V,50),1).

! NOTE: System is set to run on daily bars:

! TRADING SYSTEM WITHOUT FILTERS
LE1    if Space > 0 and symbol() = "QQQQ".
LEpr    is O.        !
Entry price is open

! EXIT IS ALWAYS TRUE FORCES AN EXIT AT CLOSE
LX    if 1.
LXpr    is C.         !
Exit price is close

! TRADING SYSTEM WITH TMA FILTERS:
LE2    if LE1 and V1 > 10000*100 and ONS < 0.

! MODIFIED TMA TRADING SYSTEM:
LE3    if Space > 0 and V1 > MAV1 * 1.1 and ONS <
0.

!AIQ RELATIVE STRENGTH:
STL     is 30.
Q3s     is STL / 4.
Q2s    is (STL - Q3s) / 3.
Q1s    is (STL - Q2s - Q3s) / 2.
Q0s    is STL - Q1s - Q2s - Q3s.
ROCq3s     is (val([close],Q2s,(Q1s+Q0s))
    - val([open],Q3s,(Q2s+Q1s+Q0s)))
    / val([open],Q3s,(Q2s+Q1s+Q0s)) * 100.
ROCq2s    is (val([close],Q1s,Q0s) - val([open],Q2s,(Q1s+Q0s)))
    / val([open],Q2s,(Q1s+Q0s)) * 100.
ROCq1s    is (val([close],Q0s,0) - val([open],Q1s,Q0s))
    / val([open],Q1s,Q0s) * 100.
ROCq0s    is ([close] - val([open],Q0s,0)) / val([open],Q0s,0)
* 100.
RS_AIQst is ROCq0s * 0.40 + ROCq1s * 0.20 +
    ROCq2s * 0.20 + ROCq3s * 0.20.
RS_AIQst1 is valresult(RS_AIQst,1).
--Richard Denning
AIQ Systems
richard.denning@earthlink.net


GO BACK


STRATASEARCH: Trongone moving average (TMA) system

The Trongone moving average (TMA) system, which is presented by Anthony Trongone in his article "Moving Averages: Long On Talk, Short On Action" in this issue, illustrates that the whole can be greater than the sum of its individual parts.

The TMA system's trading rules showed little promise standing alone, yet their performance noticeably improved when they were combined into one system.

Further, Trongone in his article reminds us to adequately consider the securities and time periods on which we focus our system development efforts. As he implies, a holistic approach better enables us to create trading systems suitable for their environment.

To be less sanguine for a moment, people cannot be assured of executing trades at a security's open or close price in live trading. This nonetheless is a key assumption of the TMA system. In our testing of the system, its performance significantly deteriorated when we included slippage of 0.1% per side. This adjustment confined the system's cumulative profitability to the final five months of our tests (as shown in Figure 7). We also noted that its volume-based trading rule did not hold up well during our parameter shift analysis, another warning the system may not be profitable moving forward. Our findings about the TMA system, however, should not obscure the author's more important message: off-the-shelf ingredients can be creatively combined to produce profitable outcomes.

FIGURE 7: STRATASEARCH, TMA SYSTEM EQUITY LINE. This sample chart shows system performance (including the effects of slippage) during the evaluation period. Almost all gains accrued during the last five months of 2006, when the QQQQ rose nearly 20%.
As with all StrataSearch Traders' Tips, additional information, including plug-ins, can be found in the Shared Area of our user forum. This month's plug-in contains a prebuilt Strategy that will allow you to evaluate the Tma system yourself. Simply install the plug-in and launch your automated evaluation.
 
//****************************************************************
// Trongone Moving Average System
//****************************************************************
Entry String:
ref(open, 1) > mov(close, 34, simple) and
volume > 100000000 and
ref(open, 1) < close
Market Order: ref(open, 1)

Exit String:
close = close
Market Order: close
-- Steve Skinner
Avarin Systems, Inc.
www.StrataSearch.com
GO BACK

TRADECISION: Trongone moving average (TMA) system

In his article "Moving Averages: Long On Talk, Short On Action" in this issue, Anthony Trongone demonstrates the advantages of using a 34-day moving average system over the traditional moving average-based systems.

Here's a Strategy Builder that enables the user to recreate the Trongone moving average (TMA) system (Figures 8 and 9):

FIGURE 8: TRADECISION, TMA SYSTEM. The TMA strategy and indicator are applied to a daily QQQQ chart.

FIGURE 9: TRADECISION, TMA SYSTEM. Analyzing the TMA strategy performance and graphs using Simulation Manager's advanced reporting.

Entry long:

return SMA(C, 34) < O;

Exit long:

return SMA(C, 34) > = O;


To use this strategy in Tradecision, visit the area "Traders' Tips from Tasc magazine" at https://tradecision.com/support/tasc_tips/tasc_traders_tips.htm or copy the code from the STOCKS & COMMODITIES website at www.Traders.com.

--Alex Grechanowski
Alyuda Research, Inc.
www.alyuda.com, www.tradecision.com
GO BACK

TRADE NAVIGATOR: Trongone moving average (TMA) system

The Trongone moving average (TMA) system is a trading system based on a 34-bar moving average crossover with a few other conditions. Anthony Trongone, author of the article "Moving Averages: Long On Talk, Short On Action" in this issue, advocates trading this system on the cues (symbol QQQQ). His conditions for entry into the market are:

1) Opening price > 34-day moving average.
2) Yesterday's trading volume > 100 million shares.
3) Today's overnight session (today's open - yesterday's close) < $0.

He suggests exiting at market on close the same day as entry.

It's easy to get this system into Trade Navigator. You can follow the steps given below to make your own strategy or just download the special file listed at the end of this article.

Note: Strategy creation in Trade Navigator requires the Platinum version. You can still download the special file into the Gold version and apply the trading strategy to a chart, but you will not be able to run performance reports or create your own strategy without Platinum.

Strategy creation
1) Click on the Edit menu and choose Strategies.
2) Click the New button to make a new strategy.
3) Click No on the Strategy Wizard prompt.

Creating the entry rule
1) Click New Rule. Answer No if a prompt appears asking if you want to build this using indicators on the active chart.
2) Copy this rule and paste or type it into the condition box:

IF Volume > 100000000 And Next Bar Open > MovingAvg (Close , 34) And Next Bar Open - Close < 0

3) Click Save to save the rule. The default name is OK.

That's it for the entry rule. Now we need to make a new rule for our exit.

Creating the exit rule
1) Click New Rule and click "No" if prompted about using indicators from the active chart.
2) The condition for entry should be simply "If True."
3) Change the Action to "Long Exit."
4) Place a checkmark in the "Can Exit on Entry Bar" box.
5) Change Order Type to "Market on Close."
6) Click Save to save the rule. The default name is OK.

Setting the data to symbol QQQQ
1) Click on the Data tab.
2) Click the Symbol Lookup button to change the symbol.
3) Type "Qqqq" to set it to the Cues and click OK.

Save the strategy
Now that we have the entry and exit rules, just click Save and give the strategy a name. We used "Trongone moving average."

What can I do with the strategy?
Backtesting:
With the Platinum version of Trade Navigator, you just have to hit the Run button to get a performance report on this strategy.
Apply to chart:
With the Gold and Platinum versions of Trade Navigator, you can apply this strategy to a chart. It will indicate entry and exit signals, as well as generate order reports for next bar.

To apply the trading strategy to a chart
1) Hit the letter "A" on your keyboard to bring up the Add to Chart menu.
2) Click on the Strategies tab.
3) Scroll down until you find the Trongone moving average strategy and click on it.
4) Click "Add" to apply it to your chart.

Download special file
You can skip most of these steps if you wish and download a special file that will give you the Trongone moving average strategy.
1) Click on the File menu and select Update Data.
2) Click on the bottom option, Download Special File.
3) Type "sc0507" and click start.
4) Follow the Upgrade prompts and when Trade Navigator has restarted, you should have access to the strategy.

--Michael Herman
Genesis Financial Technologies
https://www.GenesisFT.com
GO BACK

Return to May 2007 Contents

Originally published in the May 2007 issue of Technical Analysis of STOCKS & COMMODITIES magazine. All rights reserved. © Copyright 2007, Technical Analysis, Inc.