0 beğenilme 0 beğenilmeme
165 kez görüntülendi
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=5

indicator('TrendLiner+QnR', overlay=true)

tl = input.int(defval=2, title='Period', minval=1, maxval=500)

tl2 = input.int(defval=68, title='Period2', minval=1, maxval=500)

tlc = input.float(defval=1.7, title='Çarpan', minval=0.1)

mumrenk = input(true, title='Mum Rengi')

 

ilk = ta.highest(high - tlc * ta.atr(tl), tl2)

ta.barssince(close > ta.highest(high - tlc * ta.atr(tl), tl2) and close > close[1])

cum_1 = ta.cum(1)

highest_1 = ta.highest(high - tlc * ta.atr(tl), tl2)

highest_2 = ta.highest(high - tlc * ta.atr(tl), tl2)

iff_1 = close > highest_1 and close > close[1] ? highest_2 : ilk

h1 = cum_1 < 16 ? close : iff_1

 

iff_2 = close < h1 ? color.red : color.black

rk = close > h1 ? color.green : iff_2

barcolor(mumrenk ? rk : na)

plot(h1, color=rk, linewidth=3, title='TrendLiner')

 

AL = ta.crossover(close, h1)

SAT = ta.crossunder(close, h1)

 

//plotshape(AL,"AL", shape.labelup, location.belowbar, color.green, text="AL",textcolor=color.blue)

//plotshape(SAT,"SAT", shape.labeldown, location.abovebar, color.red, text="SAT",textcolor=color.red)

 

//alertcondition(AL, "AL", "AL")

//alertcondition(SAT, "SAT", "SAT")

h2 = h1 * 1.10

plot(h2, color=rk, linewidth=1, title='TrendLinerExt', style=plot.style_linebr)

h3 = h1 * 0.90

plot(h3, color=rk, linewidth=1, title='TrendLinerMin', style=plot.style_linebr)

 

 

 

///////////////////////////////////////////

 

src = input.source(close, 'Source')

h = input.float(23, 'Lookback Window', minval=3., tooltip='The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars. Recommended range: 3-50')

r = input.float(23, 'Relative Weighting', step=0.25, tooltip='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')

x_0 = input.int(23, "Start Regression at Bar", tooltip='Bar index on which to start regression. The first bars of a chart are often highly volatile, and omission of these initial bars often leads to a better overall fit. Recommended range: 5-25')

smoothColors = input.bool(false, "Smooth Colors", tooltip="Uses a crossover based mechanism to determine colors. This often results in less color transitions overall.", inline='1', group='Colors')

lag = input.int(0, "Lag", tooltip="Lag for crossover detection. Lower values result in earlier crossovers. Recommended range: 1-2", inline='1', group='Colors')

size = array.size(array.from(src)) // size of the data series

 

// Further Reading:

// The Kernel Cookbook: Advice on Covariance functions. David Duvenaud. Published June 2014.

// Estimation of the bandwidth parameter in Nadaraya-Watson kernel non-parametric regression based on universal threshold level. Ali T, Heyam Abd Al-Majeed Hayawi, Botani I. Published February 26, 2021.

kernel_regression(_src, _size, _h) =>

    float _currentWeight = 0.

    float _cumulativeWeight = 0.

    for i = 0 to _size + x_0

        y = _src[i]

        w = math.pow(1 + (math.pow(i, 2) / ((math.pow(_h, 2) * 2 * r))), -r)

        _currentWeight += y*w

        _cumulativeWeight += w

    _currentWeight / _cumulativeWeight

 

// Estimations

yhat1 = kernel_regression(src, size, h)

yhat2 = kernel_regression(src, size, h-lag)

 

// Rates of Change

bool wasBearish = yhat1[2] > yhat1[1]

bool wasBullish = yhat1[2] < yhat1[1]

bool isBearish = yhat1[1] > yhat1

bool isBullish = yhat1[1] < yhat1

bool isBearishChange = isBearish and wasBullish

bool isBullishChange = isBullish and wasBearish

 

// Crossovers

bool isBullishCross = ta.crossover(yhat2, yhat1)

bool isBearishCross = ta.crossunder(yhat2, yhat1)

bool isBullishSmooth = yhat2 > yhat1

bool isBearishSmooth = yhat2 < yhat1

 

// Colors

color c_bullish = input.color(color.rgb(34, 0, 255), 'Bullish Color', group='Colors')

color c_bearish = input.color(#FD1707, 'Bearish Color', group='Colors')

color colorByCross = isBullishSmooth ? c_bullish : c_bearish

color colorByRate = isBullish ? c_bullish : c_bearish

color plotColor = smoothColors ? colorByCross : colorByRate

 

// Plot

plot(yhat1, "Fin[QnR]", color=plotColor, linewidth=2, style=plot.style_linebr   )

 

// Alert Variables

bool alertBullish = smoothColors ? isBearishCross : isBearishChange

bool alertBearish = smoothColors ? isBullishCross : isBullishChange

 

// Alerts for Color Changes

alertcondition(condition=alertBullish, title='Bearish Color Change', message='Nadaraya-Watson: {{ticker}} ({{interval}}) turned Bearish ▼')

alertcondition(condition=alertBearish, title='Bullish Color Change', message='Nadaraya-Watson: {{ticker}} ({{interval}}) turned Bullish ▲')

 

// Non-Displayed Plot Outputs (i.e., for use in other indicators)

plot(alertBearish ? -1 : alertBullish ? 1 : 0, "Alert Stream", display=display.none)

//////////////////////////////////////////////

 

alimsart = bool(na)

satimsart = bool(na)

alimsart := close > h1 * 1.02 and close > close[1]

satimsart := close < h1 and close < yhat1 and yhat1 < yhat1[1]

kondisyon = 0

kondisyon := alimsart ? 1 : satimsart ? -1 : kondisyon[1]

alimkondisyon = alimsart and kondisyon[1] == -1

satimkondisyon = satimsart and kondisyon[1] == 1

plotshape(alimkondisyon, title='Al Sinyali', text='AL', textcolor=color.new(color.white, 20), style=shape.labelup, size=size.small, location=location.belowbar, color=color.new(color.navy, 20))

plotshape(satimkondisyon, title='Sat Sinyali', text='SAT', textcolor=color.new(color.white, 20), style=shape.labeldown, size=size.small, location=location.abovebar, color=color.new(color.red, 20))

 

 

 

 

cro= alimkondisyon

cru= satimkondisyon

direction = 0

direction := cro ? 1 : cru ? -1 : direction[1]

 

string gr_sc = 'TARAYICI'

string gr_sy = 'SIMGE'

string t00 = 'TRL+QnR TARAMA LİSTESİ'

color c00 = #686868

lb_sh = input.bool(title='Etiket Göster', defval=true, group=gr_sc)

lb_sz = input.string(title='Etiket Boyu', options=['Auto', 'Minik', 'Küçük', 'Normal', 'Büyük', 'EnBüyük'], defval='Normal', group=gr_sc)

lb_xa = input.int(title='Yatay Eksen', defval=20, group=gr_sc, tooltip='X Ekseni Etiket Yerleşimi')

lb_ya = input.int(title='Dikey Eksen', defval=1, group=gr_sc, tooltip='Y Ekseni Etiket Yerleşimi')

lb_cl = input.color(title='Renkler', defval=#00bb00, group=gr_sc, inline='0')
Indikator Builder kategorisinde (12 puan) tarafından | 165 kez görüntülendi

Bu soruya cevap vermek için lütfen giriş yapınız veya kayıt olunuz.

9,290 soru
9,246 cevap
5,059 yorum
31,729 kullanıcı