예스스탁
예스스탁 답변
2025-05-26 14:40:18
안녕하세요
예스스탁입니다.
input : length1(120);
input : length2(12);
input : maInput(1); #1 :EMA, 2:SMA, 3:VWMA, 4:WMA;
var : src(0),ma1(0),ma2(0);
src = (h+L)/2;
if maInput == 1 Then
{
ma1 = Ema(c,length1);
ma2 = Ema(ma1,length2);
}
if maInput == 2 Then
{
ma1 = ma(c,length1);
ma2 = ma(ma1,length2);
}
if maInput == 3 Then
{
ma1 = ma(c * volume, length1) / ma(volume, length1);
ma2 = ma(ma1 * volume, length2) / ma(volume, length2);
}
if maInput == 4 Then
{
ma1 = wma(c,length1);
ma2 = wma(ma1,length2);
}
var : lambda(0),alpha(0),nma(0);
lambda = length1 / length2;
alpha = lambda * (length1 - 1) / (length1 - lambda);
nma = (1 + alpha) * ma1 - alpha * ma2;
plot1(nma, "NMA Black Line",black);
input : lenvwap(1);
input : offsetvwap(0);
var : srcla(0),srcvwap(0),vvwap(0),line1(0);
srcla = close;
srcvwap = (h+l+c)/3;
if Bdate != Bdate[1] Then
{
var1 = 0;
var2 = 0;
}
var1 = var1 + (srcvwap*v);
var2 = var2 + v;
vvwap = var1/var2;
line1 = ma(srcla, lenvwap);
plot2(vvwap,"VWAP MIDDLE",Red);
var : emaSource(0),emaPeriod(0),devMultiple(0),baseline(0);
var : stdDeviation(0),upperBand(0),lowerBand(0);
emaSource = close;
emaPeriod = 20;
devMultiple = 2;
baseline = ma(emaSource, emaPeriod);
plot3(baseline, "BB Red Line", red);
stdDeviation = devMultiple * (std(emaSource, emaPeriod));
upperBand = (baseline + stdDeviation);
lowerBand = (baseline - stdDeviation);
plot4(upperBand, "BB Top", blue);
plot5(lowerBand, "BB Bottom", Violet);
//HULL TREND WITH KAHLMAN
input : lengthhull(24);
input : showcross(true);
input : gain(10000);
input : k(true);
var : srchull(0),Hma(0),p(0),hma3(0);
srchull = (H+L)/2;
hma = wma((2 * wma(srchull, lengthhull / 2)) - wma(srchull, lengthhull), round(sqrt(lengthhull),0)) ;
p = lengthhull/2;
hma3 = wma(wma(close,p/3)*3 - wma(close,p/2) - wma(close,p),p);
var : kf1(0),dk1(0),smooth1(0),velo1(0);
var : kf2(0),dk2(0),smooth2(0),velo2(0);
kf1 = 0.0;
dk1 = hma - iff(isnan(kf1[1]) ==true, hma,kf1[1]);
smooth1 = iff(isnan(kf1[1]) ==true, hma,kf1[1])+dk1*sqrt((gain/10000)*2);
velo1 = 0.0;
velo1 = IFf(IsNan(velo1[1]) ==true,0,velo1[1]) + ((gain/10000)*dk1);
kf1 = smooth1+velo1;
kf2 = 0.0;
dk2 = hma3 - iff(isnan(kf2[1]) ==true, hma3,kf2[1]);
smooth2 = iff(isnan(kf2[1]) ==true, hma3,kf2[1])+dk2*sqrt((gain/10000)*2);
velo2 = 0.0;
velo2 = IFf(IsNan(velo2[1]) ==true,0,velo2[1]) + ((gain/10000)*dk2);
kf2 = smooth2+velo2;
var :aa(0),bb(0),cc(0);
aa = iff(k , kf1 , hma);
bb = iff(k , kf2 , hma3);
cc = iff(bb > aa , lime , red);
plot6(aa,"Long Plot",cc);
plot7(bb,"Short Plot",cc);
즐거운 하루되세요
> 파생돌이 님이 쓴 글입니다.
> 제목 : 부틱드립니다
> 수고하십니다
아래수식을 예스로 부탁드립니다
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Adarsh
//@version=4
// Moving Average 3.0 (3rd Generation) s cript may be freely distributed under the MIT license. Copyright (c) 2018-present, Alex Orekhov (everget)
study("IDEAL BB with MA (With Alerts) by Adarsh", overlay=true)
length1 = input(title="1st Length", type=input.integer, minval=1, defval=120)
length2 = input(title="2nd Length", type=input.integer, minval=1, defval=12)
maInput = input(title="MA Type", defval="EMA", options=["EMA", "SMA", "VWMA", "WMA"])
src = input(title="Source", type=input.source, defval=hl2)
getMA(src, length) =>
ma = 0.0
if maInput == "EMA"
ma := ema(src, length)
if maInput == "SMA"
ma := sma(src, length)
if maInput == "VWMA"
ma := vwma(src, length)
if maInput == "WMA"
ma := wma(src, length)
ma
getNMA(src, length1, length2) =>
lambda = length1 / length2
alpha = lambda * (length1 - 1) / (length1 - lambda)
ma1 = getMA(src, length1)
ma2 = getMA(ma1, length2)
nma = (1 + alpha) * ma1 - alpha * ma2
nma = getNMA(src, length1, length2)
//emaLength = input(90, minval=1, title="EMA Length")
//emaSource = input(close, title="EMA Source")
//ema = ema(emaSource, emaLength)
plot(nma, title="NMA Black Line", linewidth=2, style=plot.style_stepline, color=color.black, transp=0)
//plot(ema, title="EMA", linewidth=1, color=color.red, transp=0)
//VWAP BANDS
lenvwap = input(1, minval=1, title="VWAP Length")
src1a = input(close, title="VWAP Source")
offsetvwap = input(title="VWAP Offset", type=input.integer, defval=0, minval=-500, maxval=500)
srcvwap = hlc3
vvwap = vwap(srcvwap)
line1 = sma(src1a, lenvwap)
plot(vvwap, color=#e91e63, linewidth=2, style=plot.style_line, title="VWAP MIDDLE")
// Boll Bands
emaSource = close
emaPeriod = 20
devMultiple = 2
baseline = sma(emaSource, emaPeriod)
plot(baseline, title = "BB Red Line", color = color.red)
stdDeviation = devMultiple * (stdev(emaSource, emaPeriod))
upperBand = (baseline + stdDeviation)
lowerBand = (baseline - stdDeviation)
p1 = plot(upperBand, title = "BB Top", color = color.blue)
p2 = plot(lowerBand, title = "BB Bottom", color = #311b92)
fill(p1, p2, color = color.blue)
//HULL TREND WITH KAHLMAN
srchull = input(hl2, "Price Data")
lengthhull = input(24, "Lookback")
showcross = input(true, "Show cross over/under")
gain = input(10000, "Gain")
k = input(true, "Use Kahlman")
hma(_srchull, _lengthhull) =>
wma((2 * wma(_srchull, _lengthhull / 2)) - wma(_srchull, _lengthhull), round(sqrt(_lengthhull)))
hma3(_srchull, _lengthhull) =>
p = lengthhull/2
wma(wma(close,p/3)*3 - wma(close,p/2) - wma(close,p),p)
kahlman(x, g) =>
kf = 0.0
dk = x - nz(kf[1], x)
smooth = nz(kf[1],x)+dk*sqrt((g/10000)*2)
velo = 0.0
velo := nz(velo[1],0) + ((g/10000)*dk)
kf := smooth+velo
a = k ? kahlman(hma(srchull, lengthhull), gain) : hma(srchull, lengthhull)
b = k ? kahlman(hma3(srchull, lengthhull), gain) : hma3(srchull, lengthhull)
c = b > a ? color.lime : color.red
crossdn = a > b and a[1] < b[1]
crossup = b > a and b[1] < a[1]
p1hma = plot(a,color=c,linewidth=1,transp=75, title="Long Plot")
p2hma = plot(b,color=c,linewidth=1,transp=75, title="Short Plot")
fill(p1hma,p2hma,color=c,transp=55,title="Fill")
plotshape(showcross and crossdn ? a : na, location=location.abovebar, style=shape.labeldown, color=color.red, size=size.tiny, text="Sell", textcolor=color.white, transp=0, offset=-1)
plotshape(showcross and crossup ? a : na, location=location.belowbar, style=shape.labelup, color=color.green, size=size.tiny, text="Buy", textcolor=color.white, transp=0, offset=-1)
//ALERTS
alertcondition(crossup, title='Buy', message='Go Long')
alertcondition(crossdn, title='Sell', message='Go Short')