BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Heikin - Ashi  Candlesticks
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Heikin - Ashi Candlesticks

 Post Reply Post Reply Page  <12345>
Author
Message / View First Unread Post
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 14 Sep 2012 at 2:27am

Attribute found! :P

 

[citation="'Using The Heikin-Ashi Technique', by Dan Valcu Stocks & Commodities Feb 2004 www.traders.com"]

[target=Price]

haClose := (O+H+L+C)/4;

haOpen := (prev + hist(haClose,1))/2;

haHigh := max(H, haOpen, haClose);

haLow := min(L, haOpen, haClose);

[linestyle=Candle; color=lime green]

if (haOpen < haClose,haOpen,undefined);

if (haOpen < haClose,haHigh,undefined);

if (haOpen < haClose,haLow,undefined);

if (haOpen < haClose,haClose,undefined);

[linestyle=Candle; color=indian red]

If(haOpen >= haClose,haOpen,undefined);

If(haOpen >= haClose,haHigh,undefined);

If(haOpen >= haClose,haLow,undefined);

If(haOpen >= haClose,haClose,undefined);

[linestyle=fill bars; color=indian red; width=4]

If(haOpen >= haClose,haOpen,undefined);

If(haOpen >= haClose,haClose,undefined);

Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 14 Sep 2012 at 7:04am
Thats great Maximo
It worked well on ha bars when I zoomed out on a chart but I had to change the width to 8 when I zoomed in on ha bars as it otherwise was just showing a coloured stripe on the wider down bars; and was not filling across the full width of the wider (zoomed in bar).  Note sure if the width can be set up to automatically fill fully across all the time?
BC User since June 2007
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 14 Sep 2012 at 2:34pm
I think zooming a chart is an internal function of the software and probably not detectable in scripting.   Ideally the software should be scaling the width relative to zoom for filling bars.


Edited by maximo - 14 Sep 2012 at 4:08pm
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 15 Sep 2012 at 12:59am
Maximo and Jazza
 
The London market seemed to be going crazy so I pulled out and had another look at this.
 
Here is another "partial solution" to Colouring up and down HA bars in solid colour.  I used Maximo's original HA coloured bar coding and added a third section for solid colour blue bars explained below. 
 
If you load up the indicator on a chart you will get the original white down bars with red outline and green as shown by Maximo originally.  If you go into the indicator properties and tick Partial solution you will see that the white down bars are then coloured solid blue.
 
 
In adding the extra bit of code I had assumed rightly or wrongly that there is something in the underling Bullscript Candle linestyle attibute code that otherwise makes the down bars white.  The sequence of the HA definitions is basically in the order O,H,L,C (haopen hahigh, haclose then halow).  So I assumed one could "trick" the Linesttyle candlestick code to still accept the ha bars but not as the usual candlestick format.
 
Hence, I added the third colour blue code section where I put the ha definitions in a different order.  after various trial and errors L,C,H,O worked and produced the solid blue coloured bars as you can see.  The bars are exact as far as I can see for toptails and shaven head HA bars. 
 
However, the solution is only partial as i noticed that main body of a few some bars where some ha bars had lower tails are included as an extension of the main body.  This may be an issue in the case of interpreting congestion bars but as the intension is to use the solid colours as trend indications it may not be a problem.  However, I could not find a differnt order for the lasst section of code that worked to resolve this issue.  You may be able to fix from you knowledge.  I think it is a useful trend indicator even with this issue.
 

[citation

="'Using The Heikin-Ashi Technique', by Dan Valcu Stocks & Commodities Feb 2004 www.traders.com"

]

[target

=Price

]

haClose := (

O

+H+L+C)/4;

haOpen := (

prev

+ hist(haClose,1))/2;

haHigh :=

max

(H, haOpen, haClose);

haLow :=

min

(L, haOpen, haClose);

[linestyle

=Candle

]

[color

=lime green

]

if

(haOpen < haClose,haOpen,

undefined);

if

(haOpen < haClose,haHigh,

undefined);

if

(haOpen < haClose,haLow,

undefined);

if

(haOpen < haClose,haClose,

undefined);

[linestyle

=Candle

]

[color

=red

]

If

(haOpen >= haClose,haOpen,

undefined);

If

(haOpen >= haClose,haHigh,

undefined);

If

(haOpen >= haClose,haLow,

undefined);

If

(haOpen >= haClose,haClose,

undefined);

[name

=Partial Solution; linestyle

=Candle

; color=Blue; visible=false;]

If

(haOpen >= haClose,haLow,

undefined);

If

(haOpen >= haClose,haClose,

undefined);

If

(haOpen >= haClose,haHigh,

undefined);

If

(haOpen >= haClose,haOpen,

undefined);

 
 
 
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 15 Sep 2012 at 10:25am
Jazza and Maximo
Here they are.  I went back to my original code and played around with the order of Ha definitions in the Down trend bars and after similar trial and error the solid colours worked and the proper tails are shown on both up and down Ha bars
(The order needs to be Haclose at top and Ha open at the bottom in between hahigh and ha low can be any order.   I retried this ranking on partial solution code sent earlier but that did not remedy the down tail problem on earlier post). 
 
There are two indicators below the solid colour trends (doesn't distinguish congestion bars and the second indicator showing the congestion bars in Black
 
( For some unknown reason in the second indicator when I distinguish the congestion bars in black the congestion bars appear as either white or black solid bodies.  That does not matter if you are using the first indicator).
 
 
 
1 is solid colour HA trend indicator
2 is the same but with the congestion bars in black
----------------------------------------------------------------------------------------
 

[target

=Price;]

haClose := (

O+H+L+C)/4;

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);

 

 

