예스스탁
예스스탁 답변
2025-09-16 13:46:29.0
안녕하세요
예스스탁입니다.
input : length(100);
var : cumVol(0),src(0),obv(0);
var : highest_in_length(0),highest_in_length_avg(0),lowest_in_length(0);
var : lowest_in_length_avg(0),avg_range(0),middle_line(0),normalized_obv(0);
cumVol = cumVol+ volume;
src = close;
obv = Accum(sin(src-src[1]) * volume);
highest_in_length = highest(obv,length);
highest_in_length_avg = ema(highest_in_length,length);
lowest_in_length = lowest(obv,length);
lowest_in_length_avg = ema(lowest_in_length,length);
avg_range = highest_in_length_avg - lowest_in_length_avg;
middle_line = avg_range/2;
normalized_obv = iff(obv>=middle_line,-1*((0.5-((abs(abs(obv)-abs(lowest_in_length_avg)))/(abs(avg_range))))*100),
1*((-0.5-((abs(obv)-abs(abs(lowest_in_length_avg)))/(abs(avg_range))))*100));
Plot1(50, "Upper Band");
plot2(0, "Middle Band");
plot3(-50, "Lower Band");
plot4(normalized_obv, "OnBalanceVolume");
input : typeMA(1);#1:SMA, 2:EMA, 3:SMMA, 4:WMA, 5:VWMA
input : smoothingLength(5);
var : smoothingLine(0),alpha(0);
if typeMA == 1 Then
smoothingLine = ma(normalized_obv, smoothingLength);
if typeMA == 2 Then
smoothingLine = ema(normalized_obv, smoothingLength);
if typeMA == 3 Then
{
alpha = 1/smoothingLength;
smoothingLine = iff(Isnan(smoothingLine[1]) == true , ma(normalized_obv, smoothingLength) , alpha * normalized_obv + (1 - alpha) * iff(isnan(smoothingLine[1]) == true,0,smoothingLine[1]));
}
if typeMA == 4 Then
smoothingLine = wma(normalized_obv, smoothingLength);
if typeMA == 5 Then
smoothingLine = ma(normalized_obv * volume, smoothingLength) / ma(volume, smoothingLength);
plot5(smoothingLine, "Smoothing Line");
즐거운 하루되세요
> 삼손감자 님이 쓴 글입니다.
> 제목 : 지표 변환 부탁드립니다.
> //@version=5
indicator(title="On Balance Volume Scaled", shorttitle="OBV-Scaled", format=format.volume, timeframe="", timeframe_gaps=true)
length=input.int(100,minval=10,title="Length of Scaling", group="Settings",tooltip = "The number of candles measured for the highest price, lowest price and average price in the indicator.")
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
runtime.error("No volume is provided by the data vendor.")
src = close
obv = ta.cum(math.sign(ta.change(src)) * volume)
highest_in_length = ta.highest(obv,length)
highest_in_length_avg= ta.ema(highest_in_length,length)
lowest_in_length = ta.lowest(obv,length)
lowest_in_length_avg= ta.ema(lowest_in_length,length)
avg_range= highest_in_length_avg - lowest_in_length_avg
middle_line =avg_range/2
normalized_obv= if obv>=middle_line
-1*((0.5-((math.abs(math.abs(obv)-math.abs(lowest_in_length_avg)))/(math.abs(avg_range))))*100)
else
1*((-0.5-((math.abs(obv)-math.abs(math.abs(lowest_in_length_avg)))/(math.abs(avg_range))))*100)
band1 = hline(50, "Upper Band", color=#787B86, linestyle=hline.style_dashed)
hline(0, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(-50, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=color.rgb(33, 150, 243, 90), title="Background")
plot(normalized_obv, color=#2962FF, title="OnBalanceVolume")
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => 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)
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")
smoothingLine = ma(normalized_obv, smoothingLength, typeMA)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, display=display.none)