Screening the first Heikin-Ashi green candle in Stockcharts.com

in #stocks7 years ago (edited)

A couple of my friends has been  asking for this code for a long time. The strategy is to buy on pullbacks/dips using the first/second green Heikin Ashi as entry on stocks with strong uptrends. 

<p dir="auto">  <p dir="auto">Stockcharts.com has a stock screener that can filter out candlestick patterns and technical indicator rules, but currently lacks a filter for Heikin Ashi. I've managed to come out with a draft code which can help you find uptrending stocks that is showing it’s first Heikin Ashi green candle.  <p dir="auto"><br /> <p dir="auto"><em>Please note that the code doesn't accurately calculate Heikin Ashi due to some limitation on the language provided by Stockcharts programmable filters. <p dir="auto">Let me know if  you can help with some improvements on the Heikin-Ashi code and feel free to add other indicators such as Stochastics/ADX to your own custom codes. <p dir="auto"><br /> <p dir="auto">As usual, if you find this beneficial to your trading, please don't forget to resteem and upvote this post. <p dir="auto"><br /> <p dir="auto"><strong>Code: First Heikin-Ashi green candle that recently dipped to 20SMA. <pre><code>[type = stock] <br /> <br /> <br /> <br /> # Only securities with options<br /> <br /> and [optionable is true]<br /> <br /> <br /> <br /> # High liquidity<br /> <br /> and [SMA(50,close) * SMA(50,volume) > 500000] <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> #########<br /> <br /> # Uptrend #<br /> <br /> #########<br /> <br /> <br /> <br /> # MA levels in positive alignment<br /> <br /> and [today's sma(20,close) > today's sma(40,close)]<br /> <br /> and [today's sma(40,close) > today's sma(100,close)]  <br /> <br /> and [today's sma(100,close) > today's sma(200,close)]  <br /> <br /> <br /> <br /> <br /> <br /> ##########<br /> <br /> # Pullback  #<br /> <br /> ##########<br /> <br /> <br /> <br /> # Recently dipped into 20 SMA<br /> <br /> and [<br /> <br />  [4 day's ago Low < 4 day's ago sma(20,close)] <br /> <br />  or [3 day's ago Low < 3 day's ago sma(20,close)] <br /> <br />  or [2 day's ago Low < 2 day's ago sma(20,close)]<br /> <br />  or [yesterday's Low < yesterday's sma(20,close)]<br /> <br /> ]<br /> <br /> <br /> <br /> # But for this strategy we don't want dips that go too low and could possibly be the start of a major downtrend.  <br /> <br /> # Our focus is to ride on the larger trend and buying on the smaller dips to the means.<br /> <br /> and [<br /> <br /> [5 day's ago Low > 5 day's ago sma(100,close)]  <br /> <br /> and [4 day's ago Low > 4 day's ago sma(100,close)] <br /> <br /> and [3 day's ago Low > 3 day's ago sma(100,close)] <br /> <br /> and [2 day's ago Low > 2 day's ago sma(100,close)]<br /> <br /> ]<br /> <br /> <br /> <br /> <br /> <br /> ########################################<br /> <br /> # Determine if it's the first green Heikin Ashi candle #<br /> <br /> ########################################<br /> <br /> <br /> <br /> # NOTE: My calculation for first Heikin Ashi isn't precise. Use visual confirmation from the results.<br /> <br /> <br /> <br /> # Determine if today's Heikin Ashi is green by checking if today's HA Open is higher than Close<br /> <br /> # HA calculation is normally  a loop that depends on previous candles parameters until the end of the chart. <br /> <br /> # Stockcharts doesn't support a pseudo-loop so I'm only calculating up to 3 candles back.<br /> <br /> <br /> <br /> and [<br /> <br /> # Today's HA-Open<br /> <br /> [<br /> <br />  [<br /> <br />    # Yesterday's HA-Close<br /> <br />    [<br /> <br />     [2 day's ago  open + 2 day's ago  close + 2 day's ago  high + 2 day's ago low]/4] <br /> <br />    +<br /> <br />    # Yesterday's HA-Open (2 day's ago HA-Open + 2 day's ago HA-Close)/2<br /> <br />    [<br /> <br />      [<br /> <br />       # 2 day's ago HA-Open<br /> <br />        [   [[ 3 day's ago open + [[3 day's ago  open + 3 day's ago  close + 3 day's ago  high + 3 day's ago low]/4 ] / 2]  + [[2 day's ago  open + 2 day's ago  close + 2 day's ago  high + 2 day's ago low]/4] ]/2  ]<br /> <br />      +<br /> <br />       # 2 day's ago HA-Close<br /> <br />       [ [2 day's ago  open + 2 day's ago  close + 2 day's ago  high + 2 day's ago low]/4] <br /> <br />      ]<br /> <br />      # Average<br /> <br />      / 2<br /> <br />    ]<br /> <br />  ]<br /> <br />  # Average<br /> <br /> / 2<br /> <br /> ]<br /> <br /> < <br /> <br /> # Today's HA-Close<br /> <br /> [<br /> <br />   [Open + Close + High + Low]/4 <br /> <br /> ]   <br /> <br /> ]<br /> <br /> <br /> <br /> <br /> <br /> # Determine if yesterday's Heikin Ashi candle is red.<br /> <br /> and [<br /> <br /> [<br /> <br />  [<br /> <br />     [[3 day's ago  open + 3 day's ago  close + 3 day's ago  high + 3 day's ago low]/4] <br /> <br />   +<br /> <br />    [<br /> <br />      [<br /> <br />        [   [[ 4 day's ago open + [[4 day's ago  open + 4 day's ago  close + 4 day's ago  high + 4 day's ago low]/4 ] / 2]  + [[3 day's ago  open + 3 day's ago  close + 3 day's ago  high + 3 day's ago low]/4] ]/2  ]<br /> <br />      +<br /> <br />       [ [3 day's ago  open + 3 day's ago  close + 3 day's ago  high + 3 day's ago low]/4] <br /> <br />      ]<br /> <br />      / 2<br /> <br />    ]<br /> <br />  ]<br /> <br /> / 2<br /> <br /> ]<br /> <br /> > <br /> <br /> [ [Yesterday's Open + Yesterday's Close + Yesterday's High + Yesterday's Low]/4 ]   <br /> <br /> ]<br /> <br /> <br /> <br /> <br /> <br /> rank by [SCTR]<br /> <br /> #and [[exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX] or [exchange is LSE]]<br /> <br /> <p dir="auto"><br /> <p dir="auto"><br /> <p dir="auto"><br /> <p dir="auto"><br /> <p dir="auto"><br /> <p dir="auto"><br />