예스스탁
예스스탁 답변
2024-12-09 11:19:01
안녕하세요
예스스탁입니다.
input : length(70);
input : maType (2); #1: SMA, 2:EMA, 3:SMMA, 4:WMA, 5:VWMA
input : offset(0);
input : show_HB(false);
input : col_trnd_Up(Green);
input : col_trnd_Dn(Red);
var : Ema1(0),Ema2(0);
var : src(0),alpha(0),basis(0);
var : trend_up(False),trend_dn(False),trend_up1(False),trend_dn1(False);
var : upperbreak(False),lowerbreak(False),tx1(0),tx2(0);
src = (O+H+C+C)/4;
ema1 = ema((O+H+C+C)/4, 50);
ema2 = ema((O+H+C+C)/4, 200);
if maType <= 1 then
basis = ma(c, length);
if maType == 2 then
basis = ema(c, length);
if maType == 3 then
{
alpha = 1/length;
basis = IFf(IsNan(basis[1]) == true, ma(c, length) , alpha * c + (1 - alpha) * IFf(IsNan(basis[1]) ==true,0,basis[1]));
}
if maType == 4 then
basis = wma(c, length);
if maType >= 5 then
basis = ma(c * volume, length) / ma(volume, length);
//Signals
trend_up = close > basis;
trend_dn = close < basis;
trend_up1 = CrossUp(close, basis);
trend_dn1 = CrossDown(close, basis);
plot1(ema1, "EMA1", Blue);
plot2(ema2, "EMA2", red);
input : mult(1.0);
var :dev(0),upper(0),lower(0);
dev = mult * std(src, length);
upper = basis + dev;
lower = basis - dev;
plot3(basis, "Basis", rgb(255, 255, 255));
plot4(upper, "Upper1", rgb(246, 125, 135));
plot5(lower, "Lower1", rgb(165, 249, 135));
input : mult1(2.0);
var : dev1(0),upper1(0),lower1(0);
dev1 = mult1 * std(src, length);
upper1 = basis + dev1;
lower1 = basis - dev1;
plot6(upper1, "Upper2", rgb(246, 125, 135));
plot7(lower1, "Lower2", rgb(165, 249, 135));
//Bands3
input : mult2(3.0);
var : dev2(0),upper2(0),lower2(0);
dev2 = mult2 * std(src, length);
upper2 = basis + dev2;
lower2 = basis - dev2;
plot8(upper2, "Upper3", rgb(246, 125, 135));
plot9(lower2, "Lower3", rgb(165, 249, 135));
//Bands3
input : mult3(3.5);
var : dev3(0),upper3(0),lower3(0);
dev3 = mult3 * std(src, length);
upper3 = basis + dev3;
lower3 = basis - dev3;
plot10(upper3, "Upper4", rgb(246, 125, 135));
plot11(lower3, "Lower4", rgb(165, 249, 135));
upperbreak = close > upper3;
lowerbreak = close < lower3;
if trend_up1 Then
{
tx1 = Text_New(sDate,sTime,L,"▲");
Text_SetStyle(tx1,2,0);
Text_SetColor(tx1,Red);
}
if trend_dn1 Then
{
tx1 = Text_New(sDate,sTime,H,"▼");
Text_SetStyle(tx1,2,1);
Text_SetColor(tx1,Blue);
}
if upperbreak Then
{
tx2 = Text_New(sDate,sTime,H,"●");
Text_SetStyle(tx2,2,1);
Text_SetColor(tx2,rgb(246, 125, 135));
}
if lowerbreak Then
{
tx2 = Text_New(sDate,sTime,L,"●");
Text_SetStyle(tx2,2,0);
Text_SetColor(tx2,rgb(165, 249, 135));
}
즐거운 하루되세요
> 고박사122 님이 쓴 글입니다.
> 제목 : 수식전환 요청드립니다.
> 안녕하세요.
아래 트레이딩뷰 수식을 예스트레이더 형식으로 변환을 부탁드립니다.
감사합니다.
//@version=5
indicator(shorttitle="E9 BRange", title="E9 Bollinger Range", overlay=true, timeframe="", timeframe_gaps=true)
//input parameters
length = input.int(70, minval=1)
maType = input.string("EMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(ohlc4, title="Source")
offset = input.int(0, "Offset", minval = -500, maxval = 500, display = display.data_window)
show_HB = input.bool(false, title="Show Highlight Price Bars")
col_trnd_Up = input.color(#97ff9c, "Trend Up")
col_trnd_Dn = input.color(color.rgb(250, 86, 143), "Trend Down")
ema1 = ta.ema(ohlc4, 50)
ema2 = ta.ema(ohlc4, 200)
ma(source, length, _type) =>
switch _type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
basis = ma(src, length, maType)
//Signals
trend_up = close > basis
trend_dn = close < basis
trend_up1 = ta.crossover(close, basis)
trend_dn1 = ta.crossunder(close, basis)
//EMA's
MA1 = plot(ema1, "EMA1", color = #4136e8, linewidth = 3)
MA2 = plot(ema2, "EMA2", color = color.red, linewidth = 3)
//Bands1
mult = input.float(1.0, minval=0.001, maxval=50, title="StdDev Bands 1")
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
plot(basis, "Basis", color=color.rgb(255, 255, 255), offset = offset)
p1 = plot(upper, "Upper", color=color.rgb(246, 125, 135, 100), offset = offset)
p2 = plot(lower, "Lower", color=color.rgb(165, 249, 135, 100), offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(255, 255, 255, 82))
//Bands2
mult1 = input.float(2.0, minval=0.001, maxval=50, title="StdDev Bands 2")
dev1 = mult1 * ta.stdev(src, length)
upper1 = basis + dev1
lower1 = basis - dev1
p3 = plot(upper1, "Upper", color=color.rgb(246, 125, 135, 100), offset = offset)
p4 = plot(lower1, "Lower", color=color.rgb(165, 249, 135, 100), offset = offset)
fill(p3, p4, title = "Background", color=color.rgb(255, 255, 255, 84))
//Bands3
mult2 = input.float(3.0, minval=0.001, maxval=50, title="StdDev Bands 3")
dev2 = mult2 * ta.stdev(src, length)
upper2 = basis + dev2
lower2 = basis - dev2
p5 = plot(upper2, "Upper", color=#f67d87, offset = offset)
p6 = plot(lower2, "Lower", color=#a5f987, offset = offset)
fill(p5, p6, title = "Background", color=#ffffff0d)
//Bands3
mult3 = input.float(3.5, minval=0.001, maxval=50, title="StdDev Bands 4")
dev3 = mult3 * ta.stdev(src, length)
upper3 = basis + dev3
lower3 = basis - dev3
p7 = plot(upper3, "Upper", color=#f67d87, linewidth = 2, offset = offset)
p8 = plot(lower3, "Lower", color=#a5f987, linewidth = 2, offset = offset)
fill(p7, p8, title = "Background", color=#ffffff0d)
//Signals 2
upperbreak = close > upper3
lowerbreak = close < lower3
// Bar Color Function
barColor() =>
trend_up ? col_trnd_Up : trend_dn ? col_trnd_Dn : na
barcolor(show_HB ? barColor() : na, title="Trend Bars")
//Trendchange
plotshape(trend_up1, "Signal Arrows Up", style = shape.triangleup, location = location.belowbar, color = color.white, size = size.tiny)
plotshape(trend_dn1, "Signal Arrows Down", style = shape.triangledown, location = location.abovebar, color = color.white, size = size.tiny)
//Extension
plotshape(upperbreak, "Extension Dots Upper", style = shape.circle, location = location.abovebar, color = #f67b7b, size = size.tiny)
plotshape(lowerbreak, "Extension Dots Lower", style = shape.circle, location = location.belowbar, color = #a4f67b, size = size.tiny)