TradingView
sebastinecc
28 apr 2023 03:41

Sebastine Trend Catcher 

S&P 500SP

Beskrivning

Sebastine Trend Catcher captures trends in any time frame in a very simple fashion. Green line crossing up above the signal zero line is uptrend. Red line crossing down the signal zero line is downtrend. The indicator line is presented by default as a step line, which gives an idea on how the trend moves inside the bigger trend. But it should be specifically understood that a trend starts only when the indicator crosses the signal zero line. The ups and downs in the indicator step line until crossing signal zero line is only small corrections and bounces inside a trend. Sebastine trend catcher captures trends smoothing prices in 2 steps. The indicator banks profusely on the idea of jackvmk’s Heiken Ashi Candles. The indicator presented in a centred oscillator fashion in a bottom panel helps understand the main trend and its different shades inside the trend in a clearly discernible manner with sharp entry signals when crossing zero line. The indicator could be used from Daytrading to Investment Trading. As usual this indicator too could produce overshoots and error signals and be better used with other indicators. The settings can be varied and experimented for any given scrip, timeframe or stock exchange.
Kommentarer
gu5tavo71
Nice work!
sebastinecc
@gu5tavo71, Thanks
BehCrypto
Hi,
I liked your idea so i rewrote the code with a few more comments and slightly better naming for the variables.
Hope this is useful for others:

//@version=5
indicator("Sebastine Trend Catcher", overlay=false, shorttitle="STC")

// User Inputs
len_basicEMA = input(5, title="Length for basic EMA")
len_haEMA = input(5, title="Length for Heikin-Ashi EMA")

// Basic EMA Calculations
basic_openEMA = ta.ema(open, len_basicEMA)
basic_closeEMA = ta.ema(close, len_basicEMA)
basic_highEMA = ta.ema(high, len_basicEMA)
basic_lowEMA = ta.ema(low, len_basicEMA)

// Heikin-Ashi Calculations
ha_close = (basic_openEMA + basic_highEMA + basic_lowEMA + basic_closeEMA) / 4

// Initialize ha_open with a mutable variable
var float ha_open = na
ha_open := na(ha_open[1]) ? (basic_openEMA + basic_closeEMA) / 2 : (ha_open[1] + ha_close[1]) / 2

ha_high = math.max(basic_highEMA, math.max(ha_open, ha_close))
ha_low = math.min(basic_lowEMA, math.min(ha_open, ha_close))

// Heikin-Ashi EMA Calculations
ha_openEMA = ta.ema(ha_open, len_haEMA)
ha_closeEMA = ta.ema(ha_close, len_haEMA)
ha_highEMA = ta.ema(ha_high, len_haEMA)
ha_lowEMA = ta.ema(ha_low, len_haEMA)

// Sebastine Indicator Calculation
sebastine_value = ((ha_closeEMA / ha_openEMA) - 1) * 100

// Plotting Logic
sebastine_color = sebastine_value >= 0 ? color.green : color.red

plot(sebastine_value, color=sebastine_color, linewidth=2, title="Sebastine Value", style=plot.style_stepline)
hline(0, title="Zero Line", color=color.white, linestyle=hline.style_dashed, linewidth=2)
sebastinecc
@BehCrypto, Appreciate! I am thinking of a way to circumvent a barbed wire type overshooting or undershooting of the zero line, which might misdirect decision. Something like standard deviation or an appropriate band on top and bottom of zero line. Any idea? Thanks for the suggestions!
BehCrypto
@sebastinecc, I did not really understand your point. If you can explain it more, maybe I can help rewrite the code.
sebastinecc
@BehCrypto, The indicator sometimes shoots just above the zeroline or shoots just down the zero line giving fake signals. So I am thinking of a way to filter such fake signals. Giving a band around the zero line is what I propose. Thanks for the reply.
BehCrypto
@sebastinecc, Sorry for my late replies. I don't check these messages as often. can you maybe post a screen shot of when this happens so i can see what the actual issue is and how we could fix it.
GeriCom76
@sebastinecc,
The idea is good. I tried it previously on one of my script to set above and below zero line a filter line. Signal only appear when the indicator line crosses it over or under.
Pros: filter ot most of false signals
Cons: late signal to buy or sell.
Need to use other indicators to catch proper signals.
GeriCom76
@GeriCom76,
BTW the script itself is quite good, I'll use it! :-)
Thanks @sebastinecc , @BehCrypto
sebastinecc
@GeriCom76, I have used step-lines with a purpose. Its climbing up or climbing down before zero line is an indicator of correction/consolidation. It gives buy/sell signals on a smoothed 5 min ema(default), which I feel is reasonably fast,meanwhile eliminating most of false signals, as you appreciate. What signals/indicators could be faster?
Mer