Request Information From Advertisers
|
Home | S&C Magazine | Working Money | Traders' Resource | Message-Boards | Store
May 2008
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:
METASTOCK:
THE QUEST FOR RELIABLE CROSSOVERS
TRADESTATION:
THE QUEST FOR RELIABLE CROSSOVERS
eSIGNAL:
THE QUEST FOR RELIABLE CROSSOVERS
AMIBROKER:
THE QUEST FOR RELIABLE CROSSOVERS
CQG:
THE QUEST FOR RELIABLE CROSSOVERS
WEALTH-LAB:
THE QUEST FOR RELIABLE CROSSOVERS
NEUROSHELL
TRADER: THE QUEST FOR RELIABLE CROSSOVERS
WORDEN
BROTHERS BLOCKS: THE QUEST FOR RELIABLE CROSSOVERS
ASPEN
GRAPHICS: THE QUEST FOR RELIABLE CROSSOVERS
STRATASEARCH:
THE QUEST FOR RELIABLE CROSSOVERS
AIQ:
THE QUEST FOR RELIABLE CROSSOVERS
NINJATRADER:
THE QUEST FOR RELIABLE CROSSOVERS
STRATEGYDESK:
THE QUEST FOR RELIABLE CROSSOVERS
NEOTICKER:
THE QUEST FOR RELIABLE CROSSOVERS
TRADE
NAVIGATOR: THE QUEST FOR RELIABLE CROSSOVERS
TRADINGSOLUTIOSN:
THE QUEST FOR RELIABLE CROSSOVERS
SWINGTRACKER:
TEMA OVERLAY
VT
TRADER: CROSSOVER TRADING SYSTEM
or return to May 2008 Contents
Editor's note: This month's Traders' Tips are based on Sylvain
Vervoort's article in this issue, "The Quest For Reliable Crossovers."
Code written for MetaStock is already provided by the author in the article's
sidebars. Additional code is presented here.
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, code found in Vervoort's article can be copied and
pasted into MetaStock from the Subscriber Area at www.Traders.com. Login
is required.
METASTOCK: THE QUEST FOR RELIABLE CROSSOVERS
Editor's note: Code for MetaStock can be found in the sidebars to Sylvain
Vervoort's article in this issue, "The Quest For Reliable Crossovers."
The code is reprinted here:
TEMA
Tema(Close, 10, Exponential)
Or a more general method:
3*Mov(C,10,E)-3*Mov(Mov(C,10,E),10,E)+Mov(Mov(Mov(C,10,E),10,E),10,E)
where Mov = moving average, C = Closing price,
E = Exponential average
HEIKIN-ASHI
haOpen:=(Ref((O+H+L+C)/4,-1) + PREV)/2;
haC:=((O+H+L+C)/4+haOpen+Max(H,haOpen)+Min(L,haOpen))/4;
ZERO-LAGGING EMA AND TEMA
EMA
Period:= Input("What Period",1,250,10);
EMA1:= Mov(CLOSE,Period,E);
EMA2:= Mov(EMA1,Period,E);
Difference:= EMA1 - EMA2;
ZeroLagEMA:= EMA1 + Difference;
ZeroLagEMA
TEMA
Period := Input("What TEMA period? ",1,250,10);
TMA1:= Tema(CLOSE,period);
TMA2:= Tema(TMA1,period);
Difference:= TMA1 - TMA2;
ZeroLagTMA:= TMA1 + Difference;
ZeroLagTMA
moving averages used
Typical price zero-lagging TEMA
MetaStock formula:
period := Input("Average TEMA period? ",1,100,55);
TMA1:= Tema(Typ(),period);
TMA2:= Tema(TMA1,period);
Difference:= TMA1 - TMA2;
ZeroLagTMA:= TMA1 + Difference;
ZeroLagTMA
Heikin-ashi zero-lagging TEMA
MetaStock formula:
avg := Input("Average TEMA period? ",1,100,55);
haOpen:=(Ref((O+H+L+C)/4,-1) + PREV)/2;
haC:=((O+H+L+C)/4+haOpen+Max(H,haOpen)+
Min(L,haOpen))/4;
TMA1:= Tema(haC,avg);
TMA2:= Tema(TMA1,avg);
Diff:= TMA1 - TMA2;
ZeroLagHA:= TMA1 + Diff;
ZeroLagHA
Buying formula (MetaStock)
Avg:=55; {a 55 fixed day average}
haOpen:=(Ref((O+H+L+C)/4,-1) + PREV)/2;
haC:=((O+H+L+C)/4+haOpen+Max(H,haOpen)+Min
(L,haOpen))/4;
TMA1:= Tema(haC,avg);
TMA2:= Tema(TMA1,avg);
Diff:= TMA1 - TMA2;
ZlHa:= TMA1 + Diff;
TMA1:= Tema(typ(),avg);
TMA2:= Tema(TMA1,avg);
Diff:= TMA1 - TMA2;
ZlCl:= TMA1 + Diff;
cross(ZlCl,ZlHa) {crossover of the zero-lagging TEMA on the typical price
and the zero-lagging TEMA of the heikin-ashi closing price}
Selling formula (MetaStock)
Similar to the buying formula except the last line, which makes the
crossover the other way around -- that is, cross(ZlHa,ZlCl)
GO BACK
TRADESTATION: THE QUEST FOR RELIABLE CROSSOVERS
Sylvain Vervoort's article in this issue, "The Quest For Reliable Crossovers,"
describes a trading system based on three functions: the triple exponential
moving average (TMA), the heikin-ashi close (haC), and the "typical price"
(TypicalPrice). Vervoort's strategy trades the crossover of the typical
price and heikin-ashi TMAs (Figure 1).

FIGURE 1: TRADESTATION, CROSSOVER STRATEGY. Here is a demonstration
of Vervoort's crossover strategy applied to a daily chart of S&P Depository
Receipts (SPY). The zero-lagging TMAs of both the typical price (red line)
and the heikin-ashi close (yellow line) are shown. The crossover of these
two averages produces the displayed trades.
TypicalPrice is a built-in function in TradeStation. The code for the triple
exponential moving average was published in the February 2008 issue of
S&C. The heikin-ashi code is provided here. The ELD file posted at
TradeStation.com (see link) contains all of the necessary code.
Vervoort reports doing a backtest of his system on more than 200 stocks.
Code for performing such a test can be found by searching the TradeStation
and EasyLanguage support forum for the topic "Batch Process for a series
of charts" (https://www.tradestation.com/Discussions/Forum.aspx?Forum_ID=213).
The TMA, like all exponential moving average calculations, is "starting-point
dependent." This means the value of an exponential moving average on any
bar depends on which bar the calculations began. To minimize the starting-point
dependency of Vervoort's calculations, the strategy does not trade until
four times the number of bars specified by the "Period" input have passed.
The zero-lagging TMA indicator includes a similar delay before plotting.
If you input the code into your PowerEditor, you can set both the TMA indicator
and strategy to have a MaxBarsBack setting of "1" (one bar).
To download the EasyLanguage code for these studies, go to the TradeStation
and EasyLanguage support forum and search for the file "VervoortCrossover.ELD."
Function: haOpen
haOpen = 0.5 * ( AvgPrice + haOpen[1] ) ;
Function: haC
haC = 0.25 * ( AvgPrice + haOpen +
MaxList( High, haOpen )+ Minlist( Low, haOpen ) ) ;
Indicator: Zero-Lagging TMA
inputs:
Price( TypicalPrice ),
Period( 55 ) ;
variables:
TMA1( 0 ),
TMA2( 0 ),
Difference( 0 ),
ZeroLagTMA( 0 ) ;
TMA1 = TEMA( Price, Period ) ;
TMA2 = TEMA( TMA1, Period ) ;
Difference = TMA1 - TMA2 ;
ZeroLagTMA = TMA1 + Difference ;
if CurrentBar > 4 * Period then
Plot1( ZeroLagTMA, "ZeroLagTMA" ) ;
Strategy: Vervoort Crossover
inputs:
Investment( 1000 ),
Period( 55 );
variables:
TMA1( 0 ),
TMA2( 0 ),
Difference( 0 ),
ZeroLagTMA( 0 ),
TMA3( 0 ),
TMA4( 0 ),
Difference2( 0 ),
ZeroLagHeikinAshi( 0 ),
NumShares( 0 ) ;
TMA1 = TEMA( TypicalPrice, Period ) ;
TMA2 = TEMA( TMA1, Period ) ;
Difference = TMA1 - TMA2 ;
ZeroLagTMA = TMA1 + Difference ;
TMA3 = TEMA( haC, Period ) ;
TMA4 = TEMA( TMA3, Period ) ;
Difference2 = TMA3 - TMA4 ;
ZeroLagHeikinAshi = TMA3 + Difference2 ;
NumShares = IntPortion( Investment / Close ) ;
if CurrentBar > 4 * Period then
begin
if ZeroLagTMA crosses over ZeroLagHeikinAshi then
Buy NumShares shares next bar market
else if ZeroLagTMA crosses under ZeroLagHeikinAshi then
Sell next bar market ;
end ;
TradeStation does not endorse or recommend any particular strategy.
--Mark Mills
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
www.TradeStation.com
GO BACK
eSIGNAL: THE QUEST FOR RELIABLE CROSSOVERS
For this month's Traders' Tip, we've provided the formulas Tema.efs,
ZeroLag_Tema.efs, HA_ZeroLag_Tema.efs, and ZeroLag_HA_Tema_Cross.efs, based
on the formula code from Sylvain Vervoort's article in this issue, "The
Quest For Reliable Crossovers."
The studies contain formula parameters that may be configured through
the Edit Studies option in the Advanced Chart to change the number of periods
and price source for the averages. In addition, the ZeroLag_HA_Tema_Cross.efs
contains a formula parameter to force the strategy to allow only long trades,
which is also configured for backtesting with the Strategy Analyzer.
Sample charts can be seen in Figures 2 and 3.

