커뮤니티

문의드립니다.

프로필 이미지
해암
2025-05-14 02:26:55
324
글번호 190790
답변완료
아래의 트레이딩뷰 수식을 변환부탁드립니다. ============= indicator(title="Volume Weighted Average Price", shorttitle="VWAP", overlay=true, timeframe="", timeframe_gaps=true) hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings", display = display.data_window) var anchor = input.string(defval = "Session", title="Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings") src = input(title = "Source", defval = hlc3, group="VWAP Settings", display = display.data_window) offset = input.int(0, title="Offset", group="VWAP Settings", minval=0, display = display.data_window) BANDS_GROUP = "Bands Settings" CALC_MODE_TOOLTIP = "Determines the units used to calculate the distance of the bands. " calcModeInput = input.string("Standard Deviation", "Bands Calculation Mode", options = ["Standard Deviation", "Percentage"], group = BANDS_GROUP, tooltip = CALC_MODE_TOOLTIP, display = display.data_window) showBand_1 = input(true, title = "", group = BANDS_GROUP, inline = "band_1", display = display.data_window) bandMult_1 = input.float(1.0, title = "Bands Multiplier #1", group = BANDS_GROUP, inline = "band_1", step = 0.5, minval=0, display = display.data_window) showBand_2 = input(false, title = "", group = BANDS_GROUP, inline = "band_2", display = display.data_window) bandMult_2 = input.float(2.0, title = "Bands Multiplier #2", group = BANDS_GROUP, inline = "band_2", step = 0.5, minval=0, display = display.data_window) showBand_3 = input(false, title = "", group = BANDS_GROUP, inline = "band_3", display = display.data_window) bandMult_3 = input.float(3.0, title = "Bands Multiplier #3", group = BANDS_GROUP, inline = "band_3", step = 0.5, minval=0, display = display.data_window) cumVolume = ta.cum(volume) if barstate.islast and cumVolume == 0 runtime.error("No volume is provided by the data vendor.") new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) isNewPeriod = switch anchor "Earnings" => not na(new_earnings) "Dividends" => not na(new_dividends) "Splits" => not na(new_split) "Session" => timeframe.change("D") "Week" => timeframe.change("W") "Month" => timeframe.change("M") "Quarter" => timeframe.change("3M") "Year" => timeframe.change("12M") "Decade" => timeframe.change("12M") and year % 10 == 0 "Century" => timeframe.change("12M") and year % 100 == 0 => false isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits" if na(src[1]) and not isEsdAnchor isNewPeriod := true float vwapValue = na float upperBandValue1 = na float lowerBandValue1 = na float upperBandValue2 = na float lowerBandValue2 = na float upperBandValue3 = na float lowerBandValue3 = na if not (hideonDWM and timeframe.isdwm) [_vwap, _stdevUpper, _] = ta.vwap(src, isNewPeriod, 1) vwapValue := _vwap stdevAbs = _stdevUpper - _vwap bandBasis = calcModeInput == "Standard Deviation" ? stdevAbs : _vwap * 0.01 upperBandValue1 := _vwap + bandBasis * bandMult_1 lowerBandValue1 := _vwap - bandBasis * bandMult_1 upperBandValue2 := _vwap + bandBasis * bandMult_2 lowerBandValue2 := _vwap - bandBasis * bandMult_2 upperBandValue3 := _vwap + bandBasis * bandMult_3 lowerBandValue3 := _vwap - bandBasis * bandMult_3 plot(vwapValue, title = "VWAP", color = #2962FF, offset = offset) upperBand_1 = plot(upperBandValue1, title="Upper Band #1", color = color.green, offset = offset, display = showBand_1 ? display.all : display.none, editable = showBand_1) lowerBand_1 = plot(lowerBandValue1, title="Lower Band #1", color = color.green, offset = offset, display = showBand_1 ? display.all : display.none, editable = showBand_1) fill(upperBand_1, lowerBand_1, title="Bands Fill #1", color = color.new(color.green, 95), display = showBand_1 ? display.all : display.none, editable = showBand_1) upperBand_2 = plot(upperBandValue2, title="Upper Band #2", color = color.olive, offset = offset, display = showBand_2 ? display.all : display.none, editable = showBand_2) lowerBand_2 = plot(lowerBandValue2, title="Lower Band #2", color = color.olive, offset = offset, display = showBand_2 ? display.all : display.none, editable = showBand_2) fill(upperBand_2, lowerBand_2, title="Bands Fill #2", color = color.new(color.olive, 95), display = showBand_2 ? display.all : display.none, editable = showBand_2) upperBand_3 = plot(upperBandValue3, title="Upper Band #3", color = color.teal, offset = offset, display = showBand_3 ? display.all : display.none, editable = showBand_3) lowerBand_3 = plot(lowerBandValue3, title="Lower Band #3", color = color.teal, offset = offset, display = showBand_3 ? display.all : display.none, editable = showBand_3) fill(upperBand_3, lowerBand_3, title="Bands Fill #3", color = color.new(color.teal, 95), display = showBand_3 ? display.all : display.none, editable = showBand_3) =================== 거듭 감사합니다. 수고하세요!!!
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-14 15:58:14

