커뮤니티

수식 부탁드립니다

프로필 이미지
짜왕
2022-04-20 23:19:35
1237
글번호 158193
답변완료
VWAP = 거래량 가중 평균가 = ∑ (대표 가격 * 거래량 ) / ∑ 거래량 대표 가격 = 고가 + 저가 + 종가 / 3 입니다 // Initial inputs Act_RSI_VWAP = input(true, " PRICE") RSI_VWAP_length = input(17, "LENGTH") RSI_VWAP_overSold = input(19, "OVERSOLD", type=input.float) RSI_VWAP_overBought = input(80, "OVERBOUGHT", type=input.float) // RSI with VWAP as source RSI_VWAP = rsi(vwap(close), RSI_VWAP_length) // Plotting, overlay=false r=plot(RSI_VWAP, color = RSI_VWAP > RSI_VWAP_overBought ? color.red : RSI_VWAP < RSI_VWAP_overSold ? color.lime : color.blue, title="rsi", linewidth=2, style=plot.style_line) h1=plot(RSI_VWAP_overBought, color = color.gray, style=plot.style_stepline) h2=plot(RSI_VWAP_overSold, color = color.gray, style=plot.style_stepline) fill(r,h1, color = RSI_VWAP > RSI_VWAP_overBought ? color.red : na, transp = 60) fill(r,h2, color = RSI_VWAP < RSI_VWAP_overSold ? color.lime : na, transp = 60) long=crossover(RSI_VWAP, RSI_VWAP_overSold) long1=crossunder(RSI_VWAP, RSI_VWAP_overBought)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-04-21 09:46:47

안녕하세요 예스스탁입니다. vwap(close) 올리신 수식에 vwap는 종가로 계산되게 되어 있습니다. 원식대로 작성해 드립니다. 다른값을 사용하고자 하시면 수식내 price변수에 저장하는 값을 변경하시면 됩니다. 또한 일반적으로 vwap가 봉수를 지정해 거래량가중평균을 구하는데 해당함수에는 기간이 지정되어 있지 않아 평균값을 구하는 구간이 모호합니다. 올리신 내용이면 차트 전체누적으로 계산하는 것 같습니다. 차트전체상 평균이면 가격변화가 크지 않아 RSI값이 계속 100이나 0일수가 있습니다. 위 내용이 맞으면 1번식을 이용하시면 되고 거래량가중평균에 기간을 주시면 2번식 이용하시면 됩니다. 1 input : RSI_VWAP_length(17),RSI_VWAP_overSold(19),RSI_VWAP_overBought(80); var : price(0),vwap(0),RSI_VWAP(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); price = c; #(H+L+C)/3; var1 = var1 + (price*V); var2 = var2 + v; vwap = var1/Var2; If RSI_VWAP_length+10 == Index Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSI_VWAP_length - 1 { UpAmt = vwap[Counter] - vwap[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSI_VWAP_length; DownAvg = DownSum / RSI_VWAP_length; } Else If Index > RSI_VWAP_length+10 Then { UpAmt = vwap[0] - vwap[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (UpAvg * (RSI_VWAP_length - 1) + UpAmt) / RSI_VWAP_length; DownAvg = (DownAvg * (RSI_VWAP_length - 1) + DownAmt) / RSI_VWAP_length; } If UpAvg + DownAvg <> 0 Then RSI_VWAP = 100 * UpAvg / (UpAvg + DownAvg); Else RSI_VWAP = 0; plot1(RSI_VWAP,"rsi",IFf(RSI_VWAP > RSI_VWAP_overBought ,red ,IFf(RSI_VWAP < RSI_VWAP_overSold , Cyan ,blue))); plot2(RSI_VWAP_overBought,"overBought",gray); plot3(RSI_VWAP_overSold,"overSold",gray); 2 input : VWAP_length(10),RSI_VWAP_length(17),RSI_VWAP_overSold(19),RSI_VWAP_overBought(80); var : price(0),vwap(0),RSI_VWAP(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); price = c; #(H+L+C)/3; var1 = AccumN(price*V,VWAP_length); Var2 = AccumN(v,VWAP_length); vwap = var1/Var2; If RSI_VWAP_length+10 == Index Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSI_VWAP_length - 1 { UpAmt = vwap[Counter] - vwap[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSI_VWAP_length; DownAvg = DownSum / RSI_VWAP_length; } Else If Index > RSI_VWAP_length+10 Then { UpAmt = vwap[0] - vwap[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (UpAvg * (RSI_VWAP_length - 1) + UpAmt) / RSI_VWAP_length; DownAvg = (DownAvg * (RSI_VWAP_length - 1) + DownAmt) / RSI_VWAP_length; } If UpAvg + DownAvg <> 0 Then RSI_VWAP = 100 * UpAvg / (UpAvg + DownAvg); Else RSI_VWAP = 0; plot1(RSI_VWAP,"rsi",IFf(RSI_VWAP > RSI_VWAP_overBought ,red ,IFf(RSI_VWAP < RSI_VWAP_overSold , Cyan ,blue))); plot2(RSI_VWAP_overBought,"overBought",gray); plot3(RSI_VWAP_overSold,"overSold",gray); 즐거운 하루되세요 > 짜왕 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다 > VWAP = 거래량 가중 평균가 = ∑ (대표 가격 * 거래량 ) / ∑ 거래량 대표 가격 = 고가 + 저가 + 종가 / 3 입니다 // Initial inputs Act_RSI_VWAP = input(true, " PRICE") RSI_VWAP_length = input(17, "LENGTH") RSI_VWAP_overSold = input(19, "OVERSOLD", type=input.float) RSI_VWAP_overBought = input(80, "OVERBOUGHT", type=input.float) // RSI with VWAP as source RSI_VWAP = rsi(vwap(close), RSI_VWAP_length) // Plotting, overlay=false r=plot(RSI_VWAP, color = RSI_VWAP > RSI_VWAP_overBought ? color.red : RSI_VWAP < RSI_VWAP_overSold ? color.lime : color.blue, title="rsi", linewidth=2, style=plot.style_line) h1=plot(RSI_VWAP_overBought, color = color.gray, style=plot.style_stepline) h2=plot(RSI_VWAP_overSold, color = color.gray, style=plot.style_stepline) fill(r,h1, color = RSI_VWAP > RSI_VWAP_overBought ? color.red : na, transp = 60) fill(r,h2, color = RSI_VWAP < RSI_VWAP_overSold ? color.lime : na, transp = 60) long=crossover(RSI_VWAP, RSI_VWAP_overSold) long1=crossunder(RSI_VWAP, RSI_VWAP_overBought)