FIGURE 2: eSIGNAL, TEMA. This eSignal Advanced Chart displays
the TEMA, zero-lag TEMA, and HA zero-lag TEMA studies.

FIGURE 3: eSIGNAL, TEMA CROSSOVER. This eSignal Advanced Chart displays
the HA Zero Lag TEMA study.
eSignal code for the zero-lag EMA study discussed in the article
can be found in the February 2008 Traders' Tips section in the S&C
back-issue archive (http://www.traders.com/Documentation/FEEDbk_docs/Archive/022008/TradersTips/TradersTips.html)
or the eSignal EFS Library. Meanwhile, the original heikin-ashi study mentioned
in the article was covered in the February 2004 Traders' Tips, also found
at the S&C back-issue archive.
To discuss these studies or download complete copies of the formula
code, please visit the EFS Library Discussion Board forum under the Forums
link at www.esignalcentral.com or visit our Efs KnowledgeBase at www.esignalcentral.com/support/kb/efs/.
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
AMIBROKER: THE QUEST FOR RELIABLE CROSSOVERS
In "The Quest For Reliable Crossovers" in this issue, Sylvain
Vervoort presents a basic trading system that uses a combination of techniques
presented in earlier issues of STOCKS & COMMODITIES, namely the zero-lag
exponential moving averages and heikin-ashi charts. The system is based
on crossovers between averages calculated using a typical price and heikin-ashi
transformation. For an example, see Figure 4.

FIGURE 4: AMIBROKER, CROSSOVER SYSTEM. Here is a daily QQQQ
chart showing heikin-ashi candlesticks with 55-day zero-lag moving averages
and arrows marking entry and exit points.
Listing 1 shows a full-featured all-in-one formula that implements a heikin-ashi
chart with zero-lag moving averages, together with basic trading system
rules and entry/exit arrows.
Using the Parameters window, you can adjust the average period as well
as switch between regular candlestick charts and heikin-ashi charts. The
same formula can also be used in the Automatic Analysis window to perform
backtesting.
LISTING 1
function ZeroLagTEMA( array, period )
{
TMA1 = TEMA( array, period );
TMA2 = TEMA( TMA1, period );
Diff = TMA1 - TMA2;
return TMA1 + Diff ;
}
/////////////////////
// Heikin-Ashi code
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
// Velvoort is using not original, but modified Heikin-Ashi close
HaClose = ( HaClose + HaOpen + HaHigh + HaLow )/4;
// you can switch between Heikin-Ashi chart and regular candlestick chart
if( ParamToggle("Plot Heikin-Ashi", "No,Yes", 1 ) )
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Heikin Ashi " + Name(), colorBlack, styleCandle );
else
Plot( C, "Regular candles " + Name(), colorBlack, styleCandle );
period = Param("Avg. TEMA period", 55, 1, 100 );
ZLHa = ZeroLagTEMA( HaClose, period );
ZLTyp = ZeroLagTEMA( Avg, period );
Plot( ZLHa, "ZLTema(Ha,"+period+")", colorRed );
Plot( ZLTyp, "ZLTema(Typ,"+period+")", colorGreen );
Buy = Cross( ZLTyp, ZLHa );
Sell = Cross( ZLHa, ZLTyp );
PlotShapes( shapeUpArrow * Buy, colorGreen, 0, HaLow );
PlotShapes( shapeDownArrow * Sell, colorRed, 0, HaHigh );
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
GO BACK
CQG: THE QUEST FOR RELIABLE CROSSOVERS
Here is the CQG code for recreating the custom studies detailed in
the "Crossovers" sidebar in Sylvain Vervoort's article in this issue, "The
Quest For Reliable Crossovers."
Each study uses a parameters setup named Period. You can easily modify
the lookback period from the study. Click on the "Parms" button to create
the parameter "Period." The default period in the CQG component pac for
the Tema study is 10 bars and 55 bars for the ZLHA and the ZLCLstudies.
Code for Tema:
(3* MA(@,Exp,Period))-(3* MA( MA(@,Exp,Period),Exp,Period))
+ MA( MA( MA(@,Exp,Period),Exp,Period),Exp,Period)
Code for Zlha:
HAOpen:=((((( Open(@)+ High(@)+ Low(@)+ Close(@))/4))[-1])+HAOpen[-1])/2;
HACLose:=(( Open(@)+ High(@)+ Low(@)+ Close(@))/4+HAOpen
+ Maximum( High(@),HAOpen)+ Minimum( Low(@),HAOpen))/4;
TEMA1:= TEMA.c1^(HACLose,Period);
TEMA2:= TEMA.c1^(TEMA1,Period);
Diff:=TEMA1-TEMA2;
TEMA1+Diff
Code for Zlcl:
TEMA1:= TEMA.c1^(@,Period);
TEMA2:= TEMA.c1^(TEMA1,Period);
Diff:=TEMA1-TEMA2;
TEMA1+Diff
A CQG component pac is available at the CQG website for installing
the studies on CQG (http://www.cqg.com/Support/Downloads.aspx). The pac
is also available at Thom Hartle's personal blog, www.hartleandflow.com.
--Thom Hartle
CQG, Inc.
www.cqg.com
GO BACK
WEALTH-LAB: THE QUEST FOR RELIABLE CROSSOVERS
The code for Wealth-Lab version 5.0 to use the zero-lag triple EMA
crossover system presented in Sylvain Vervoort's article in this issue,
"The Quest For Reliable Crossovers," is given here.
We interpreted the "power of analyzing" logic to exit for a profit when
the averages cross, but exit for a loss at the lesser price of a 10% stop-loss
or a close lower than the lowest low of the 21 bars prior to entry. Running
that strategy in Portfolio Simulation mode using 5% of equity per trade
on the NASDAQ 100 over the five years ending 12/31/2007 resulted in gains
of approximately 21% annualized. The actual result varies from simulation
to simulation since the portfolio can hold only 20 positions simultaneously
using the 5% of equity sizing method. The buy & hold strategy, however,
returned nearly 38% Apr over the same period (Figure 5).

FIGURE 5: WEALTH-LAB, CROSSOVER TRADING SYSTEM. Note that
one of the crossovers did not result in a simulated trade. This is not
an error but rather due to the results of a Portfolio Simulation in which
insufficient equity existed at the time of the trading alert. The WealthScript
code also creates the heikin-ashi chart style.
WealthScript strategy code:
/* Code for the derived WealthScript Class using TASCIndicators; */
private StrategyParameter emaPeriod; // Slider parameter
public ReliableCrossovers()
{
emaPeriod = CreateParameter("EMA Period", 55, 10, 120, 5);
}
public DataSeries ZLTEMASeries(DataSeries Source, int Period, EMACalculation calcType)
{
DataSeries tma1 = TEMA.Series(Source, Period, calcType);
DataSeries tma2 = TEMA.Series(tma1, Period, calcType);
return tma1 + (tma1 - tma2);
}
protected override void Execute()
{
/* Create a Heikin-Ashi chart above the main PricePane */
DataSeries HO = Open + 0; // intializations
DataSeries HH = High + 0;
DataSeries HL = Low + 0;
DataSeries HC = (Open + High + Low + Close) / 4;
DataSeries haC = HC + 0;
haC.Description = "Heikin-Ashi Close";
for (int bar = 1; bar < Bars.Count; bar++)
{
double o1 = HO[ bar - 1 ];
double c1 = HC[ bar - 1 ];
HO[bar] = ( o1 + c1 ) / 2;
HH[bar] = Math.Max( HO[bar], High[bar] );
HL[bar] = Math.Min( HO[bar], Low[bar] );
haC[bar] = ( HC[bar] + HO[bar] + HH[bar] + HL[bar] ) / 4;
}
ChartPane haPane = CreatePane(40, true, true);
PlotSyntheticSymbol(haPane, "Heikin-Ashi", HO, HH, HL, HC, Volume, Color.DodgerBlue, Color.Red);
//Obtain SMA period from parameter
int period = emaPeriod.ValueInt;
double stop = 0d;
double LL = 0d;
DataSeries typPrice = ( High + Low + Close ) / 3;
DataSeries zlTyp = ZLTEMASeries(typPrice, period, EMACalculation.Modern);
zlTyp.Description = "ZeroLagTEMA(typPrice, " + period + ")";
PlotSeries(PricePane, zlTyp, Color.Blue, LineStyle.Solid, 2);
DataSeries zlHa = ZLTEMASeries(haC, period, EMACalculation.Modern);
zlHa.Description = "ZeroLagTEMA(HeikinAshiClose, " + period + ")";
PlotSeries(PricePane, zlHa, Color.Red, WealthLab.LineStyle.Dashed, 2);
for(int bar = period; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
Position p = LastPosition;
stop = Math.Min(LL, p.EntryPrice * 0.9);
if( CrossUnder(bar, zlTyp, zlHa) && Close[bar] > p.EntryPrice )
SellAtMarket(bar + 1, p, "Profit");
else if( Close[bar] < stop )
SellAtMarket(bar + 1, p, "Stop Loss");
}
else if( CrossOver(bar, zlTyp, zlHa) )
{
LL = Lowest.Series(Low, 21)[bar];
BuyAtMarket(bar + 1);
}
}
}
--Robert Sucher
www.wealth-lab.com
GO BACK
NEUROSHELL TRADER: THE QUEST FOR RELIABLE
CROSSOVERS
The zero-lag indicators described by Sylvain Vervoort in his article
in this issue, "The Quest For Reliable Crossovers," can be easily implemented
in NeuroShell Trader by combining a few of NeuroShell Trader's 800+ indicators.
Select "New Indicator ..." from the Insert menu and use the Indicator Wizard
to create the following indicators:
ZeroLag EMA:
Add2( ExpAvg( Close, period ),
Subtract( ExpAvg( Close, period ),
ExpAvg( ExpAvg( Close, period )) ) )
ZeroLag TEMA:
Add2( TEMA( Close, period ),
Subtract( TEMA( Close, period ),
TEMA(TEMA( Close, period )) ) )
ZeroLag Heikin-ashi TEMA:
Add2( TEMA( HeikinAshiClose(), Period ),
Subtract( TEMA(HeikinAshiClose(), period ),
TEMA( TEMA(HeikinAshiClose(), period )) ) )
ZeroLag MedianPrice TEMA:
Add2( TEMA( Avg2(High,Low), Period ),
Subtract( TEMA(Avg2(High,Low), period ),
TEMA( TEMA(Avg2(High,Low), period )) ) )
Note: The zero-lagging TEMA and heikin-ashi zero-lagging TEMA are
based on the HeikinAshiClose and TEMA custom indicators, which NeuroShell
Trader users can download for free at www.ward.net.
To recreate the crossover trading strategy as described in Vervoort's
article (Figure 6), select "New Trading Strategy ..." from the Insert menu
and enter the following in the appropriate locations of the Trading Strategy
Wizard:

FIGURE 6: NEUROSHELL, CROSSOVER SYSTEM. Here is a NeuroShell
Trader chart that shows the TEMA crossover based on Sylvain Vervoort's
technique.
Buy Long Condition:
CrossAbove (ZeroLag MedianPrice TEMA, ZeroLag Heikin-ashi TEMA )
Sell Long Condition:
CrossBelow (ZeroLag MedianPrice TEMA, ZeroLag Heikin-ashi TEMA )
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 crossover strategy.
Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section
of the NeuroShell Trader free technical support website to download a copy
of this or any previously published 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
WORDEN BROTHERS BLOCKS: THE QUEST FOR RELIABLE
CROSSOVERS
In his article in this issue, "The Quest For Reliable Crossovers,"
Sylvain Vervoort discusses several ways to smooth closing prices with as
little lag as possible. Charts with triple exponential moving averages
(TEMA), averages based on heikin-ashi closing prices, and zero-lag averages
can be found in the Share library of Blocks 3.0.
(Note: To use the indicators and charts in this Traders' Tip, you will
need the free Blocks software. Go to www.Blocks.com to download the software
and get detailed information on the available data packs.)
Click the Share button, then type in part of the name of a chart listed
below on the Chart tab, then click the Search button.
EMA - TEMA - TEMA of heikin-ashi
TEMA zero-lagging average
Zero-lag heikin-ashi TEMA - Median price zero lag TEMA
Reliable crossovers
In Figure 7, the sample chart shows a typical price zero-lag TEMA (green)
vs. a heikin-ashi zero-lag TEMA (red) to time entry and exit conditions.

FIGURE 7: WORDEN BLOCKS, CROSSOVERS USING A PERIOD OF 55
BARS. You can experiment with different periods to find the optimum period
for a specific stock.
For more information and to view Blocks tutorial videos, go to www.Blocks.com.
--Bruce Loebrich and Patrick Argo
Worden Brothers, Inc
www.blocks.com.
GO BACK
ASPEN GRAPHICS: THE QUEST FOR RELIABLE
CROSSOVERS
Aspen Graphics offers several styles of visual cues for displaying the
crossovers discussed in Sylvain Vervoort's article in this issue, "The
Quest For Reliable Crossovers."
By creating small formula files for the various averages used in Vervoort's
article, Aspen provides a platform where formulas become modular and reusable.
Due to space concerns, only those used directly in the crossover are displayed
here. The full list of formulas can be found on our forums at http://www.aspenres.com/forums/viewtopic.php?f=3&t=13.
We start by creating the heikin-ashi candle, TEMA, and zero-lag TEMA
formulas and call those formulas in our crossover formula. We implement
the crossover using a formula that returns integer values. We can then
take this formula and apply it to text-on-chart formulas as well as color
rules and email alerts.
Figure 8 illustrates text-on-chart visual cues as well as color rules
on both time-based and tick-based charts.

FIGURE 8: ASPEN GRAPHICS, CROSSOVERS. This screenshot illustrates
text-on-chart visual cues as well as color rules on both time-based and
tick-based charts.
haOpen(input) = ( ( ( $1.open[1] + $1.high[1] + $1.low[1] + $1.close[1] ) / 4 )+ $1.prev) / 2
haClose(input) = begin
val1 = ($1.open + $1.high + $1.low + $1.close) / 4
val2 = 0
val3 = 0
hopen = haOpen($1)
retval = 0
if($1.high > hopen) then val2 = $1.high
if($1.high <= hopen) then val2 = hopen
if($1.low < hopen) then val3 = $1.low
if($1.low >= hopen) then val3 = hopen
retval =( val1+ hopen + val2 + val3 ) / 4
retval
end
TEMA(input, periods = 10) = 3 * eavg($1, periods) - 3 * eavg(eavg($1, periods), periods)
+ eavg(eavg(eavg($1, periods), periods), periods)
HAZLTema(input, periods = 55) = begin
retval = 0
TMA1 = TEMA(haClose(input), periods)
TMA2 = TEMA(TEMA(haClose(input), periods), periods)
difference = TMA1 - TMA2
retval = TMA1 + difference
retval
end
ZeroLagTEMA(input, periods = 55) = begin
retval = nonum
avg1 = TEMA($1.avg, periods)
avg2 = TEMA(TEMA($1.avg, periods), periods)
difference = avg1 - avg2
retval = avg1 + difference
retval
end
crossTest(series, periods=55) = begin
retval = 0
ZLTema1 = ZeroLagTema($1, periods)
ZLTema2 = ZeroLagTema($1, periods)[-1]
HAZLTema1 = HAZLTema($1, periods)
HAZLTema2 = HAZLTema($1, periods)[-1]
if( (ZLTema1 > HAZLTema1) and (ZLTema2 < HAZLTema2) ) then retval = -1
if( (HAZLTema1 > ZLTema1) and (HAZLTema2 < ZLTema2) ) then retval = 1
retval
end
crossover(input, periods = 55) = begin
retval = nonum
if( crossTest($1, periods) == 1 ) then begin
retval = 'buy'|clr_white|below|ftiny|arrow|vertical
end
if( crossTest($1, periods) == -1 ) then begin
retval = 'sell'|clr_yellow|above|ftiny|arrow|vertical
end
retval
end
--Jeremiah Adams, Aspen Research Group
Sales: 1-800-359-1121, Support: (970) 945-2921
sales@aspenres.com, support@aspenres.com
Aspenres.com
GO BACK
STRATASEARCH: THE QUEST FOR RELIABLE CROSSOVERS
Once in a while, we come across a new indicator that works perfectly
right out of the box. The zero-lag crossover presented by Sylvain Vervoort
in his article in this issue, "The Quest For Reliable Crossovers," seems
to be one of those indicators.
During initial testing on five years of NASDAQ 100 stocks, the zero-lag
crossover seemed to perform best at about a 58-day period, which is close
to the 55-day period suggested by the author. Holding periods of winning
trades was four times longer than those of losing trades, and the average
gain was twice the percentage of the average loss. The percentage of profitable
trades, however, was only about 35% (Figure 9).

FIGURE 9: STRATASEARCH, CROSSOVERS. While there will always
be some lag in a crossover, Vervoort's crossover technique can decrease
the lag considerably.
In a second test, we ran this indicator in an automated search to test
its benefit alongside other indicators. In a few hours, we ran the zero-lag
crossover more than 50,000 times, each time testing it with supporting
indicators such as price rate-of-change, stochastics, and forecast oscillator.
Interestingly, the greatest benefits came when the supporting indicators
focused on the sector as a whole, rather than the individual stock. But
these supporting indicators greatly increased the annual return in addition
to improving the percentage profitability.
As with all other Traders' Tips, additional information, including plug-ins,
can be found in the Shared Area of the StrataSearch user forum. This month's
plug-in contains a number of prebuilt trading rules that will allow you
to include this indicator in your automated searches. Simply install the
plug-in and let StrataSearch identify which supporting indicators might
be the most helpful.
//***************************************
// Zero Lag Buy Signal
//***************************************
avg = parameter("Period");
TMA1 = tema(haClose(), avg);
TMA2 = tema(TMA1, avg);
Diff = TMA1 - TMA2;
ZlHa = TMA1 + Diff;
TMA1 = tema(tp(), avg);
TMA2 = tema(TMA1, avg);
Diff = TMA1 - TMA2;
ZlCl = TMA1 + Diff;
ZeroLagBuy = CrossAbove(ZlCl, ZlHa);
//****************************************
// Zero Lag Sell Signal
//****************************************
avg = parameter("Period");
TMA1 = tema(haClose(), avg);
TMA2 = tema(TMA1, avg);
Diff = TMA1 - TMA2;
ZlHa = TMA1 + Diff;
TMA1 = tema(tp(), avg);
TMA2 = tema(TMA1, avg);
Diff = TMA1 - TMA2;
ZlCl = TMA1 + Diff;
ZeroLagSell = CrossBelow(ZlCl, ZlHa);
--Pete Rast
Avarin Systems Inc
www.StrataSearch.com
GO BACK
AIQ: THE QUEST FOR RELIABLE CROSSOVERS
The AIQ code for constructing the two moving averages described by Sylvain
Vervoort in his article in this issue, "The Quest For Reliable Crossovers,"
is shown below.
Due to time constraints, I was not able to provide test results using
my standard test list, the NASDAQ 100 list of stocks. The tests will be
available at my website, www.tradersedgesystems.com/traderstips.htm.
This code can be downloaded from the AIQ website at www.aiqsystems.com
and also from www.tradersedgesystems.com/traderstips.htm.
!! QUEST FOR RELIABLE CROSSOVERS
! Author: Sylvain Vervoort, TASC May 2008
! Coded by: Richard Denning 3/12/08
! CODING ABBREVIATIONS:
H is [high].
L is [low].
C is [close].
C1 is valresult(C,1).
O is [open].
V is [volume].
! INPUTS:
emaLen is 55.
!--------TEMA----------------------------
! Formula:
! TEMA=3xEMA(input)-3 x EMA(EMA(input)+EMA(EMA(EMA(input)))
EMA1 is expavg(C,emaLen).
EMA2 is expavg(EMA1,emaLen).
EMA3 is expavg(EMA2,emalen).
TEMA is 3*EMA1-3*EMA2+EMA3.
!--------end TEMA----
!--------HEIKIN-ASHI--------
haC is (O + H +L + C) / 4.
DaysInto is ReportDate() - RuleDate().
end if DaysInto > 10.
endHAO is iff(end,O, haO).
haO is (valresult(endHAO,1) + valresult(haC,1)) / 2.
haH is Max(H,max(haO,haC)).
haL is Min(L,min(haO,haC)).
haCL is (haC + haO + haH + haL) / 4.
!--------end HEIKIN-ASHI--------
!--------ZERO-LAGGING EMA--------
Diff is EMA1 - EMA2.
zeroLagEMA is EMA1 + Diff.
!--------end ZERO LAG EMA--------
!--------TYPICAL PRICE ZERO-LAG TEMA--------
TP is (H+L+C)/3.
TMA1 is expavg(TP,emaLen).
TMA2 is expavg(TMA1,emaLen).
TMA3 is expavg(TMA2,emalen).
tpTEMA1 is 3*TMA1-3*TMA2+TMA3.
TMA4 is expavg(tpTEMA1,emaLen).
TMA5 is expavg(TMA4,emaLen).
TMA6 is expavg(TMA5,emalen).
tpTEMA2 is 3*TMA4-3*TMA5+TMA6.
Diff2 is tpTEMA1 - tpTEMA2.
zeroLAGtpTEMA is tpTEMA1 + Diff2.
!--------end TYPICAL PRICE ZERO-LAG TEMA--------
!--------HEIKIN-ASHI ZERO-LAG TEMA--------
haTMA1 is expavg(haCL,emaLen).
haTMA2 is expavg(haTMA1,emaLen).
haTMA3 is expavg(haTMA2,emalen).
haTEMA1 is 3*haTMA1-3*haTMA2+haTMA3.
haTMA4 is expavg(haTEMA1,emaLen).
haTMA5 is expavg(haTMA4,emaLen).
haTMA6 is expavg(haTMA5,emalen).
haTEMA2 is 3*haTMA4-3*haTMA5+haTMA6.
Diff3 is haTEMA1 - haTEMA2.
zeroLAGhaTEMA is haTEMA1 + Diff3.
!--------end HEIKIN-ASHI ZERO-LAG TEMA--------
!--------BUYING FORMULA (Xup)--------
Xup if zeroLAGtpTEMA > zeroLAGhaTEMA
and valrule(zeroLAGtpTEMA < zeroLAGhaTEMA ,1).
!--------SELLING FORMULA (Xdn)--------
Xdn if zeroLAGtpTEMA < zeroLAGhaTEMA
and valrule(zeroLAGtpTEMA > zeroLAGhaTEMA ,1).
--Richard Denning, AIQ Systems
richard.denning@earthlink.net
GO BACK
NINJATRADER: THE QUEST FOR RELIABLE CROSSOVERS
The various indicators and strategy discussed in this issue by Sylvain
Vervoort in "The Quest For Reliable Crossovers" is available for download
at www.ninjatrader.com/SC/May2008SC.zip.
Once downloaded, from within the NinjaTrader Control Center window,
select the menu File > Utilities > Import NinjaScript and select the downloaded
file. This indicator is for NinjaTrader Version 6.5 or greater.
You can review the indicator's source code by selecting the menu Tools
> Edit NinjaScript > Indicator from within the NinjaTrader Control Center
window and selecting either ZeroLagEMA, ZeroLagHATEM, ZeroLoagTEMA.
You can review the strategy source code by selecting the menu Tools
> Edit NinjaScript > Strategy from within the NinjaTrader Control Center
window and selecting VervoortMACrossOver. See Figure 10.

FIGURE 10: NINJATRADER, CROSSOVERS. The screenshot shows
the VervoortMACrossOver strategy backtested on a five-minute chart of the
March 2008 S&P emini contract.
NinjaScript indicators are compiled DLLs that run native, not interpreted,
which provides you with the highest performance possible.
-- Raymond Deux and Josh Peng
NinjaTrader, Llc
www.ninjatrader.com
GO BACK
STRATEGYDESK: THE QUEST FOR RELIABLE CROSSOVERS
In his article in this issue, "The Quest For Reliable Crossovers," Sylvain
Vervoort discusses the use of moving average crossovers for entry and exit
points. Here, we'll present one interpretation using TD Ameritrade's StrategyDesk.
In the article, Vervoort shows the benefits of using a zero-lag moving
average. Here is the StrategyDesk formula for a five-day zero-lag exponential
moving average (Figure 11):

FIGURE 11: TD AMERITRADE, CROSSOVERS. Buy signals are produced
when the five-day zero-lag exponential moving average (red line) crosses
above the five-day exponential moving average (blue line); sell signals
are shown when the zero-lag average crosses below the normal average.
2 * ExpMovingAverage[EMA,Close,5,0,D] - (.3333*ExpMovingAverage[EMA,Close,5,0,D]
+ .2222*ExpMovingAverage[EMA,Close,5,0,D,1] + .1481*ExpMovingAverage[EMA,Close,5,0,D,2]
+ .0988*ExpMovingAverage[EMA,Close,5,0,D,3] + .0659*ExpMovingAverage[EMA,Close,5,0,D,4]
+ .0439*ExpMovingAverage[EMA,Close,5,0,D,5] + .0293*ExpMovingAverage[EMA,Close,5,0,D,6]
+ .0195*ExpMovingAverage[EMA,Close,5,0,D,7] + .013*ExpMovingAverage[EMA,Close,5,0,D,8]
+ .0087*ExpMovingAverage[EMA,Close,5,0,D,9] + .0058*ExpMovingAverage[EMA,Close,5,0,D,10]
+ .0039*ExpMovingAverage[EMA,Close,5,0,D,11] + .0026*ExpMovingAverage[EMA,Close,5,0,D,12]
+ .0017*ExpMovingAverage[EMA,Close,5,0,D,13] + .0011*ExpMovingAverage[EMA,Close,5,0,D,14])
This formula can be used in comparison with price or other moving averages
for the purpose of running a backtest or for program trading. It can also
be used to create a custom indicator on a chart.
Here is an example using the formula in comparison with a five-day exponential
moving average. This can be used for backtesting or program trading.
Entry (Buy):
2 * ExpMovingAverage[EMA,Close,5,0,D] - (.3333*ExpMovingAverage[EMA,Close,5,0,D]
+ .2222*ExpMovingAverage[EMA,Close,5,0,D,1] + .1481*ExpMovingAverage[EMA,Close,5,0,D,2]
+ .0988*ExpMovingAverage[EMA,Close,5,0,D,3] + .0659*ExpMovingAverage[EMA,Close,5,0,D,4]
+ .0439*ExpMovingAverage[EMA,Close,5,0,D,5] + .0293*ExpMovingAverage[EMA,Close,5,0,D,6]
+ .0195*ExpMovingAverage[EMA,Close,5,0,D,7] + .013*ExpMovingAverage[EMA,Close,5,0,D,8]
+ .0087*ExpMovingAverage[EMA,Close,5,0,D,9] + .0058*ExpMovingAverage[EMA,Close,5,0,D,10]
+ .0039*ExpMovingAverage[EMA,Close,5,0,D,11] + .0026*ExpMovingAverage[EMA,Close,5,0,D,12]
+ .0017*ExpMovingAverage[EMA,Close,5,0,D,13] + .0011*ExpMovingAverage[EMA,Close,5,0,D,14])
> ExpMovingAverage[EMA,Close,5,0,D] AND 2 * ExpMovingAverage[EMA,Close,5,0,D,1]
- (.3333*ExpMovingAverage[EMA,Close,5,0,D,1] + .2222*ExpMovingAverage[EMA,Close,5,0,D,2]
+ .1481*ExpMovingAverage[EMA,Close,5,0,D,3] + .0988*ExpMovingAverage[EMA,Close,5,0,D,4]
+ .0659*ExpMovingAverage[EMA,Close,5,0,D,5] + .0439*ExpMovingAverage[EMA,Close,5,0,D,6]
+ .0293*ExpMovingAverage[EMA,Close,5,0,D,7]+ .0195*ExpMovingAverage[EMA,Close,5,0,D,8]
+ .013*ExpMovingAverage[EMA,Close,5,0,D,9] + .0087*ExpMovingAverage[EMA,Close,5,0,D,10]
+ .0058*ExpMovingAverage[EMA,Close,5,0,D,11] + .0039*ExpMovingAverage[EMA,Close,5,0,D,12]
+ .0026*ExpMovingAverage[EMA,Close,5,0,D,13] + .0017*ExpMovingAverage[EMA,Close,5,0,D,14]
+ .0011*ExpMovingAverage[EMA,Close,5,0,D,15]) <= ExpMovingAverage[EMA,Close,5,0,D,1]
Exit (Sell):
2 * ExpMovingAverage[EMA,Close,5,0,D] - (.3333*ExpMovingAverage[EMA,Close,5,0,D]
+ 0.2222*ExpMovingAverage[EMA,Close,5,0,D,1] + .1481*ExpMovingAverage[EMA,Close,5,0,D,2]
+ 0.0988*ExpMovingAverage[EMA,Close,5,0,D,3] + .0659*ExpMovingAverage[EMA,Close,5,0,D,4]
+ .0439*ExpMovingAverage[EMA,Close,5,0,D,5] + .0293*ExpMovingAverage[EMA,Close,5,0,D,6]
+ .0195*ExpMovingAverage[EMA,Close,5,0,D,7] + .013*ExpMovingAverage[EMA,Close,5,0,D,8]
+ .0087*ExpMovingAverage[EMA,Close,5,0,D,9] + .0058*ExpMovingAverage[EMA,Close,5,0,D,10]
+ .0039*ExpMovingAverage[EMA,Close,5,0,D,11] + .0026*ExpMovingAverage[EMA,Close,5,0,D,12]
+ .0017*ExpMovingAverage[EMA,Close,5,0,D,13] + .0011*ExpMovingAverage[EMA,Close,5,0,D,14])
< ExpMovingAverage[EMA,Close,5,0,D] AND 2 * ExpMovingAverage[EMA,Close,5,0,D,1]
- (.3333*ExpMovingAverage[EMA,Close,5,0,D,1] + 0.2222*ExpMovingAverage[EMA,Close,5,0,D,2]
+ .1481*ExpMovingAverage[EMA,Close,5,0,D,3] + 0.0988*ExpMovingAverage[EMA,Close,5,0,D,4]
+ .0659*ExpMovingAverage[EMA,Close,5,0,D,5] + .0439*ExpMovingAverage[EMA,Close,5,0,D,6]
+ .0293*ExpMovingAverage[EMA,Close,5,0,D,7]+ .0195*ExpMovingAverage[EMA,Close,5,0,D,8]
+ .013*ExpMovingAverage[EMA,Close,5,0,D,9] + .0087 * ExpMovingAverage[EMA,Close,5,0,D,10]
+ .0058*ExpMovingAverage[EMA,Close,5,0,D,11] + .0039*ExpMovingAverage[EMA,Close,5,0,D,12]
+ .0026*ExpMovingAverage[EMA,Close,5,0,D,13] + .0017*ExpMovingAverage[EMA,Close,5,0,D,14]
+ .0011*ExpMovingAverage[EMA,Close,5,0,D,15]) >= ExpMovingAverage[EMA,Close,5,0,D,1]
If you have questions about this formula or functionality, please call
TD Ameritrade's StrategyDesk help line at 800 228-8056, free of charge,
or access the Help Center via the StrategyDesk application. StrategyDesk
is a downloadable application free for all TD Ameritrade clients. Regular
commission rates apply.
TD Ameritrade and StrategyDesk do not endorse or recommend any particular
trading strategy.
--Jeff Anderson
TD AMERITRADE Holding Corp.
www.tdameritrade.com
GO BACK
NEOTICKER: THE QUEST FOR RELIABLE CROSSOVERS
We can use the NeoTicker formula language to implement moving average
calculations along with a simple trading system as presented in "The Quest
For Reliable Crossovers" by Sylvain Vervoort in this issue.
The indicator (Listing 1) has two parameters. The first is an integer
parameter for the period of the moving average calculation, with the default
set to 55. The second parameter is a string that can turn on the short
side of the system, since in the article, the author mentions this system
should trade the long side only. The following system code includes the
short side and uses the switch parameter to enable or disable the short
side. The default short side is disabled.
The stop loss is set to 10% of the entry bar range. The system uses
trial stops to take profit, and is set at 10% of the current bar range.
The indicator has three plot values. The first is current equity of
trading system, while the other two are the two moving averages (Figure
12).

FIGURE 12: NEOTICKER, TEMA CROSSOVER. The indicator has
three plot values. The first is current equity of trading system, while
the other two are the two moving averages.
This system code will be available at the NeoTicker blog site (blog.neoticker.com).
LISTING 1
$avg := param1; 'moving average period
'optional parameter to switch short signals for this system
$NoShortSide := paramis(2, "Yes");
'Moving average generation code
haOpen := ((O(1)+h(1)+l(1)+c(1))/4 + haOpen(1))/2;
haC := ((o(1)+h(1)+l(1)+c(1))/4 +
haOpen +
maxlist(h, haOpen) +
minlist(l, haOpen))/4;
TMA1 := tema(haC, $avg);
TMA2 := tema(TMA1, $avg);
ZlHa := TMA1+(TMA1-TMA2);
tyTMA1 := tema(typicalprice(data1), $avg);
tyTMA2 := tema(tyTMA1, $avg);
ZlCl := tyTMA1+(tyTMA1-tyTMA2);
'Corss over signals
$tradesignal := xcross(ZlCl, ZlHa);
'Rest of these code are NeoTicker trading system code
longatmarket ((openpositionflat > 0) and ($tradesignal > 0),
DefaultOrderSize,
"Entry long at long signal");
'stop lost
longexitstop (openpositionpl <= 0,
'10% bar range at entry bar is used as stop
openpositionentryprice -
(0.1*range((barsnum(0)-openpositionentrybar), data1)),
openpositionabssize,
"long stop lost");
'trial stop
longexitstop (openpositionpl > 0,
c-(0.1*range(data1)),
openpositionabssize,
"long trial stop");
'Check to see if short side has been disable before entering a short
shortatmarket ((openpositionflat > 0) and ($tradesignal < 0) and
($DisableShort = 1),
DefaultOrderSize,
"Entry short at short sgianl");
shortexitstop (openpositionpl <= 0,
openpositionentryprice +
(0.1*range((barsnum(0)-openpositionentrybar), data1)),
openpositionabssize,
"short stop lost");
shortexitstop (openpositionpl > 0,
c+(0.1*range(data1)),
openpositionabssize,
"short trial stop");
plot1 := currentequity;
plot2 := ZlHa;
plot3 := ZlCl;
--Kenneth Yuen
TickQuest Inc.
www.TickQuest.com
GO BACK
TRADE NAVIGATOR: THE QUEST FOR RELIABLE
CROSSOVERS
Many of the functions given in Sylvain Vervoort's article in this issue,
"The Quest For Reliable Crossovers," already exist in Trade Navigator.
We will point these out and also indicate the code used for the new indicators.
As per usual, you can download special file "SC0508.gzp" to get access
to all these functions.
All the functions are set up by going to the Edit menu and clicking
Functions. From the function list, click "New" to create a new one. After
the code has been pasted into the new function window, click "Save" and
then give the same name listed here.
The components are:
-
10-day exponential moving average (Ema)
-
Triple exponential moving average (Tema)
-
Tema based on heikin-ashi closing prices
-
Highlight bars representing buy and sell signals based on the crossing.
The exponential moving average is already built into Trade Navigator
software and is represented as MovingAvgX. The triple exponential moving
average is represented as TEMA.
Heikin-ashi bars can be applied to your chart as a study. To reference
the values in functions, use:
-
HeikinAshi Open
-
HeikinAshi High
-
HeikinAshi Low
-
HeikinAshi Close
Use the TradeSense syntax listed below for the remaining functions:
ZeroLagEMA:
MovingAvgX (expression , bars) + (MovingAvgX (expression , bars)
- MovingAvgX (MovingAvgX (expression , bars) , bars , False))
On the input tab, set the following as the default values:
Expression: Close
Bars: 7
ZeroLagTMA:
TEMA (expression , bars , False) + (TEMA (expression , bars , False)
- TEMA (TEMA (expression , bars , False) , bars , False))
On the input tab, set the following as the default values:
Expression: Close
Bars: 7
ZLCL:
TEMA (MovingAvg (Close , bars) , bars , False)
+ (TEMA (MovingAvg (Close , bars) , bars , False)
- TEMA (TEMA (MovingAvg (Close , bars) , bars , False) , bars , False))
On the input tab, set the following as the default values:
Bars: 7
ZLHA:
TEMA (HeikinAshi Close , bars , False)
+ (TEMA (HeikinAshi Close , bars , False)
- TEMA (TEMA (HeikinAshi Close , bars , False) , bars , False))
On the input tab, set the following as the default values:
Bars: 7
We'll then use all the functions above to produce our buy and sell signals,
represented as ZeroLagBuy and ZeroLagSell.
ZeroLagBuy:
Crosses Above (ZLCL (bars) , ZLHa (bars))
On the input tab, set the following as the default values:
Bars: 55
ZeroLagSell:
Crosses Above (ZLHa (bars) , ZLCL (bars))
On the input tab, set the following as the default values:
Bars: 55
Figure 13 shows the indicators on the ES-067 continuous contract.
The same template can be applied by clicking on the templates menu and
clicking "SC0508" after downloading the library.

FIGURE 13: TRADE NAVIGATOR. This chart demonstrates the
zero-lag buy and sell.
To download the special file, click on File and then Update Data.
Click Download Special File and type "SC0508." Click Start
and then follow through the upgrade prompts.
--Dave Kilman
Genesis Financial Technologies
http://www.GenesisFT.com
GO BACK
TRADINGSOLUTIOSN: THE QUEST FOR RELIABLE
CROSSOVERS
In "The Quest For Reliable Crossovers" in this issue, Sylvain Vervoort
discusses trading crossovers between the zero-lag TEMA of the typical price
and the zero-lag TEMA of his version of the heikin-ashi close. These functions
and the system are described below. They are also available as a function
file that can be downloaded from the TradingSolutions website (www.tradingsolutions.com)
in the Free Systems section. As with many indicators, these functions could
make good inputs to neural network predictions.
Function Name: Triple Exponential Moving Average
Short Name: TEMA
Inputs: Data, Period
Sub (Mult (EMA (Data, Period), 3),
Add (Mult (EMA (EMA (Data, Period), Period), 3),
EMA (EMA (EMA (Data, Period), Period), Period)))
Function Name: Heikin-Ashi Open (Vervoort)
Short Name: haOpenV
Inputs: Open, High, Low, Close, Period
Div (Add (Lag (Div (Add (Add (Open, High), Add (Low, Close)), 4), 1), Prev (1)),2)
Function Name: Heikin-Ashi Close (Vervoort)
Short Name: haCloseV
Inputs: Open, High, Low, Close, Period
Div (Add (Add (Div (Add (Add (Open, High),
Add (Low, Close)), 4), haOpenV (Open, High, Low, Close)),
Add (Max (High, haOpenV (Open, High, Low, Close)),
Min (Low, haOpenV (Open, High, Low, Close)))), 4)
Function Name: Zero-Lag EMA
Short Name: ZeroLagEMA
Inputs: Data, Period
Add (EMA (Data, Period), Sub (EMA (Data, Period), EMA (EMA (Data, Period), Period))
Function Name: Zero-Lag TEMA
Short Name: ZeroLagTEMA
Inputs: Data, Period
Add (TEMA (Data, Period), Sub (TEMA (Data, Period), TEMA (TEMA (Data, Period), Period))
Function Name: Zero-Lag Typical Price TEMA
Short Name: ZeroLagTPTEMA
Inputs: Close, High, Low, Period
Add (TEMA (Typical (Close, High, Low), Period),
Sub (TEMA (Typical (Close, High, Low), Period),
TEMA (TEMA (Typical (Close, High, Low), Period), Period)))
Function Name: Zero-Lag Heikin-Ashi TEMA
Short Name: ZeroLagHATEMA
Inputs: Open, High, Low, Close, Period
Add (TEMA (haCloseV (Open, High, Low, Close), Period),
Sub (TEMA (haCloseV (Open, High, Low, Close), Period),
TEMA (TEMA (haCloseV (Open, High, Low, Close), Period), Period)))
System Name: Zero-Lag TEMA Crossovers
Inputs: Open, High, Low, Close, Period
Enter Long: CrossAbove (ZeroLagTPTEMA(Close, High, Low, Period),
ZeroLagHATEMA(Open, High, Low, Close, Period))
Enter Short: CrossAbove (ZeroLagHATEMA(Open, High, Low, Close, Period),
ZeroLagTPTEMA(Close, High, Low, Period))
--Gary Geniesse
NeuroDimension, Inc.
800 634-3327, 352 377-5144
http://www.tradingsolutions.com
GO BACK
SWINGTRACKER: TEMA OVERLAY
The zero-lagging TEMA overlay has been introduced in SwingTracker 5.13.088
based on Sylvain Vervoort's article in this issue, "The Quest For Reliable
Crossovers."
The indicator can be calculated on either the closing price, typical
price, or heikin-ashi price. Several instances of the overlay can be added
to the chart with different parameters in order to see the buy/sell signals
generated by the crossovers.
A sample chart is shown in Figure 14. A sample chart parameters window
is shown in Figure 15.

FIGURE 14: SWINGTRACKER, TRIPLE EXPONENTIAL MOVING AVERAGE.
Here is a sample chart of the zero-lagging TEMA overlay.

FIGURE 15: SWINGTRACKER, CHART PARAMETERS
To discuss these tools, please visit our user forum at forum.mrswing.com.
If you need assistance, our development staff can help at support.mrswing.com.
For more information on our free trial, visit www.swingtracker.com.
--Larry Swing
+1 (281) 968-2718
theboss@mrswing.com
www.mrswing.com
GO BACK
VT TRADER: CROSSOVER TRADING SYSTEM
Sylvain Vervoort's article in this issue, "The Quest For Reliable Crossovers,"
discusses the use of two "zero-lag" triple exponential moving averages
and volatility-based stops to create a simple moving average-style crossover
trading system.
For added flexibility, we've expanded on Vervoort's idea of volatility-based
stops by allowing the user to choose between pip-based stops or volatility-
(that is, ATR) based stops.
The VT Trader code and instructions for recreating Vervoort's TEMA crossover
trading system are as follows:
Zero-lag Tema crossover trading system
1. Navigator Window>Tools>Trading Systems Builder>[New] button
2. In the Indicator Bookmark, input the following text for each field:
Name: TASC - 05/2008 - "The Quest for Reliable Crossovers"
Short Name: vt_TQFRC
Label Mask: TASC - 05/2008 - "The Quest for Reliable Crossovers"
(ShortTEMA: %pr1%, %tp1% | LongTEMA: %pr2%, %tp2% |
Initial Stoploss: %InitialStoplossMode:ls%, %InitialStoplossType:ls% |
Trailing Stoploss: %TrailingStoplossMode:ls%, %TrailingStoplossType:ls%)
3. In the Input Bookmark, set up the following variables:
[New] button... Name: pr1 , Display Name: Short TEMA Price , Type: price , Default: Typical Price
[New] button... Name: tp1 , Display Name: Short TEMA Periods , Type: integer , Default: 55
[New] button... Name: pr2 , Display Name: Long TEMA Price , Type: price , Default: haClose
[New] button... Name: tp2 , Display Name: Long TEMA Periods , Type: integer , Default: 55
[New] button... Name: InitialStoplossMode , Display Name: Enable Initial Stoploss? ,
Type: Enumeration , Default: Click [...] button -> Click [New] button ->
Type "Yes" -> Click [New] button -> Type "No" -> Click [OK] button; Default: Yes
[New] button... Name: InitialStoplossType , Display Name: Initial Stoploss Type? ,
Type: Enumeration , Default: Click [...] button -> Click [New] button ->
Type "ATR_Based" -> Click [New] button -> Type "Pip_Based" ->
Click [OK] button; Default: ATR_Based
[New] button... Name: InitialStoploss , Display Name: Initial Stoploss (in Pips) ,
Type: integer , Default: 20
[New] button... Name: ATRper1 , Display Name: ATR Periods (if ATR Initial Stoploss) ,
Type: integer , Default: 10
[New] button... Name: atrmultiplier1 , Display Name: ATR Multiplier (if ATR Initial Stoploss) ,
Type: float , Default: 3.0000
[New] button... Name: TrailingStoplossMode , Display Name: Enable Trailing Stoploss? ,
Type: Enumeration , Default: Click [...] button -> Click [New] button ->
Type "Yes" -> Click [New] button -> Type "No" -> Click [OK] button; Default: Yes
[New] button... Name: TrailingStoplossType , Display Name: Trailing Stoploss Type? ,
Type: Enumeration , Default: Click [...] button -> Click [New] button ->
Type "ATR_Based" -> Click [New] button -> Type "Pip_Based" ->
Click [OK] button; Default: ATR_Based
[New] button... Name: TrailingStoploss , Display Name: Trailing Stoploss (in Pips) ,
Type: integer , Default: 20
[New] button... Name: ATRper , Display Name: ATR Periods (if ATR Trailing Stoploss) ,
Type: integer , Default: 10
[New] button... Name: atrmultiplier , Display Name: ATR Multiplier (if ATR Trailing Stoploss) ,
Type: float , Default: 3.0000
4. In the Output Bookmark, create the following variables:
[New] button...
Var Name: ShortTEMA
Name: Short TEMA
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: green
Line Width: thin
Line Style: solid
Placement: Price Frame
[OK] button...
[New] button...
Var Name: LongTEMA
Name: Long MA
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: red
Line Width: thin
Line Style: solid
Placement: Price Frame
[OK] button...
[New] button...
Var Name: DisplayLongEntryInitialStop
Name: Long Entry Initial Stoploss
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: blue
Line Width: slightly thicker
Line Style: solid
Placement: Price Frame
[OK] button...
[New] button...
Var Name: DisplayLongEntryTrailingStop
Name: Long Entry Trailing Stoploss
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: blue
Line Width: thin
Line Style: dashed
Placement: Price Frame
[OK] button...
[New] button...
Var Name: DisplayShortEntryInitialStop
Name: Short Entry Initial Stoploss
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: red
Line Width: slightly thicker
Line Style: solid
Placement: Price Frame
[OK] button...
[New] button...
Var Name: DisplayShortEntryTrailingStop
Name: Short Entry Trailing Stoploss
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: red
Line Width: thin
Line Style: dashed
Placement: Price Frame
[OK] button...
[New] button...
Var Name: LongEntrySignal
Name: LongEntrySignal
Description: Long Entry Signal Alert
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font [...]: Up Arrow
Size: Medium
Color: Blue
Symbol Position: Below price plot
Select Alerts Bookmark
Alerts Message: Long Entry Signal!
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: LongExitSignal
Name: LongExitSignal
Description: Long Exit Signal Alert
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font [...]: Exit Sign
Size: Medium
Color: Blue
Symbol Position: Above price plot
Select Alerts Bookmark
Alerts Message: Long Exit Signal!
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: ShortEntrySignal
Name: ShortEntrySignal
Description: Short Entry Signal Alert
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font [...]: Down Arrow
Size: Medium
Color: Red
Symbol Position: Above price plot
Select Alerts Bookmark
Alerts Message: Short Entry Signal!
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: ShortExitSignal
Name: ShortExitSignal
Description: Short Exit Signal Alert
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font [...]: Exit Sign
Size: Medium
Color: Red
Symbol Position: Below price plot
Select Alerts Bookmark
Alerts Message: Short Exit Signal!
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: OpenBuy
Name: OpenBuy
Description: Automated Open Buy Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Buy
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
[New] button...
Var Name: CloseBuy
Name: CloseBuy
Description: Automated Close Buy Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Sell
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
[New] button...
Var Name: OpenSell
Name: OpenSell
Description: Automated Open Sell Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Sell
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
[New] button...
Var Name: CloseSell
Name: CloseSell
Description: Automated Close Sell Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Buy
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
5. In the Formula Bookmark, copy and paste the following formula:
{Provided By: Capital Market Services, LLC & Visual Trading Systems, LLC (c) Copyright 2008}
{Description: May 2008 Issue - The Quest For Reliable Crossovers by Sylvain Vervoort}
{vt_TQFRC Version 1.0}
{Control Error}
Barnum:= BarCount();
Err:= (tp1=0) or (tp2=0);
{Zero-Lag TEMA's}
ShortTEMA1:= vt_TEMA(pr1,tp1,E);
ShortTEMA2:= vt_TEMA(ShortTEMA1,tp1,E);
ShortTEMADiff:= ShortTEMA1 - ShortTEMA2;
ShortTEMA:= ShortTEMA1 + ShortTEMADiff;
LongTEMA1:= vt_TEMA(pr2,tp2,E);
LongTEMA2:= vt_TEMA(LongTEMA1,tp2,E);
LongTEMADiff:= LongTEMA1 - LongTEMA2;
LongTEMA:= LongTEMA1 + LongTEMADiff;
{Define Final Trade Entry/Exit Criteria}
LongEntrySetup:= Cross(ShortTEMA,LongTEMA);
LongExitSetup:= Cross(LongTEMA,ShortTEMA);
ShortEntrySetup:= Cross(LongTEMA,ShortTEMA);
ShortExitSetup:= Cross(ShortTEMA,LongTEMA);
{Determine the Pip Value for the currency chart being used}
_SymbolPoint:= SymbolPoint();
_InitialStoploss:= InitialStoploss * _SymbolPoint;
_TrailingStoploss:= TrailingStoploss * _SymbolPoint;
{Define Final Entry and Exit Criteria}
LongEntrySignal:= (NOT Err AND LongTradeAlert=0 AND ShortTradeAlert=0 AND LongEntrySetup) OR
(NOT Err AND LongTradeAlert=0 AND Cross(0.5,ShortTradeAlert) AND LongEntrySetup) OR
(NOT Err AND LongTradeAlert=0 AND ShortExitSetup);
LongEntryPrice:= valuewhen(1,LongEntrySignal,C);
BarsSinceLongEntry:= BarsSince(LongEntrySignal);
LongEntryPipInitialStop:= if(LongTradeAlert=1 OR LongEntrySignal OR
LongExitSignal, LongEntryPrice - _InitialStoploss, null);
LongEntryATRInitialStop:= if(LongTradeAlert=1 OR LongEntrySignal OR LongExitSignal, valuewhen(1,LongEntrySignal,H)
- valuewhen(1,LongEntrySignal,(ATR(ATRper1) * atrmultiplier1)), null);
DisplayLongEntryInitialStop:= if(InitialStoplossMode=0 AND InitialStoplossType=1, LongEntryPipInitialStop,
if(InitialStoplossMode=0 AND InitialStoplossType=0, LongEntryATRInitialStop, null));
LongEntryPipTrailingStop:= if(LongTradeAlert=1 OR LongEntrySignal OR LongExitSignal,
max((C - _TrailingStoploss), PREV(LongEntryPrice - _TrailingStoploss)), null);
LongEntryATRTrailingStop:= if((LongTradeAlert=1 OR LongEntrySignal OR LongExitSignal),
max(HHV(H,BarsSinceLongEntry) - (ATR(ATRper) * atrmultiplier),
PREV(valuewhen(1,LongEntrySignal,H) - valuewhen(1,LongEntrySignal,(ATR(ATRper)
* atrmultiplier)))), null);
DisplayLongEntryTrailingStop:= if(TrailingStoplossMode=0 AND TrailingStoplossType=1, LongEntryPipTrailingStop,
if(TrailingStoplossMode=0 AND TrailingStoplossType=0, LongEntryATRTrailingStop, null));
LongExitSignal:= (LongTradeAlert=1 AND InitialStoplossMode=0 AND InitialStoplossType=1 AND Cross(LongEntryPipInitialStop,C))
OR (LongTradeAlert=1 AND InitialStoplossMode=0 AND InitialStoplossType=0 AND Cross(LongEntryATRInitialStop,C))
OR (LongTradeAlert=1 AND TrailingStoplossMode=0 AND TrailingStoplossType=1 AND Cross(LongEntryPipTrailingStop,C))
OR (LongTradeAlert=1 AND TrailingStoplossMode=0 AND TrailingStoplossType=0 AND Cross(LongEntryATRTrailingStop,C))
OR (LongTradeAlert=1 AND LongExitSetup);
LongExitPrice:= valuewhen(1,LongExitSignal,C);
ShortEntrySignal:= (NOT Err AND ShortTradeAlert=0 AND LongTradeAlert=0 AND ShortEntrySetup) OR
(NOT Err AND ShortTradeAlert=0 AND Cross(0.5,LongTradeAlert) AND ShortEntrySetup) OR
(NOT Err AND ShortTradeAlert=0 AND LongExitSetup);
ShortEntryPrice:= valuewhen(1,ShortEntrySignal,C);
BarsSinceShortEntry:= BarsSince(ShortEntrySignal);
ShortEntryPipInitialStop:= if(ShortTradeAlert=1 OR ShortEntrySignal OR ShortExitSignal,
ShortEntryPrice + _InitialStoploss, null);
ShortEntryATRInitialStop:= if(ShortTradeAlert=1 OR ShortEntrySignal OR ShortExitSignal,
valuewhen(1,ShortEntrySignal,L) + valuewhen(1,ShortEntrySignal,(ATR(ATRper1)
* atrmultiplier1)), null);
DisplayShortEntryInitialStop:= if(InitialStoplossMode=0 AND InitialStoplossType=1, ShortEntryPipInitialStop,
if(InitialStoplossMode=0 AND InitialStoplossType=0, ShortEntryATRInitialStop, null));
ShortEntryPipTrailingStop:= if(ShortTradeAlert=1 OR ShortEntrySignal OR ShortExitSignal,
min((C + _TrailingStoploss), PREV(ShortEntryPrice + _TrailingStoploss)), null);
ShortEntryATRTrailingStop:= if(ShortTradeAlert=1 OR ShortEntrySignal OR ShortExitSignal,
min(LLV(L,BarsSinceShortEntry) + (ATR(ATRper) * atrmultiplier),
PREV(valuewhen(1,ShortEntrySignal,L) + valuewhen(1,ShortEntrySignal,(ATR(ATRper)
* atrmultiplier)))), null);
DisplayShortEntryTrailingStop:= if(TrailingStoplossMode=0 AND TrailingStoplossType=1, ShortEntryPipTrailingStop,
if(TrailingStoplossMode=0 AND TrailingStoplossType=0, ShortEntryATRTrailingStop, null));
ShortExitSignal:= (ShortTradeAlert=1 AND InitialStoplossMode=0 AND InitialStoplossType=1 AND Cross(C,ShortEntryPipInitialStop))
OR (ShortTradeAlert=1 AND InitialStoplossMode=0 AND InitialStoplossType=0 AND Cross(C,ShortEntryATRInitialStop))
OR (ShortTradeAlert=1 AND TrailingStoplossMode=0 AND TrailingStoplossType=1 AND Cross(C,ShortEntryPipTrailingStop))
OR (ShortTradeAlert=1 AND TrailingStoplossMode=0 AND TrailingStoplossType=0 AND Cross(C,ShortEntryATRTrailingStop))
OR (ShortTradeAlert=1 AND ShortExitSetup);
ShortExitPrice:= valuewhen(1,ShortExitSignal,C);
{Simulated Open Trade Determination and Trade Direction}
LongTradeAlert:= SignalFlag(LongEntrySignal,LongExitSignal);
ShortTradeAlert:= SignalFlag(ShortEntrySignal,ShortExitSignal);
{Create Auto-Trading Functionality}
OpenBuy:= LongEntrySignal and (eventCount('OpenBuy')=eventCount('CloseBuy'));
CloseBuy:= LongExitSignal and (eventCount('OpenBuy')>eventCount('CloseBuy'));
OpenSell:= ShortEntrySignal and (eventCount('OpenSell')=eventCount('CloseSell'));
CloseSell:= ShortExitSignal and (eventCount('OpenSell')>eventCount('CloseSell'));
6. Click the "Save" icon to finish building Vervoort's Tema crossover trading system. (See Figure 16.)
FIGURE 16: VT TRADER, VERVOORT'S TEMA CROSSOVER SYSTEM. Here is the
trading system attached to a EUR/USD one-hour candle chart.
To attach the trading system to a chart, select the "Add trading
system" option from the chart's contextual menu, select "TASC - 05/2008
- 'The Quest for Reliable Crossovers'" from the trading systems list, and
click the [Add] button.
To learn more about VT Trader, please visit www.cmsfx.com.
--Chris Skidmore
CMS Forex
(866) 51-CMSFX, trading@cmsfx.com
www.cmsfx.com
GO BACK
Return to May 2008 Contents
Originally published in the May 2008 issue of Technical Analysis
of STOCKS & COMMODITIES magazine. All rights reserved. © Copyright
2008, Technical Analysis, Inc.
|