{end of indicator1}
 

[target

=Price;]

haClose := (

O+H+L+C)/4;

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;color=Black; ]

If

(Greenlight >0.000 and Redlight <-0.000, haClose,undefined);

If

(Greenlight >0.000 and Redlight <-0.000, haLow,undefined);

If

(Greenlight >0.000 and Redlight <-0.000, haHigh,undefined);

If

(Greenlight >0.000 and Redlight <-0.000, haOpen,undefined);

 
 
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 15 Sep 2012 at 10:46am
Serendipidy never ends!  Maybe a third indicator.
I just changed the above code for the congestion bars section as shown below and this produced all trend up bars in White and all down trend in black which is the way they are shown in Valcu's book mentioned earlier and also in Sylvain Vervoort "Capturing Profit with Technical analysis, Market Place Books 2009; and I think Jazza alternative to colour requirement.
 

[linestyle

=Candle;color=Black; ]

If

(Greenlight >=0.000 and Redlight <=-0.000, haClose,undefined);

If

(Greenlight >=0.000 and Redlight <=-0.000, haLow,undefined);

If

(Greenlight >=0.000 and Redlight <=-0.000, haHigh,undefined);

If

(Greenlight >=0.000 and Redlight <=-0.000, haOpen,undefined);

BC User since June 2007
Back to Top
jazza View Drop Down
Regular
Regular
Avatar

Joined: 10 Aug 2007
Posts: 33
Post Options Post Options   Quote jazza Quote  Post ReplyReply Direct Link To This Post Posted: 16 Sep 2012 at 2:05pm

Hi Cmacdon and Maximo,

Hearty congrats, great effort. Very happy with these solutions. Sorry about the late reply but immediately noticed some visual anomalies that I wanted to figure out first.

Noticed that some of the close priced congestion bars differed in trend between the different solutions as per the super imposed screen shot below.

The answer is easy once you know but it took me some time to figure out. Zooming the page corrects the candle Up/Down anomalies.  I put the formula into an excel spread sheet and it checked out. I also carefully checked the price of the HA candle with the Crosshair under zoom and they were correct.

The HA formula alters all the OHLC prices to 3 decimal point increments at different times. In respect to the Origional Bullcharts HA formula, when the Candle bodies are small, unfilled candles do not visually cope with these fractions and can be filled under normal unzoomed conditions. When you are looking at the “Hard Right Edge” of the chart I think this is Important.

Certainly  Maximo, love your solid fill Up/Down color solution as it solves any ambiguity as to whether the HA bars have closed up or down in narrow ranges.

Cmacdon, as a Black and White candlestick traditionalist, I also love you’re your solution. Just gotta remember to zoom in with congestion bars if you are concerned about the correct open or close.

Thanks guys, Cheers. Clap

PS: Cmacdon, figure from previous comments that you may have the Sylvain Vervoort book “Capturing profit with technical analysis” Worth buying in your opinion?

 

Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 16 Sep 2012 at 4:37pm
Jazza
 
Like most trading books I have and there are many on shelves behind me, I tend to read them only once and do not reread them again unless they are really  focused onto something that is fundamental to understanding  a particular aspect of trading or the market process that is useful to me.  In other words, the books need to be really focused and with some depth thereon to a particular issue before I would reread.
 
(There are numerous light weight books out there that are that are focused on reexplaining MACD, RSI and maybe stochastics?  They tend to be repetitive and at the end of the day thoroughly boring.)
 
In my opinion, Vervoort's book tries to cover too much ground in one book.  He expalins HA bars , and covers his SVAPO oscillator system and "Lockitt"which is the name of his trading methodology but this entails covering Heikin Ashi, and Candlesticks  (of which there are many other books) and Elliott waves  (of which there are too too many other books) and Risk Management ( of which there are many other books), Babson and Pitchforks, resistance levels and Fibbonnacci etc. 
 
I only referred to his book in my post as I wanted to compare whether his uptrends and down trend HA bars were the same black and white direction as shown in Falcu's book cited earlier, and your suggestion that Bullcharts was back to front.  Personally it does not matter to me which way the colours or B&W) go as long as they are consistenlt the same way. 
 
I do not know if you have it but, Part One (Chapters 1-7) of Falcu's book is good as he focuses purely on explaining HA, and the table on page 22 is particularly useful as it gives you the 5 rules for translating HA bars so you can trade them.   The rest of the book compares the HA approach to candlesticks, moving averages, ichimoku, market breadth , pivotts and Forex.  So I might reread Section one from time to time.
 
Hope that helps
 
By the way how do you post  graphics on your posst as I tried to post a graphic of a chart the other day and the forum pst reply process did not accept the graphic.
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 16 Sep 2012 at 4:58pm
Just noticed, must be a good week as I joined the forum last week to discuss a few things I was interested in and I have been promoted from a newbie to a regular by the system.  I need to go back into my shell.
BC User since June 2007
Back to Top
jazza View Drop Down
Regular
Regular
Avatar

Joined: 10 Aug 2007
Posts: 33
Post Options Post Options   Quote jazza Quote  Post ReplyReply Direct Link To This Post Posted: 16 Sep 2012 at 8:57pm

Back to Top
 Post Reply Post Reply Page  <12345>

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz