Академический Документы
Профессиональный Документы
Культура Документы
26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort INDICATORS
nalyzing a candlestick chart gives a good idea of what is going on in the market. Candlestick patterns, resistance or support from price pivots, rising or falling windows, and the use of trendlines are all excellent technical trading tools. But initiating a trade and deciding when to close it, candle after candle, remains a difficult task. It would be nice
Stocks & Commodities V. 26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort
9.1 9.0 8.9 8.8 8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.9 7.8 7.7 7.6 7.5 7.4 7.3 7.2 7.1 7.0 6.9 6.8
the uptrend line. As a rule, we will wait for the next day. The price continues above the trendline and the candles are turning green again. On February 22, 2007, there is another red candle. Now, the uptrend line is broken, so we close the long position eventually, opening a new short position. The color-coded candlesticks make daily followup easy and relaxing. Want to know how this is done? Of course you do.
A good starting point is the heikin-ashi chart. In the 3 30 6 13 20 27 4 11 18 26 3 16 22 29 5 12 20 26 November December 2007 February daily chart of Sysco Corp. in Figure 2, you can see the traditional candlestick chart on the top and the heikin- FIGURE 1: COLOR-CODED CANDLESTICKS. A short trade can be opened when price falls ashi chart on the bottom. Visually, the heikin-ashi through the uptrend line. The short trade is open till the downtrend line is broken to the upside. candles look very consistent. In a downtrend, we see mostly black candles with no or small upper shadows. In an 4+haOpen+Max(H,haOpen)+Min(L,haOpen))/4; ClHa:=haC>=haOpen; uptrend, there are mostly white candles with no or small ClHa lower shadows. First, I am going to color-code the normal candle chart with We do the same for creating a red candle with this second the information from the heikin-ashi chart. A white heikinformula when the heikin-ashi closing price is smaller than ashi candle will paint the normal candlestick green and a the opening price and we link red to it. black heikin-ashi candle will paint the normal candlestick red. The result can be seen in Figure 3. To do this in {red candle} MetaStock, we create an expert function and link it to the haOpen:=(Ref((O+H+L+C)/4,-1)+PREV)/2; chart. In the highlights tab of the expert editor, we first haC:=((O+H+L+C)/ introduce the formula to create a green candle when the 4+haOpen+Max(H,haOpen)+Min(L,haOpen))/4; heikin-ashi closing price is greater than or equal to the heikinClHa:=haC<haOpen; ashi opening price and we link a green color to a positive ClHa outcome:
{green candle} haOpen:=(Ref((O+H+L+C)/4,-1)+PREV)/2; haC:=((O+H+L+C)/
The execution priority is a green candle followed by a red candle. That way, the red candle function is only executed if the green candle function has a negative outcome (not true).
34
33 32 31 30 29 28 27
34.0 33.5 33.0 32.5 32.0 31.5 31.0 30.5 30.0 29.5 29.0 28.5 28.0 27.5 27.0 33 32 31 30 29 28 27
33 32 31 30 29
28 27 25 2 9
17
24
31
14
21
28
11
18
10
July
17
24
31
14
21
28
11
18
25
August
September
October
August
September
October
FIGURE 2: THE HEIKIN-ASHI CHART. Here you see a traditional candlestick chart on the top and a heikin-ashi chart on the bottom. As you can see, the heikin-ashi chart is very consistent.
FIGURE 3: COLOR-CODING USING INFORMATION FROM HEIKIN-ASHI. A white heikin-ashi candle will paint the normal candlestick green and a black heikin-ashi candle will paint the normal candlestick red.
METASTOCK
Stocks & Commodities V. 26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort
17.0 16.5 16.0
February
March
April
May
June
FIGURE 4: NOT A PERFECT WORLD. Here, the colors are less consistent and cannot be used for entering or exiting a trade.
16.5 16.0 15.5 15.0 14.5 14.0 13.5 16.5 16.0 15.5 15.0 14.5 14.0
10
17
24
31
14
21
28
12
19
27
March
April
May
FIGURE 5: AS GREEN AS POSSIBLE. All single-day reactions can be eliminated by extending a previous green candle by at least one more bar.
1))) {red candle} haOpen:=(Ref((O+H+L+C)/4,-1)+PREV)/2; haC:=((O+H+L+C)/4+haOpen+Max(H,haOpen)+Min (L,haOpen))/4; ClHa:=Alert(haC<haOpen,2); ClHa OR (Ref(ClHa,-1) AND (C<O OR C<Ref(C,-1)))
But a number of red candles are still left that we would like to eliminate in the uptrend. The second step is to see if the new candle comes after a green candle, or if it is a white candle (close above open). If it is the latter, there is no need to change the color because the bars still point in the direction of the uptrend. In Figure 6 you can see that another two red candles are eliminated by this second step. The green candle and red candle formulas have now been changed as follows:
In the third step, we will use a fast crossover system to allow a minimum price reaction while still being very fast at the turning points. We will employ the zero-lag crossover system that I introduced in my article in the STOCKS & COMMODITIES May 2008 issue. The code can be found here (upper left) in the sidebar, MetaStock crossover formula. We consider an uptrend (green candle) when ZlDif is equal {green candle} to or greater than zero. I am using a triple exponential moving haOpen:=(Ref((O+H+L+C)/4,-1)+PREV)/2; average (TEMA) of 34 bars. You may want to make that value haC:=((O+H+L+C)/4+haOpen+Max(H,haOpen)+Min smaller or bigger if you want to allow less or more price (L,haOpen))/4; reaction. ClHa:=Alert(haC>=haOpen,2); ClHa OR (Ref(ClHa,-1) AND (C>=O OR C>=Ref(C,At the price pivot point levels, often there are doji candles or spinning tops or bottoms with a small body compared to Copyright (c) Technical Analysis Inc.
Stocks & Commodities V. 26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort METASTOCK CROSSOVER FORMULA
avg:=34; 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((H+L)/2,avg); TMA2:= Tema(TMA1,avg); Diff:= TMA1 - TMA2; ZlCl:= TMA1 + Diff; ZlDif:=ZlCl-ZlHa; ZlDif
15.0 the high-low price. To eliminate them, I must introduce a last step. That step is not 14.5 changing the green color when the previous candle is green and the size of the real 14.0 body is smaller than 35% of the full high low range. In addition, the high must be 17 24 31 7 14 21 28 5 12 19 27 higher than the previous low to make sure April May there is no window in between. The final FIGURE 6: DO THE BARS POINT IN THE RIGHT DIRE C TION? We can take this one step further and eliminate result can be seen in Figure 7. more red candles in an uptrend. There are now only green candles during the entire uptrend. We get a sell signal on the first red candle. Drawing uptrend lines at this point shows a third, Initiating a trade and deciding steeper trendline that has been broken downward. This tells when to close it, candle after us it is time to sell. The complete expert formula _Uptrend_HA can be found in the sidebar MetaStock and candle, remains a difficult task. the last step. The order of execution is first the formula (green candle) and then the red candle only when the green candle is false. the _Downtrend_HA expert, we receive a buy signal at With the green candle uptrend expert we have a useful tool to (1). So we are now looking at the _Uptrend_HA candle keep us in an uptrend and detect a downward trend reversal. chart. We are combining this chart with a fast indicator like What we need next is an equally effective expert for a my SVAPO (see my article in the November 2007 issue of downtrend. For this we can simply reverse the execution STOCKS & COMMODITIES) to find out if there is a greater order and put a red candle on top of a green candle in the chance for a move up or down. In early March, we had a red selling bar at (2). Here we would expert editor. Or you can create another expert and call it _Downtrend_HA with the same formulas to be introduced hold on to the long position at least for one more day because the in the expert editor, but now with an inverse execution order closing price remains well above the last support line, and formula (red candle) first, followed by the (green candle) SVAPO is below the lower reference line, suggesting the possibility of an up move for the following bars. formula. We have an uptrend line drawn from the beginning of the Figure 8, a graphic of KBH, shows a downtrend. In the lower part of the chart, we used the expert function _Uptrend_HA. up move through the low at (2). We have drawn a parallel line The first red candle here is the reversal signal for going short. The through the previous top to form an uptrend channel. At the end upper part is the expert function _Downtrend_HA. We will of March, we have a second selling signal at (3). But there are stay short as long as there are red candles. With the first green enough reasons to hold onto the position. The price remains candle, we would close the short position and eventually open a above the uptrend line within the uptrend channel and a closing price above the last support while SVAPO is below the lower long position. Unfortunately, there is no perfect system. You may receive reference line, suggesting a higher chance of an up move. The next selling signal appears in the first half of April, but signals to exit a trade when it is probably better to hold onto the trade. The idea is not to trust this system blindly. When you are the price remains above the uptrend line within the uptrend faced with a reversal signal, you must use all available technical channel and a closing price above the last support. During analysis techniques to make an intelligent decision, preferably this activity, SVAPO is moving up. The price continues to move up and reaches the upper side of the trend channel, supported by more than one technique. Figure 9 illustrates the use of combined techniques. From making a top above the upper SVAPO reference line. At (5)
Stocks & Commodities V. 26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort
16.5 16.0 15.5 15.0 14.5 14.0
16.5 16.0
price drops through the last steeper uptrend line and we get another red selling bar. This is a good profit-taking moment. Next, selling signals appear at (6) when the closing price drops through the last support line, and at (7), when price drops out of the trend channel. If you prefer using an oscillator instead of color-coded candlesticks, you can use the heikin-ashi candlesticks oscillator (HACO), which I will explain next.
INTRODUCING HACO
15.5 15.0 14.5 14.0 13.5
10
17 24
31
14
21
28
12
19
27 2
March
April
May
June
FIGURE 7: TWEAKING THE TREND EVEN FURTHER. We can go one more step further and eliminate any dojis, spinning tops or bottoms, and other similar patterns.
HACO is a digital oscillator version of the colored candlesticks. It has either a value of zero for a red candle or 1 for a green candle. The basic formula is taken from the green candle and the red candle out of the _Uptrend_HA expert. The MetaStock code for the HACO can be found in the sidebar The heikin-ashi candlestick oscillator (HACO). On the chart of General Electric (GE) in Figure 10, youll see the HACO on the top subchart. I have colored the price chart so
METASTOCK AND THE LAST STEP (Note: The MetaStock expert for an uptrend is _Uptrend_HA)
{green candle} avg:=34; 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((H+L)/2,avg); TMA2:= Tema(TMA1,avg); Diff:= TMA1 - TMA2; ZlCl:= TMA1 + Diff; ZlDif:=ZlCl-ZlHa; keep1:=Alert(haC>=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)*.35 AND H>=Ref(L,-1)); utr:=Keepall OR (Ref(keepall,-1) AND keep3); keep1:=Alert(haC<haOpen,2); keep2:=ZlDif<0; keep3:=Abs(C-O)<(H-L)*.35 AND L<=Ref(H,-1); keeping:=keep1 OR keep2; keepall:=keeping OR (Ref(keeping,-1) AND (C<O) OR C<Ref(C,-1)); dtr:=If(Keepall OR (Ref(keepall,-1) AND keep3)=1,1,0); upw:=dtr=0 AND Ref(dtr,-1) AND utr; dnw:=utr=0 AND Ref(utr,-1) AND dtr; result:=If(upw,1,If(dnw,0,PREV)); result {red candle} avg:=34; 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((H+L)/2,avg); TMA2:= Tema(TMA1,avg); Diff:= TMA1 - TMA2; ZlCl:= TMA1 + Diff; ZlDif:=ZlCl-ZlHa; keep1:=Alert(haC>=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)*.35 AND H>=Ref(L,-1)); utr:=Keepall OR (Ref(keepall,-1) AND keep3); keep1:=Alert(haC<haOpen,2); keep2:=ZlDif<0; keep3:=Abs(C-O)<(H-L)*.35 AND L<=Ref(H,-1); keeping:=keep1 OR keep2; keepall:=keeping OR (Ref(keeping,-1) AND (C<O) OR C<Ref(C,-1)); dtr:=If(Keepall OR (Ref(keepall,-1) AND keep3)=1,1,0); upw:=dtr=0 AND Ref(dtr,-1) AND utr; dnw:=utr=0 AND Ref(utr,-1) AND dtr; result:=If(upw,1,If(dnw,0,PREV)); result=0
Stocks & Commodities V. 26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort
55
50
45
55
50
45
20
26
5 March
12
19
26
2 9 April
16
FIGURE 8: DOWNTRENDS. Here you see red candle and green candle formulas. As long as there are red candles, its best to stay short.
you can easily see the periods with a long position (green) and with a short position (red). HACO is not meant to be an automatic trading system, so when there is a buy or sell signal from HACO, make sure it is confirmed by other technical analysis techniques. HACO will certainly aid in signaling buy and sell opportunities and help you hold onto a trade, making it more profitable. In early 2004, you can probably avoid a short position in GE for just a couple of days, generating more net profit. You can change the input value in the HACO for the zero-lag TEMA in the up and down moves. Basically, you would use the same value for both entries. If you use different values, it will work fine most of the time, but there may be some unexpected results. This is because using different up and down TEMAs will mean no synchronization between the up and down components. The behavior of HACO is closely related to the level and speed of price change. It can be used on charts of any time frame ranging from intraday to monthly. Sylvain Vervoort lives in the Flemish part of Belgium and is a retired electronics engineer, studying and using technical analysis for more than 30 years. He is an independent trader, writer, publisher, and educator in the area of technical analysis and options. Sylvain Vervoort may be reached at his website at http://stocata.org/.
5 6 7
3 4 1 2
25.5 25.0 24.5 24.0 23.5 23.0 22.5 22.0 21.5 21.0 20.5 20.0 19.5 19.0 18.5 18.0
ADDITIONAL READING
Mulloy, Patrick [1994]. Smoothing Data With Less Lag, Technical Analysis of STOCKS & COMMODITIES, Volume 12: February. Valcu, Dan [2004]. Using The HeikinAshi Technique, Technical Analysis of STOCKS & COMMODITIES, Volume 22: February. Vervoort, Sylvain [2008]. The Quest For Reliable Crossovers, Technical Analysis of STOCKS & COMMODITIES, Volume 26: May. _____ [2007]. Short-Term Volume And Price Oscillator, Technical Analysis of STOCKS & COMMODITIES, Volume 25: November.
SVAPO(1,3)
-5
2008
February
March
April
May
June
FIGURE 9: COMBINING TREND CHARTS WITH SVAPO. Using trend charts with a fast indicator like SVAPO adds confirmation to your buy/sell decisions.
Stocks & Commodities V. 26:12 (50-57): Trading With The Heikin-Ashi Candlestick Oscillator by Sylvain Vervoort THE HEIKIN-ASHI CANDLESTICK OSCILLATOR (HACO)
{HACO} avg:=Input(Up TEMA average: ,1,100,34); avgdn:=Input(Down TEMA Average: ,1,100,34); 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((H+L)/2,avg); TMA2:= Tema(TMA1,avg); Diff:= TMA1 - TMA2; ZlCl:= TMA1 + Diff; ZlDif:=ZlCl-ZlHa; keep1:=Alert(haC>=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)*.35 AND H>=Ref(L,-1)); utr:=Keepall OR (Ref(keepall,-1) AND keep3); TMA1:= Tema(haC,avgdn); TMA2:= Tema(TMA1,avgdn); Diff:= TMA1 - TMA2; ZlHa:= TMA1 + Diff; TMA1:= Tema((H+L)/2,avgdn); TMA2:= Tema(TMA1,avgdn); Diff:= TMA1 - TMA2; ZlCl:= TMA1 + Diff; ZlDif:=ZlCl-ZlHa; keep1:=Alert(haC<haOpen,2); keep2:=ZlDif<0; keep3:=Abs(C-O)<(H-L)*.35 AND L<=Ref(H,-1); keeping:=keep1 OR keep2; keepall:=keeping OR (Ref(keeping,-1) AND (C<O) OR C<Ref(C,-1)); dtr:=If(Keepall OR (Ref(keepall,-1) AND keep3)=1,1,0); upw:=dtr=0 AND Ref(dtr,-1) AND utr; dnw:=utr=0 AND Ref(utr,-1) AND dtr; result:=If(upw,1,If(dnw,0,PREV)); result S.V.
0.5
35.0 34.5 34.0 33.5 33.0 32.5 32.0 31.5 30.5 30.0 29.5 29.0 28.5 28.0 27.5 27.0
November
2004
February March
April
May
June
S&C
FIGURE 10: HACO. The long positions are displayed in green and short positions in red.