Heikin - Ashi Candlesticks |
Post Reply | Page <1 345 |
Author | |
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: 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: 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
|
|
jazza
Regular Joined: 10 Aug 2007 Posts: 33 |
Post Options Quote Reply 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 |
|
Post Reply | Page <1 345 |
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 |