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 Reverse Sort Order / View First Unread Post
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
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: 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: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
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: 13 Sep 2012 at 11:45pm

Hi Cmcdon,

I think we have a slight misunderstanding with terminology. I think the screen shot below is the final result we are talking about?

My point, is that I am trying to achieve the opposite of that, with the white candles for up and the black candles for down as per normal candlestick custom.

Maybe answer is for a “Solid fill” attribute to be added to Bullscript or HA to be coded and added to the linestyle dropdown menu?

Cheers for hanging in with this one, Jazza

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: 13 Sep 2012 at 3:45pm
Jazza
 
I do not know if you have tried the abovebut as well as the Ribbon backgound it shows the proper HA bars filled in solid black for up and solid white for down.
 
 
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: 13 Sep 2012 at 12:04pm

Hi Cmacdon,

Nice bit of lateral thinking re the trend via the ribbon.  Still doesn’t solve our problem of unfilled down candles. Maybe just got to get my head around the visual flip. Hopefully a solution somewhere.

Thanks again for all your help and input so far.

Cheers Jazza

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: 13 Sep 2012 at 9:07am
Jazza
 
You can get what you want albeit with some smoke and mirrors but you also end  up with Black up bars and White down HA bars that appear solid fills.
 
Take Maximos candlestick code and change the Lime Green colour to Black and the Red Colour to White.
 
That will give the perception of solid up black bars and solid down white bars.
 
Copy that amended code and change the Target=Price to Target=ribbon,  and reverse the colour Black to White and color white to Black.
 
Put that new ribbon indicator on the chart and go into the advance setting on the ribbon and tick the box solid background.
 
That gives you the ha bars illusion you want and clearly shows the Ha up and down trend.
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: 13 Sep 2012 at 2:13am

Hi Cmacdon, That’s great. Got it working, thanks very much for that.

I am still trying to replicate the true Heikin- Ashi candlestick formula with the colors filled or with white up and black down candles.

If I use your HA formula as: [target=Price; linestyle=PriceColor] then I will get the OHLC bars which I can override and fill in the price plot as you say , but ends up as a standard colorized Candle price chart, albeit with the trend change colorized ,still not with the HA averaged out bars.

If I go back to the original formula, yours, Maximo’ or Bullcharts as: [linestyle=Candle], then when it is added to the chart as a Candle, it overrides the drop down menu. If you double click the candle, you will not get the price plot.

Any other ideas on how to get those candles filled?

Cheers Jazza

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: 12 Sep 2012 at 9:11am
Jazza
 
Ifyou apply the above HA colour bar indicator, turn on candlestick on the top of the chart drop down menu, double click on any price bar to bring up the Price Plot Properties, click on Colour tab, and in that screen click on fill  all bars - it will give you , normal candlesticks with the solid fill HA colours you want. That will probably save you having two screens one with HA and one your normal candlesticks if that is how you are set up.
BC User since June 2007
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