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. 

 

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. 


Please note that the code doesn't accurately calculate Heikin Ashi due to some limitation on the language provided by Stockcharts programmable filters.

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.


As usual, if you find this beneficial to your trading, please don't forget to resteem and upvote this post.


Code: First Heikin-Ashi green candle that recently dipped to 20SMA.

[type = stock] 



# Only securities with options

and [optionable is true]



# High liquidity

and [SMA(50,close) * SMA(50,volume) > 500000]







#########

# Uptrend #

#########



# MA levels in positive alignment

and [today's sma(20,close) > today's sma(40,close)]

and [today's sma(40,close) > today's sma(100,close)]  

and [today's sma(100,close) > today's sma(200,close)]  





##########

# Pullback  #

##########



# Recently dipped into 20 SMA

and [

 [4 day's ago Low < 4 day's ago sma(20,close)]

 or [3 day's ago Low < 3 day's ago sma(20,close)]

 or [2 day's ago Low < 2 day's ago sma(20,close)]

 or [yesterday's Low < yesterday's sma(20,close)]

]



# But for this strategy we don't want dips that go too low and could possibly be the start of a major downtrend.  

# Our focus is to ride on the larger trend and buying on the smaller dips to the means.

and [

[5 day's ago Low > 5 day's ago sma(100,close)]  

and [4 day's ago Low > 4 day's ago sma(100,close)]

and [3 day's ago Low > 3 day's ago sma(100,close)]

and [2 day's ago Low > 2 day's ago sma(100,close)]

]





########################################

# Determine if it's the first green Heikin Ashi candle #

########################################



# NOTE: My calculation for first Heikin Ashi isn't precise. Use visual confirmation from the results.



# Determine if today's Heikin Ashi is green by checking if today's HA Open is higher than Close

# HA calculation is normally  a loop that depends on previous candles parameters until the end of the chart.

# Stockcharts doesn't support a pseudo-loop so I'm only calculating up to 3 candles back.



and [

# Today's HA-Open

[

 [

   # Yesterday's HA-Close

   [

    [2 day's ago  open + 2 day's ago  close + 2 day's ago  high + 2 day's ago low]/4]

   +

   # Yesterday's HA-Open (2 day's ago HA-Open + 2 day's ago HA-Close)/2

   [

     [

      # 2 day's ago HA-Open

       [   [[ 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  ]

     +

      # 2 day's ago HA-Close

      [ [2 day's ago  open + 2 day's ago  close + 2 day's ago  high + 2 day's ago low]/4]

     ]

     # Average

     / 2

   ]

 ]

 # Average

/ 2

]

<

# Today's HA-Close

[

  [Open + Close + High + Low]/4

]   

]





# Determine if yesterday's Heikin Ashi candle is red.

and [

[

 [

    [[3 day's ago  open + 3 day's ago  close + 3 day's ago  high + 3 day's ago low]/4]

  +

   [

     [

       [   [[ 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  ]

     +

      [ [3 day's ago  open + 3 day's ago  close + 3 day's ago  high + 3 day's ago low]/4]

     ]

     / 2

   ]

 ]

/ 2

]

>

[ [Yesterday's Open + Yesterday's Close + Yesterday's High + Yesterday's Low]/4 ]   

]





rank by [SCTR]

#and [[exchange is NYSE] or [exchange is NASDAQ] or [exchange is AMEX] or [exchange is LSE]]







Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 99341.76
ETH 3285.44
USDT 1.00
SBD 3.05