TradingView
veryfid
2023년 5월 25일 오전 8시 49분

Kernel Regression Toolkit 

Bitcoin all time history indexINDEX

설명

This toolkit provides filters and extra functionality for non-repainting Nadaraya-Watson estimator implementations made by @jdehorty. For the sake of ease I have nicknamed it "kreg". Filters include a smoothing formula and zero lag formula. The purpose of this script is to help traders test, experiment and develop different regression lines. Regression lines are best used as trend lines and can be an invaluable asset for quickly locating first pullbacks and breaks of trends.
Other features include two J lines and a blend line. J lines are featured in tools like Stochastic KDJ. The formula uses the distance between K and D lines to make the J line. The blend line adds the ability to blend two lines together. This can be useful for several tasks including finding a center/median line between two lines or for blending in the characteristics of a different line. Default is set to 50 which is a 50% blend of the two lines. This can be increased and decreased to taste. This tool can be overlaid on the chart or on top of another indicator if you set the source. It can even be moved into its own window to create a unique oscillator based on whatever sources you feed it.

Below are the standard settings for the kernel estimation as documented by @jdehorty:
Lookback Window: The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars. Recommended range: 3-50

Weighting: Relative weighting of time frames. As this value approaches zero, the longer time frames will exert more influence on the estimation. As this value approaches infinity, the behavior of the Rational Quadratic Kernel will become identical to the Gaussian kernel. Recommended range: 0.25-25

Level: Bar index on which to start regression. Controls how tightly fit the kernel estimate is to the data. Smaller values are a tighter fit. Larger values are a looser fit. Recommended range: 2-25

Lag: Lag for crossover detection. Lower values result in earlier crossovers. Recommended range: 1-2

For more information on this technique refer to to the original open source indicator by @jdehorty located here:
https://www.tradingview.com/script/AWNvbPRM-Nadaraya-Watson-Rational-Quadratic-Kernel-Non-Repainting/
코멘트
jdehorty
Great work!
veryfid
@jdehorty, Hi, thanks for the coins and all your hard work that went into the development of this kernel regression. It is an amazingly powerful tool.
PineCoders
djmad
Great Kernels, thx a lot for sharing
veryfid
Hi @djmad, thanks for the coins. Looking forward to seeing what you make next.
djmad
@veryfid, already cooking :-)
Mmp13800831
//@version=4
strategy(title = "SuperTREX strategy", overlay = true, pyramiding=1,initial_capital = 10000, default_qty_type= strategy.percent_of_equity, default_qty_value = 10, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.075)
strat_dir_input = input(title="Strategy Direction", defval="long", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)
length = input( 14 )
overSold = input( 35 )
overBought = input( 70 )
HTF = input("W", type=input.resolution)
ti = change( time(HTF) ) != 0
p = fixnan( ti ? close : na )

vrsi = rsi(p, length)
price = close
var bool long = na
var bool short = na

long :=crossover(vrsi,overSold)
short := crossunder(vrsi,overBought)

var float last_open_long = na
var float last_open_short = na

last_open_long := long ? close : nz(last_open_long[1])
last_open_short := short ? close : nz(last_open_short[1])

entry_value =last_open_long
entry_value1=last_open_short

xy=(entry_value+entry_value)/2

// INPUTS //
st_mult = input(4, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(10, title = 'SuperTrend Period', minval = 1)

// CALCULATIONS //
up_lev =xy - (st_mult * atr(st_period))
dn_lev =xy + (st_mult * atr(st_period))

up_trend = 0.0
up_trend := entry_value[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev

down_trend = 0.0
down_trend := entry_value1[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev

// Calculate trend var
trend = 0
trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(trend[1], 1)

// Calculate SuperTrend Line
st_line = trend ==1 ? up_trend : down_trend
plot(xy,color = trend == 1 ? color.green : color.red)

buy=crossover( close, st_line)
sell1=crossunder(close, st_line)

buy1=buy
//

sell=sell1

// STRATEGY

plotshape(buy , title="buy", text="Buy", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0) //plot for buy icon
plotshape(sell, title="sell", text="Sell", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0) //plot for sell icon
// Take profit

//
l = buy
s1=sell
if l
strategy.entry("buy", strategy.long)
if s1
strategy.entry("sell", strategy.short)
per(pcnt) =>
strategy.position_size != 0 ? round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)
stoploss=input(title=" stop loss", defval=25, minval=0.01)
los = per(stoploss)
q1=input(title=" qty_percent1", defval=25, minval=1)
q2=input(title=" qty_percent2", defval=25, minval=1)
q3=input(title=" qty_percent3", defval=25, minval=1)
tp1=input(title=" Take profit1", defval=2, minval=0.01)
tp2=i
bradleypout120
Rest in peace, veryfid. Your brilliant mind and dedication to creating the best tradingview indicators have helped countless people. Your indicators, like Boom Hunter, have made trading more accessible and profitable for everyone. We will miss you and your contributions to the trading community.
s06565619
@bradleypout120, what happened bro
Omni-Trading
@bradleypout120, Id also second to know if hes still around?
더보기