Ni6HTH4wK

[LAVA] Heiken Ashi Re-Enter Levels

383
Using Heiken Ashi at customizable higher intervals and some standard deviation of candle lengths, some of the guesswork of picking tops and bottoms can be reduced using this tool.

This indicator is a variation of another tool that I plan on certifying as a low-cost subscription option.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
// Tradingview.com Pinescript @author Ni6HTH4wK [LAVA]
study(title="[LAVA] Heiken Ashi Re-Enter Levels", overlay=true)

// Inputs
n1  = input(20, title="Multiplier", minval=1)
n2  = input(100, title="Trend Length", minval=1)

// Sources
hk_open = security(heikenashi(tickerid), tostring((interval*n1)), open)
hk_stop = security(heikenashi(tickerid), tostring((interval*n1)), close)
hk_local_open = na(hk_open[1])?open:(hk_open[1]+ohlc4[1])/2
hk_local_stop = ohlc4
hk_cci = cci(ohlc4, n1)

// Source logic
oc2 = avg(hk_open,hk_stop)
oc_hi = max(hk_local_open,hk_local_stop)
oc_lo = min(hk_local_open,hk_local_stop)
oc_dif = avg(oc_hi-oc_lo, high-low)
dif_ema = ema(oc_dif, 14)
std_dev = stdev(dif_ema, 20)*3+dif_ema

// Heiken Ashi Logic
hk_bull = hk_stop>hk_open?low>=hk_open?3*std_dev+hk_bull[1]:1*std_dev+hk_bull[1]:0
hk_bear = hk_open>hk_stop?high<=hk_open?3*std_dev+hk_bear[1]:1*std_dev+hk_bear[1]:0
hk_bearfish = sma(hk_bear, n2)
hk_bearwale = sma(hk_bearfish, n2*2)
hk_bullfish = sma(hk_bull, n2)
hk_bullwale = sma(hk_bullfish, n2*2)
hk_bot  = hk_bullfish>hk_bullwale?hk_bull and hk_cci<0?oc2-std_dev:0:0
hk_top  = hk_bearfish>hk_bearwale?hk_bear and hk_cci>0?oc2+std_dev:0:0

// Plotting
plot(hk_top>0?hk_top:na, title="Bearish Tops", color=red, style=circles, linewidth=2)
plot(hk_bot>0?hk_bot:na, title="Bullish Bottoms", color=green, style=circles, linewidth=2)