Professional Documents
Culture Documents
TRADERS' TIPS - December 2008
TRADERS' TIPS - December 2008
TRADERS' TIPS - December 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.
variables:
BodySize( 0 ),
Outline( 0 ),
HaCValue( 0 ),
HaOpenValue( 0 ),
TMA1( 0 ),
TMA2( 0 ),
TMADiff( 0 ),
ZlHa( 0 ),
ZlCl( 0 ),
ZlDiff( 0 ),
Z1DiffPos( false ),
HABasic( false ),
DiffAndLastBasic( false ),
UpSigns( false ),
NoDojiReverse( false ),
GreenBar( false ),
Color( 0 ),
ColorW( 0 ) ;
Once
begin
switch BodyWidth
begin
case 2:
BodySize = 1 ;
case > 4:
BodySize = 4 ;
default:
BodySize = BodyWidth ;
end ;
switch BodySize
begin
case 0:
Outline = 2 ;
case 1:
Outline = 3 ;
case 3:
Outline = 4 ;
default:
Outline = 5 ;
end ;
end ;
HaCValue = HaC ;
HaOpenValue = HaOpen ;
{ trend determination }
Z1DiffPos = ZlDiff >= 0 ;
{ if prior bar was Green, then make this one green too }
DiffAndLastBasic = Z1DiffPos and HABasic[1] ;
if GreenBar then
begin
ColorW = UpTrendColor ;
end
else
begin
ColorW = DnTrendColor ;
end ;
Function: HaC
HaC = 0.25 * ( AvgPrice + HaOpen + MaxList( High,
HaOpen ) + MinList( Low, HaOpen ) ) ;
Function: HaOpen
HaOpen = 0.5 * ( AvgPrice[1] + HaOpen[1] ) ;
--Mark Mills
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
www.TradeStation.com
BACK TO LIST
Strategy Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;
namespace WealthLab.Strategies
{
public class HACO_Demo : WealthScript
{
// Create parameter sliders
public HACO_Demo()
{
TemaPeriod = CreateParameter("TEMA Period", 34, 10, 120, 1);
timeoutPeriod = CreateParameter("Timeout", 2, 1, 3, 1);
}
--Eugene
www.wealth-lab.com
BACK TO LIST
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 );
// up average
ZlHa = ZeroLagTEMA( HaClose, avp );
ZlCl = ZeroLagTEMA( ( H + L ) / 2, avp );
ZlDif = ZlCl - ZlHa;
// dn average
ZlHa = ZeroLagTEMA( HaClose, avpdn );
ZlCl = ZeroLagTEMA( ( H + L ) / 2, avpdn );
ZlDif = ZlCl - ZlHa;
keep1 = Hold( HaClose < HaOpen, 2 );
keep2 = ZlDif < 0;
keeping = keep1 OR keep2;
keepall = keeping OR ( Ref( keeping, -1 ) AND ( C < O ) OR C < Ref( C, -1 ) );
keep3 = abs( C - O ) < ( H - L ) * 0.35 AND L <= Ref( H, -1 );
dtr = keepall OR ( Ref( keepall, -1 ) AND keep3 );
BACK TO LIST
Description:
Heikin-Ashi Candelstick Oscillator (HACO)
Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.
function preMain() {
setPriceStudy(true);
setShowCursorLabel(false);
setShowTitleParameters( false );
setStudyTitle("Heikin-Ashi Candelstick Oscillator");
setDefaultBarBgColor(Color.white, 0);
var x=0;
fpArray[x] = new FunctionParameter("UpColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Long Positions Color");
setDefault(Color.RGB(160, 255, 160));
}
fpArray[x] = new FunctionParameter("DnColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Short Positions Color");
setDefault(Color.RGB(255,160,160));
}
fpArray[x] = new FunctionParameter("Avg", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Up TEMA Average Length");
setLowerLimit(1);
setDefault(34);
}
fpArray[x] = new FunctionParameter("Avgdn", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Down TEMA Average Length");
setLowerLimit(1);
setDefault(34);
}
}
if (nState == BARSTATE_NEWBAR) {
bkeeping_Ref = bkeeping;
bkeepall_Ref = bkeepall;
bkeeping1_Ref = bkeeping1;
bkeepall1_Ref = bkeepall1;
butr_Ref = butr;
bdtr_Ref = bdtr;
nhaOpen_Ref = nhaOpen;
nRef = nRes;
}
nTMA1 = xTMA1.getValue(0);
nTMA2 = xTMA2.getValue(0);
nTMA1_hl2 = xTMA1_hl2.getValue(0);
nTMA2_hl2 = xTMA2_hl2.getValue(0);
nDiff = nTMA1 - nTMA2;
nZlHa = nTMA1 + nDiff;
nDiff = nTMA1_hl2 - nTMA2_hl2;
nZlCl = nTMA1_hl2 + nDiff;
nZlDif = nZlCl - nZlHa;
bkeep1 = Alert1(xhaC, xhaOpen, 2);
if (nZlDif >= 0)
bkeep2 = true
else
bkeep2 = false;
if (bkeep1 || bkeep2)
bkeeping1 = true
else
bkeeping1 = false;
if (bkeeping1 || (bkeeping1_Ref && (close(0) >= open(0)) || close(0) >= close(-1)))
bkeepall1 = true
else
bkeepall1 = false;
if (Math.abs(close(0) - open(0)) < (high(0) - low(0)) * 0.35 && high(0) >= low(-1))
bkeep3 = true
else
bkeep3 = false;
if (bkeepall1 || (bkeepall1_Ref && bkeep3))
butr = true;
else
butr = false;
nTMA1 = xTMA1_2.getValue(0);
nTMA2 = xTMA2_2.getValue(0);
nTMA1_hl2 = xTMA1_hl2_2.getValue(0);
nTMA2_hl2 = xTMA2_hl2_2.getValue(0);
nDiff = nTMA1 - nTMA2;
nZlHa = nTMA1 + nDiff;
nDiff = nTMA1_hl2 - nTMA2_hl2;
nZlCl = nTMA1_hl2 + nDiff;
nZlDif = nZlCl - nZlHa;
bkeep1 = Alert2(xhaC, xhaOpen, 2);
if (nZlDif < 0)
bkeep2 = true
else
bkeep2 = false;
if (Math.abs(close(0) - open(0)) < (high(0) - low(0)) * 0.35 && low(0) <= high(-1))
bkeep3 = true;
else
bkeep3 = false;
if (bkeep1 || bkeep2)
bkeeping = true;
else
bkeeping = false;
if (bkeeping || (bkeeping_Ref && (close(0) < open(0)) || close(0) < close(-1)))
bkeepall = true
else
bkeepall = false;
if(bkeepall || (bkeepall_Ref && bkeep3) == true)
bdtr = true
else
bdtr = false;
if (bdtr == false && bdtr_Ref && butr)
nupw = 1
else
nupw = 0;
if (butr == false && butr_Ref && bdtr)
ndnw = 1
else
ndnw = 0;
if (nupw == 1)
nRes = 1
else
if(ndnw == 1)
nRes = 0
else
nRes = nRef;
if (nRes == 1)
setDefaultBarBgColor(UpColor, 0);
else
if (nRes == 0)
setDefaultBarBgColor(DnColor, 0);
return;
}
function Calc_haOpen(xOHLC4) {
var nRes = 0;
var nRef = ref(-1);
if (nRef == null) nRef = 1;
if (xOHLC4.getValue(-1) == null) return;
nRes = (xOHLC4.getValue(-1) + nRef) / 2;
if (nRes == null) return;
return nRes;
}
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=http://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;
}
--Jason Keck
eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignalcentral.com
BACK TO LIST
After moving the MetaStock code given in the article to your preferred compiler, you can insert
the resulting heikin-ashi candlestick oscillator (H ) indicators into a chart (see Figure 5) as
follows:
1. Select "New Indicator …" from the Insert menu.
2. Choose the External Program & Library Calls category.
3. Select the appropriate External Dll Call indicator.
4. Set up the parameters to match your Dll and select "Indicator output is a Boolean value."
5. Select the Finished button.
To create a heikin-ashi candlestick oscillator–based reversal trading system, select "New Trading
Strategy …" from the Insert menu and enter the following in the appropriate locations of the
Trading Strategy Wizard:
Buy Long Market order if all of the following are true:
HACO( Open, High, Low, Close, 34, 34 )
If you have NeuroShell Trader Professional, you can also choose whether the system parameters
should be optimized.
After backtesting the trading strategies, use the "Detailed Analysis…" button to view the backtest
and trade-by-trade statistics for the trading strategy.
Users of NeuroShell Trader can go to the S C section of the NeuroShell Trader
free technical support website to download a copy of this or any past Traders' Tips.
--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com
BACK TO LIST
NEOTICKER: HEIKIN-ASHI CANDLESTICK OSCILLATOR
In the article "Trading With The Heikin-Ashi Candlestick Oscillator" in this issue, author Sylvain
Vervoort uses heikin-ashi candle rules to highlight trend changes in price bars. This coloring
algorithm can be implemented in NeoTicker using formula language.
The formula indicator is called "T Uptrend HA" (Listing 1) with one parameter, avg, that
allows the user to adjust the number of periods that T is calculated (the default is 34). This
indicator plots vertical color bars that mark the highs and lows of the underlying data series
(Figure 6).
The H oscillator and background coloring can be produced from the same indicator code by
changing the plot value settings (refer to NeoTicker blog site for details).
A downloadable version of this indicator will be available at the NeoTicker blog site
(http://blog.neoticker.com).
LISTING 1
$avg := param1;
haOpen := ((O(1)+H(1)+L(1)+C(1))/4 + haOpen(1))/2;
haC := ((O+H+L+C)/4+haOpen+maxlist(H,haOpen)+minlist(L,haOpen))/4;
TMA1 := tema(haC,$avg);
TMA2 := tema(TMA1,$avg);
$myDiff := TMA1-TMA2;
$ZlHa := TMA1+$myDiff;
TMA1 := tema(((h+l)/2), $avg);
TMA2 := tema(TMA1, $avg);
$myDiff := TMA1-TMA2;
$ZlCl := TMA1+$myDiff;
$ZlDif := $ZlCl-$ZlHa;
$keep1 := (haC(1)>=haOpen(1)) and (haC>=haOpen);
$keep2 := $ZlDif>=0;
keeping := $keep1>0 or $keep2>0;
keepall := keeping>0 or (keeping(1)>0 and C>=O or C>=C(1));
$keep3 := absvalue(C-O)<((H-L)*0.35) and H>=L(1);
utr := keepall>0 or (keepall(1)>0 and $keep3>0);
$keep1 := (haC(1)<0;
$keep3 := (absvalue(C-O)<(H-L)*0.35) and L<=H(1);
keeping := $keep1>0 or $keep2>0;
keepall := keeping>0 or (keeping(1)>0 and C0) or (keepall(1)>0 and C0) and (utr>0);
$dnw := (utr=0) and (utr(1)>0) and (dtr>0);
plot1 := h;
plot2 := l;
plot3 := choose($upw>0, clgreen,$dnw>0, clred, plot3(1));
success1 := barsnum(0) > $avg;
success2 := barsnum(0) > $avg;
success3 := barsnum(0) > $avg;
<O or C>0) or (keepall(1)>0 and C0) and (utr>0);
$dnw := (utr=0) and (utr(1)>0) and (dtr>0);
plot1 := h;
plot2 := l;
plot3 := choose($upw>0, clgreen,$dnw>0, clred, plot3(1));
success1 := barsnum(0) > $avg;
success2 := barsnum(0) > $avg;
success3 := barsnum(0) > $avg;
BACK TO LIST
! CODING ABBREVIATIONS:
H is [high].
H1 is valresult(H,1).
L is [low].
L1 is valresult(L,1).
C is [close].
C1 is valresult(C,1).
O is [open].
V is [volume].
! INPUTS:
emaLen is 34.
!-------------------------HEIKIN-ASHI-----------------------------------
haC is (O + H +L + C) / 4.
haH is Max(H,max(haO,haC)).
haL is Min(L,min(haO,haC)).
!---------------------end HEIKIN-ASHI---------------------------------
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.
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.
endRes is iff(end,0,res).
res is iff(upw,1,iff(dnw,0,valresult(endRes,1))).
--Richard Denning
For AIQ Systems
richard.denning@earthlink.net
BACK TO LIST
'xmaLen = 34
'green candle: startWith = 1
'red candle: startWith = 0
Dim haC As BarArray
Dim haO As BarArray
Dim haH As BarArray
Dim haL As BarArray
Dim haCL As BarArray
haC = (O+H+L+C)/4
haO = IIF(BarNumber = FirstBar,O,(haO[1] + haC[1])/2)
haH = Max(H,haO)
haL = Min(L,haO)
haCL = (haC+haO+haH+haL)/4
If res = 1 Then
barcolor(0) = vbGreen
Else
barcolor(0) = vbRed
End If
End Sub
--Richard Denning
For TradersStudio
richard.denning@earthlink.net
BACK TO LIST
STRATASEARCH: HEIKIN-ASHI CANDLESTICK OSCILLATOR
In "Trading With The Heikin-Ashi Candlestick Oscillator" in this issue, author Sylvain Vervoort
gives us a helpful way to trade candlestick patterns. Using the traditional heikin-ashi pattern as a
base, we have a complete indicator that provides a good foundation for further exploration.
Using the H indicator on its own, the results proved to be a good starting point. The indicator
did a good job of letting the winning trades continue while cutting the losing trades short. The
system also produced a large number of trades, which is helpful for additional filtering. However,
profitability per trade was rather low, running about 40% for the N 100 and S&P 500
components from 2004 to 2007.
In a separate test, the H was run alongside a variety of supporting trading rules. In just a short
time, we were able to improve profitability per trade, increase the returns, and cut the holding
periods nearly in half. Thus, the Haco can greatly benefit from the use of supporting indicators.
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 the benefits of using this indicator alongside other
trading rules.
See Figure 9 for a sample chart.
Editor's note: The Strata-Search code is not shown here but can be found at our website at
www.traders.com in the Traders' Tips area.
--Pete Rast
Avarin Systems, Inc.
www.StrataSearch.com
BACK TO LIST
The H chart in Figure 10 can be added to your layout by clicking the Share menu in
StockFinder and searching for "H " on the chart tab. This chart implements Sylvain Vervoort's
heikin-ashi candlestick oscillator (H ) as a StockFinder rule used to shade the chart's
background either red or green.
Eight additional rules are also included on this chart that implement the four stages of the green
candle and red candle expert functions presented in the article. You can drag and drop these rules
onto the price history plot to paint it the correct colors using these conditions. You can also choose
which rule-based paint brushes are applied as well as the priority of how these rules are applied in
the colors tab of price history. This allows you to follow along with the article to see how the
various steps in the evolution of the green candles and red candles from the article would affect
how the symbol you are looking at would be colored.
Here's an example of the RealCode used to implement the first version of the green candle as a
rule in StockFinder:
RealCode:
'Green Candle v1
Static haOpen As Single
Static haC As Single
If isFirstBar Then
haOpen = Price.Open
Else
haOpen = (haOpen+(Price.Open(1)+Price.High(1)+Price.Low(1)+Price.Last(1))/4)/2
End If
haC = ((Price.Open+Price.High+Price.Low+Price.Last)/4+haOpen+ _
System.Math.Max(Price.High,haOpen)+System.Math.Min(Price.Low,haOpen))/4
If haC >= haOpen Then Pass
For more information or to start your free trial, please visit www.StockFinder.com.
--Bruce Loebrich and Patrick Argo
Worden Brothers, Inc.
BACK TO LIST
We'll be offering the H indicator for download in our client forums. The VT Trader code and
instructions for creating the H indicator are as follows:
The heikin-ashi candlestick oscillator
2. In the Indicator Bookmark, type the following text for each field:
[New] button... Name: avg , Display Name: Up TEMA average , Type: integer , Default: 34
[New] button... Name: avgdn , Display Name: Down TEMA average , Type: integer, Default: 34
[New] button...
Name: (HACO)
{Provided By: Capital Market Services, LLC & Visual Trading Systems, LLC (c) Copyright 2008}
{Description: December 2008 Issue - Trading with the Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort}
{Uptrend}
UpTMA1:= vt_TEMA(haC,avg,E);
UpTMA2:= vt_TEMA(UpTMA1,avg,E);
UpTMA1_2:= vt_TEMA((H+L)/2,avg,E);
UpTMA2_2:= vt_TEMA(UpTMA1_2,avg,E);
Upkeep1:= SignalHold(haC>=haO,2);
Upkeep2:= UpZlDif>=0;
{Downtrend}
DownTMA1:= vt_TEMA(haC,avgdn,E);
DownTMA2:= vt_TEMA(DownTMA1,avgdn,E);
DownTMA1_2:= vt_TEMA((H+L)/2,avgdn,E);
DownTMA2_2:= vt_TEMA(DownTMA1_2,avgdn,E);
Downkeep1:= SignalHold(haC<haO,2);
Downkeep2:= DownZlDif<0;
{HACO}
HACO:= If(upw,1,If(dnw,0,PREV(0)));
To attach the indicator to a chart, activate the chart window's contextual menu and select "Add
Indicator." Select "12/2008 - Heikin-Ashi Candlestick Oscillator (HACO)" from the indicator list
and click [Add].
To learn more about VT Trader, visit www.cmsfx.com.
--Chris Skidmore
Visual Trading Systems, LLC (courtesy of CMS Forex)
(866) 51-CMSFX, trading@cmsfx.com
www.cmsfx.com
BACK TO LIST
BACK TO LIST
Provided by:
Trade Ideas (copyright (c) Trade Ideas LLC 2008). All rights reserved. This sample
Trade Ideas strategy is for educational purposes only and may be modified to
further reflect a trading plan. Remember these are sketches meant to give an
idea how to model a trading plan. Use this 'as is' or modify it as many others
do. Know, however, that Trade-Ideas.com and all individuals affiliated with this
site assume no responsibilities for trading and investment results.
Copy this string directly into Trade-Ideas PRO using the "Collaborate" feature
(right-click in any strategy window)(spaces represent an underscore if typing):
http://www.trade-ideas.com/View.php?O=20000000000000000000000_1D_0&QRUI=2&MaxDNbbo=
0.1&MaxSpread=10&MinDia15=0.1&MinMA50R=1&MinPUp15=0.2&MinPrice=5&MinQqqq15=
0.1&MinSpy15=0.1&MinVol=500000&MinVol15=200&WN=SHORT+-+Rising+Faster+Than+Mkt+Above
+50+Day+SMA+-+Hold+120m+-+Start+30+After+Open+End+30+B4+-+SL+0.75+-+Exit+on+50+SMA+
Cross+
The strategy's filters stipulate that all three major indices (N , S&P, D ) must be up by
0.1% over a 15-minute period. Then, in order to ensure all the stocks are rising faster than the
markets, candidates must be up 0.2% over the last 15-minute period. Finally, the strategy stipulates
that all stocks must be one volatility bar above the 50-day S . This allows us to honor the exit
strategy of leaving when the stock dips below the 50 day S .
Given these filtered conditions, the strategy only produces an alert if a stock in this universe starts
running 200% (2 as a ratio) faster than normal.
Where one alert and 10 filters are used with the following specific settings:
Running Up Intermediate: 2 (run rate ratio)
Min Price = 5 ($)
Max Spread = 5 (pennies)
Min Distance from Inside Market = 0.1 (%)
Min Daily Volume = 500,000 (shares/day)
Min Volume 15 Minute Candle = 200 (%)
Min Up 15 Minute Candle = 0.2 (%)
Min NASDAQ Up 15 Minute Candle = 0.1 (%)
Min S&P Up 15 Minute Candle = 0.1 (%)
Min Dow Up 15 Minute Candle = 0.1 (%)
Min Up from 50 Day SMA = 1 (Volatility Bars)
The results (last backtested for the period of 9/23/2008 to 10/14/2008) are as shown in Figure 15.
Learn how to interpret these backtest results from The OddsMaker by reading the user's manual at
http://www.trade-ideas.com/OddsMaker/Help.html.
FIGURE 15: TRADE IDEAS, STOCK STRATEGY. Here are the results
from the OddsMaker backtesting results for "Over Extended Up
Move."
BACK TO LIST