안녕하세요 예스스탁입니다. 올려주신 수식은 정학한 내용이 파악이 안되는 부분들이 있어 변환이 어렵습니다. 도움을 드리지 못해 죄송합니다. 즐거운 하루되세요 > 해암 님이 쓴 글입니다. > 제목 : 문의드립니다. > 아래의 트레이딩뷰 수식을 변환부탁드립니다. ============= indicator(title="Volume Weighted Average Price", shorttitle="VWAP", overlay=true, timeframe="", timeframe_gaps=true) hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings", display = display.data_window) var anchor = input.string(defval = "Session", title="Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings") src = input(title = "Source", defval = hlc3, group="VWAP Settings", display = display.data_window) offset = input.int(0, title="Offset", group="VWAP Settings", minval=0, display = display.data_window) BANDS_GROUP = "Bands Settings" CALC_MODE_TOOLTIP = "Determines the units used to calculate the distance of the bands. " calcModeInput = input.string("Standard Deviation", "Bands Calculation Mode", options = ["Standard Deviation", "Percentage"], group = BANDS_GROUP, tooltip = CALC_MODE_TOOLTIP, display = display.data_window) showBand_1 = input(true, title = "", group = BANDS_GROUP, inline = "band_1", display = display.data_window) bandMult_1 = input.float(1.0, title = "Bands Multiplier #1", group = BANDS_GROUP, inline = "band_1", step = 0.5, minval=0, display = display.data_window) showBand_2 = input(false, title = "", group = BANDS_GROUP, inline = "band_2", display = display.data_window) bandMult_2 = input.float(2.0, title = "Bands Multiplier #2", group = BANDS_GROUP, inline = "band_2", step = 0.5, minval=0, display = display.data_window) showBand_3 = input(false, title = "", group = BANDS_GROUP, inline = "band_3", display = display.data_window) bandMult_3 = input.float(3.0, title = "Bands Multiplier #3", group = BANDS_GROUP, inline = "band_3", step = 0.5, minval=0, display = display.data_window) cumVolume = ta.cum(volume) if barstate.islast and cumVolume == 0 runtime.error("No volume is provided by the data vendor.") new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) isNewPeriod = switch anchor "Earnings" => not na(new_earnings) "Dividends" => not na(new_dividends) "Splits" => not na(new_split) "Session" => timeframe.change("D") "Week" => timeframe.change("W") "Month" => timeframe.change("M") "Quarter" => timeframe.change("3M") "Year" => timeframe.change("12M") "Decade" => timeframe.change("12M") and year % 10 == 0 "Century" => timeframe.change("12M") and year % 100 == 0 => false isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits" if na(src[1]) and not isEsdAnchor isNewPeriod := true float vwapValue = na float upperBandValue1 = na float lowerBandValue1 = na float upperBandValue2 = na float lowerBandValue2 = na float upperBandValue3 = na float lowerBandValue3 = na if not (hideonDWM and timeframe.isdwm) [_vwap, _stdevUpper, _] = ta.vwap(src, isNewPeriod, 1) vwapValue := _vwap stdevAbs = _stdevUpper - _vwap bandBasis = calcModeInput == "Standard Deviation" ? stdevAbs : _vwap * 0.01 upperBandValue1 := _vwap + bandBasis * bandMult_1 lowerBandValue1 := _vwap - bandBasis * bandMult_1 upperBandValue2 := _vwap + bandBasis * bandMult_2 lowerBandValue2 := _vwap - bandBasis * bandMult_2 upperBandValue3 := _vwap + bandBasis * bandMult_3 lowerBandValue3 := _vwap - bandBasis * bandMult_3 plot(vwapValue, title = "VWAP", color = #2962FF, offset = offset) upperBand_1 = plot(upperBandValue1, title="Upper Band #1", color = color.green, offset = offset, display = showBand_1 ? display.all : display.none, editable = showBand_1) lowerBand_1 = plot(lowerBandValue1, title="Lower Band #1", color = color.green, offset = offset, display = showBand_1 ? display.all : display.none, editable = showBand_1) fill(upperBand_1, lowerBand_1, title="Bands Fill #1", color = color.new(color.green, 95), display = showBand_1 ? display.all : display.none, editable = showBand_1) upperBand_2 = plot(upperBandValue2, title="Upper Band #2", color = color.olive, offset = offset, display = showBand_2 ? display.all : display.none, editable = showBand_2) lowerBand_2 = plot(lowerBandValue2, title="Lower Band #2", color = color.olive, offset = offset, display = showBand_2 ? display.all : display.none, editable = showBand_2) fill(upperBand_2, lowerBand_2, title="Bands Fill #2", color = color.new(color.olive, 95), display = showBand_2 ? display.all : display.none, editable = showBand_2) upperBand_3 = plot(upperBandValue3, title="Upper Band #3", color = color.teal, offset = offset, display = showBand_3 ? display.all : display.none, editable = showBand_3) lowerBand_3 = plot(lowerBandValue3, title="Lower Band #3", color = color.teal, offset = offset, display = showBand_3 ? display.all : display.none, editable = showBand_3) fill(upperBand_3, lowerBand_3, title="Bands Fill #3", color = color.new(color.teal, 95), display = showBand_3 ? display.all : display.none, editable = showBand_3) =================== 거듭 감사합니다. 수고하세요!!!