Heikin - Ashi Candlesticks |
Post Reply | Page 123 5> |
Author | |
jazza
Regular Joined: 10 Aug 2007 Posts: 33 |
Post Options
Quote Reply
Topic: Heikin - Ashi Candlesticks Posted: 20 Oct 2012 at 4:36pm |
Hi cmacdon, Some serious coding there and nice adjustments. I have pasted to a new template and will use as an alternative with my old Heikin Ashi for comparison. Thanks very much, cheers |
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 15 Oct 2012 at 11:26am |
Here is the Bullscript code
----------------------------------------------- [target =Price;] n := input("Define Haclose 1=(O,H,C,L)/4; 2=pldot ",2,1); pldot:=((( hist(h,0)+hist(Low,0)+hist(C,0))/3)+((hist(h,1)+hist(Low,1)+hist(C,1))/3)+((hist(h,2)+hist(Low,2)+hist(C,2))/3))/3; norm:=( O+H+L+C)/4; haClose := if(n=1,norm,pldot); haOpen := ( prev + hist(haClose,1))/2; haHigh := max(H, haOpen, haClose); haLow := min(L, haOpen, haClose); haCl:=(( O+H+L+C)/4+haOpen+Max((O+H+L+C)/4,Max(H,haOpen))+Min((O+H+L+C)/4,Min(L,haOpen)))/4; Greenlight:=Hahigh-(haopen) ; Redlight:=Halow-(haOpen);
{I changed this to a difference to net off the minor congestion amounts to whatever if the largest Traffic light tmeasure. this makes the trends more continuous for the coloured bars} LightDiff:=Greenlight+Redlight; [linestyle =Candle;color=Green; ] If (lightdiff >=0.000, haOpen,undefined); If (lightdiff >=0.000, haHigh,undefined); If (lightdiff >=0.000, haLow,undefined); If (lightdiff >=0.000, haClose,undefined); [linestyle =Candle;color=Red; ] If (lightdiff <=0.000, haClose,undefined); If (lightdiff <=0.000, haLow,undefined); If (lightdiff <=0.000, haHigh,undefined); If (lightdiff <=0.000, haOpen,undefined);
[linestyle =Candle; Width=2; color=Red; ] If (H<Hist(h,1) And Hist(h,1)>=Hist(H,2) AND Hist(h,1)>=Hist(H,3) AND Hist(h,1)>=Hist(H,4), haopen,undefined); If (H<Hist(h,1) And Hist(h,1)>=Hist(H,2) AND Hist(h,1)>=Hist(H,3) AND Hist(h,1)>=Hist(H,4), haLow,undefined); If (H<Hist(h,1) And Hist(h,1)>=Hist(H,2) AND Hist(h,1)>=Hist(H,3) AND Hist(h,1)>=Hist(H,4), haHigh,undefined); If (H<Hist(h,1) And Hist(h,1)>=Hist(H,2) AND Hist(h,1)>=Hist(H,3) AND Hist(h,1)>=Hist(H,4), haClose,undefined);
{To catch second bar at a Bottom turning point} a:= If((L>Hist(L,1) AND Hist(L,1)<=Hist(L,2) AND Hist(L,1)<=Hist(L,3) AND Hist(L,1)<=Hist(L,4) AND C>Hist(c,1)),1, undefined); {To Catch a second incorrect HA bar after a bottom turning point} a2:= If (Hist(a,1) AND L>Hist(L,1)AND C>Hist(c,1) ,1,undefined); {To Catch a third incorrect HA bar after a bottom turning point} a3:= If (Hist(a2,1) AND L>Hist(L,1) AND C>Hist(c,1),1,undefined); [linestyle =Candle; Width=2; color=Green; ] If (a OR a2 OR a3, HaClose,undefined); If (a OR a2 OR a3, HaLow,undefined); If (a OR a2 OR a3, HaHigh,undefined); If (a OR a2 OR a3, Haopen,undefined);
|
|
BC User since June 2007
|
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 15 Oct 2012 at 11:24am |
Here is some corrected code to pick up earlier and correctly colour the HA , Ha-Pldot bars.
I provided an option to select the traditional haClose definition HaClose:= (O +H+C+L) or pldot. At the bottom of the code I added some exception rules to overcome the probelm of HA bars not picking up changes in trend earl enough at tops and bottoms. This intoduces the possibility of whipsaws but they are more correct as they identify actual down bars in uptrends or actual upbars in down trends when they occue. If you find further exceptions needed it is relatively easy as shown at the bottom of the code to add more exceptions using an Or statement. The exception rules are triggered if you have the 3rd and 4th box ticked in the style menu i.e. Chart 4 below. if the exception rules are not triggered leave those boxes blank. Ticking them on and off gives some insight as to whther synthetic HA bars appear to be correct. 4 charts of AQP for comparison purposes are shown below 1 Original OHLC bars. 2 Original Defined HA code 3 My chart from code shown further below with original HA pldot bars ( exceptions not turned on) 4 Same chart with 3rd and 4th box in style menu turned on. |
|
BC User since June 2007
|
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 14 Oct 2012 at 11:59pm |
I just lost a correction post so I will do it again.
I withdraw and correct my proposal about using pldot in the HA definition two posts above. After reviewing it in more depth it appear that HA pldot is giving the appearance of improving the turning point but it is in fact picking up the same incorrect bar as the turning point as the original Ha bars showed. Both Ha definitions are picking up the actual second bar after the particula top as the first HA down bar. I will have to keep working at it. Apologies. |
|
BC User since June 2007
|
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 14 Oct 2012 at 8:58pm |
In this chart, I thought it might be worth comparing how smooth is pldot compared to a couple of other ways to develop similar indicators.
Chart 1 is the amended HA-pldot bars with Bollinger bands at 1 and 2 standard deviations where BB is based also on pldot. Chart 2 is traditional HA bars and traditional Bollinger bands calculations based on the close rather than pldot. Chart 3 is similar to t he above but BB is based on Hull Moving average which is one of the fastest MA configurations available. In my view Chart 1 show that a system based on pldot has the edge in providing clearer potential signals. Each 5 min chart is based on 10 period MA. |
|
BC User since June 2007
|
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 14 Oct 2012 at 12:58pm |
Here is a potential fix/improvement to the problem noted above regarding late signals, potential whipsaws or incorrect signals using traditional Heikin Ashi defined bars.
The key issue underlying HA bars is a moving average concept. The definition of HaClose is := (
O+H+L+C)/4; and this MA estimate flows into each of the other definitions of HAHigh, HALow and HA Open bars. In a lot of indicators based on moving averages, I tend to always use "pldot" as the moving average definition, as it tends to produce a very smooth MA and, because it is based on the last 3 bars the MA has a built in momentum component. Pldot was invented by Charles Drummond, a Canadian Trader and is the core input to Drummond Geometry Trading approach and software. pldot:=((( hist(h,0)+hist(Low,0)+hist(C,0))/3)+((hist(h,1)+hist(Low,1)+hist(C,1))/3)+((hist(h,2)+hist(Low,2)+hist(C,2))/3))/3; replace the definition of HaClose to - haclose:=pldot, you get the improved charting results I show in the first comparison chart below. On the charts I have noted the potential benefits for trading using HA-pldot bars on the charts as I see them. You can make up your own minds.I used AQP as the security, as it had the problem I noted above in an earlier post when it was still showing a HA up bar when clearly the market had turned. Chart2 is my previous HA coloured bars for comparison purposes showing problematic turning points or potential whipsaw bars. Chart 3 is Maximo's originally defined Heikin Ashi bars. Also showing comparative turning points or potential whipsaws traditional defined HA bars. |
|
BC User since June 2007
|
|
jazza
Regular Joined: 10 Aug 2007 Posts: 33 |
Post Options Quote Reply Posted: 19 Sep 2012 at 1:54pm |
Hi Cmacdon, Interesting point re HA. I have been looking at the HA delta(3) and have come to the conclusion that it is gives too many false signals. I think you alluded to that in an earlier post. Still think the HA is a great trend trading tool. At the moment, I am combining it with my favorite momentum oscillator, a 7 period RSI |
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 19 Sep 2012 at 11:09am |
|
|
BC User since June 2007
|
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 19 Sep 2012 at 11:08am |
Going back to an earlier post about potential problems using HA bars to trade EOD or longer, and also the use of HA Delta or my HA Oscillator here is a good example of the issue from today's market.
At 10.30 a.m. approx AQP has dropped 12% from yesterdays high and 8% from Yesterdays Close yet the HA bar is still showing Green for an up trend. The First chart shows the OHLC bars and the next charts shows the incorrect trend indication on the last HA bar at the same point in time On the other hand, the Oscillator has picked up the change as it is coloured yellow showing a move down from a green bar indicating a decine from a maxima, and the HA Delta is showing a cross over. |
|
BC User since June 2007
|
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 19 Sep 2012 at 8:44am |
Good Jazza
|
|
BC User since June 2007
|
|
Post Reply | Page 123 5> |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |