Sunday, June 7, 2015

thinkscript included: sdi_closeLevel - plot the eod price on a heiken-ashi candle.

i have become enamored with the heiken-ashi candle. the heiken-ashi candle re-jiggers the way open and close are represented. here's a picture that 'splains the heiken-ashi basics:
heiken-ashi explained
the tails point to the same high/low of day as regular candles but the heiken-open is the mid-point of the previous day's heiken-ashi body and the heiken-close is the average price of the day as represented by (open+high+low+close)/4 (aka ohlc4.) the advantage of this presentation of the data is that a series of fat-body/single-tailed candles makes it easy to identify a trend in its nascent stages. also, the heiken-open represents good trade placement in the trend direction. so, if the days trading crosses through the heiken-open to create a two-tailed candle then the trend is questionable and might be reversing.

however, the heiken-ashi candle is a little disconcerting. i think this is because it hides where the market leaves price at the end-of-the-day. so i wrote a thinkscript that shows the eod price in relationship to the heiken-ashi candle. here's what this looks like:
heiken-ashi candles with eod prices
when the eod price is above the heiken-body i color it green because the bulls won the battle on that day and when the eod price is below the heiken-body i color it red because the bears won the battle. if the eod price is inside the heiken-body then i color it black - a stalemate was achieved. i think this improves the heiken-ashi system.

here's the code:

# sdi_closeLevel
plot cl = close;
#hint: plot the close level as a horizontal line with the color determined by its relationship to the heiken-ashi body. source: rev:1.0.0
cl.defineColor("above h-a body", color.GREEN);
cl.defineColor("inside h-a body", color.DARK_GRAY);
# author: allen everhart
# date: 7jun2015
cl.defineColor("below h-a body", color.RED);
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale. 
# Help me get the word out about my blog by keeping this header
# in place. 
    if close>ohlc4 && heikinAshiDiff()>0 then cl.color("above h-a body")
    else if close<ohlc4 && heikinAshiDiff()<0 then cl.color("below h-a body")
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale. 
    else if heikinAshiDiff()<0 and close>ohlc4-heikinAshiDiff() then  cl.color("above h-a body")
    else if heikinAshiDiff()>0 and close<ohlc4-heikinAshiDiff() then cl.color("below h-a body")
    else cl.color("inside h-a body")


No comments:

Post a Comment