답변완료
문의드립니다.
아래의 트레이딩뷰 수식을 변환부탁드립니다.
=============
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)
===================
거듭 감사합니다. 수고하세요!!!
2025-05-14
400
글번호 190790
지표
답변완료
지표 문의 드립니다.
//@version=6
indicator(
title = "Stoch RSI + TEMA",
shorttitle = "SRTEMA",
overlay = false,
format = format.price,
precision = 2)
// ────────── 입력
smoothK = input.int(12 , "K" , minval = 1)
smoothD = input.int(3 , "D" , minval = 1)
rsiLen = input.int(14, "RSI Length" , minval = 1)
stochLen = input.int(14, "Stoch Len" , minval = 1)
src = input.source(close, "RSI Src")
temaLen = input.int(12 , "TEMA Length" , minval = 1)
// ────────── Stochastic RSI
rsiVal = ta.rsi(src, rsiLen)
k_raw = ta.stoch(rsiVal, rsiVal, rsiVal, stochLen)
k = ta.sma(k_raw, smoothK) // %K
d = ta.sma(k , smoothD) // %D
// ────────── TEMA (%K 기반)
ema1 = ta.ema(k, temaLen)
ema2 = ta.ema(ema1, temaLen)
ema3 = ta.ema(ema2, temaLen)
tema = 3 * (ema1 - ema2) + ema3
// ────────── 시각화
plot(k , "K" , color = color.blue , linewidth = 2)
plot(d , "D" , color = color.orange, linewidth = 2)
plot(tema, "TEMA", color = color.green , linewidth = 2)
hUpper = hline(80, "Upper" , color = color.gray)
hMid = hline(50, "Middle", color = color.new(color.gray, 50))
hLower = hline(20, "Lower" , color = color.gray)
fill(hUpper, hLower, color = color.rgb(33,150,243,90), title = "BG")
// ────────── 알림(선택)
bullCross = ta.crossover(k, tema)
bearCross = ta.crossunder(k, tema)
alertcondition(bullCross, "Bullish K>TEMA", "K crossed above TEMA")
alertcondition(bearCross, "Bearish K<TEMA", "K crossed below TEMA")
트레이딩뷰 수식인데 예스 수식으로 바꿔주세요.
2025-05-14
303
글번호 190789
지표
답변완료
지표 변환 문의드립니다. 질문 92667 관련
안녕하세요.건승을 기원합니다.
질문 92667 답변 관련 질문입니다.
3번 지표로 구현하엿는데,선은 필요없으니 신호만 나타낼수잇는 수식을 좀 알려주시면 감사하겟습니다.
상단,하단밴드는 버리고 중간선이 색갈이변할때만 신호를 표출하는 식을 부탁합니다.(색깔변하는 봉 바로 밑에 또는 위에)
제가 작성한 "잘못된" 수식입니다만
plot1(filt, "Filter", fcolor);
plot2(hband, "Filtered True Range High Band", fcolor);
plot3(lband, "Filtered True Range Low Band", fcolor);
if filt < filt[1] Then
{
tx = Text_New(sdate,sTime,H,"☎");
Text_SetStyle(tx,2,0);#좌우상하정렬
Text_SetColor(tx,Black);#색상
Text_SetSize(tx,20);#크기
}
if filt > filt[1] Then
{
tx = Text_New(sdate,sTime,L,"♥");
Text_SetStyle(tx,2,0);#좌우상하정렬
Text_SetColor(tx,Brown);#색상
Text_SetSize(tx,20);#크기
}
모든 봉 위 또는 아래에 신호가 나오네요. 이게 아니고 핵심은
색깔이 변할때만 나오게 해주면 됩니다.
감사합니다.(더불어 전략수식도 알려주시면 감사하겠숩니다)
2025-05-14
254
글번호 190788
지표
답변완료
부탁드립니다
input: 기준배율(1.8), 익절비율(1.01), 손절비율(0.995),
진입선색(cyan), 익절선색(green), 손절선색(red);
var:
기준거래량(0), 중심선(0), 제곱합(0), 분산(0), 표준편차(0), BB상단(0),
ma5(0), ma20(0),
진입가(0), 익절선(0), 손절선(0),
신호발생(false), 매도출력(false),
ID_진입선(0), ID_익절선(0), ID_손절선(0), ID_txt(0);
// === 기준 계산 ===
기준거래량 = ma(volume, 20);
중심선 = ma(Close, 20);
제곱합 = ma(Close * Close, 20);
분산 = 제곱합 - 중심선 * 중심선;
표준편차 = SquareRoot(분산);
BB상단 = 중심선 + 표준편차 * 2;
ma5 = ma(Close, 5);
ma20 = ma(Close, 20);
// === 매수 신호 ===
if (신호발생 == false) and
(volume > 기준거래량 * 기준배율) and
(Close > BB상단) and
(Close > Open) and
((Close - Open) > (High - Low) * 0.6) and
(ma5 > ma20) then
begin
TL_New(sDate,sTime,0,sDate,sTime,99999999);
// 기존 선 삭제
TL_Delete(ID_진입선);
TL_Delete(ID_익절선);
TL_Delete(ID_손절선);
진입가 = Close;
익절선 = 진입가 * 익절비율;
손절선 = 진입가 * 손절비율;
// 진입선
ID_진입선 = TL_New(sdate, stime, 진입가,NextBarSdate,NextBarStime,진입가);
TL_SetColor(ID_진입선, 진입선색);
TL_SetSize(ID_진입선, 2);
// 익절선
ID_익절선 = TL_New(sdate, stime, 익절선, NextBarSdate, NextBarStime, 익절선);
TL_SetColor(ID_익절선, 익절선색);
TL_SetSize(ID_익절선, 2);
// 손절선
ID_손절선 = TL_New(sdate, stime, 손절선, NextBarSdate, NextBarStime, 손절선);
TL_SetColor(ID_손절선, 손절선색);
TL_SetSize(ID_손절선, 2);
신호발생 = true;
매도출력 = false;
end;
// === 매도 신호 ===
if (신호발생 == true) and (매도출력 == false) then
begin
if (Close >= 익절선) or (Close <= 손절선) then
begin
ID_txt = Text_New(date, time, High, "SELL");
Text_SetColor(ID_txt, red);
매도출력 = true;
end;
end;
// === 상태 초기화 ===
if (매도출력 == true) and
((Close > 진입가 * 1.2) or (Close < 진입가 * 0.9)) then
begin
신호발생 = false;
매도출력 = false;
end;
차트에 구현이 되질않아요 해외선물에 구현되게끔 부탁드립니다
2025-05-13
239
글번호 190785
지표
답변완료
문의드립니다.
아래의 수식을 변화부탁드립니다.
===================
/ ~~ Inputs {
PriceValue = input.string("hl2", options = ["hl2","VWAP", "sma", "wma", "ema", "hma"], group="", inline="Value")
maLen = input.int(5, minval=2, maxval=200, title="", group="", inline="Value", tooltip=t1)
TargetValue = input.string("Price Action", options = ["Price Action","VWAP", "Volatility", "sma", "wma", "ema", "hma"], group="", inline="Target")
maLen_ = input.int(5, minval=2, maxval=200, title="", group="", inline="Target", tooltip=t2)
// Input parameters for the KNN Moving Average
numberOfClosestValues = input.int(3, "Number of Closest Values", 2, 200, tooltip=t3)
smoothingPeriod = input.int(50, "Smoothing Period", 2, 500, tooltip=t4)
windowSize = math.max(numberOfClosestValues, 30)
// knn Color
Upknn_col = input.color(color.lime, title="", group="KNN Color", inline="knn col")
Dnknn_col = input.color(color.red, title="", group="KNN Color", inline="knn col")
Neuknn_col = input.color(color.orange, title="", group="KNN Color", inline="knn col")
// MA knn Color
Maknn_col = input.color(color.teal, title="", group="MA KNN Color", inline="MA knn col")
// BG Color
bgcolor = input.bool(false, title="Trend Prediction Color", group="BG Color", inline="bg", tooltip=t5)
Up_col = input.color(color.lime, title="", group="BG Color", inline="bg")
Dn_col = input.color(color.red, title="", group="BG Color", inline="bg")
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ kNN Classifier {
value_in = switch PriceValue
"hl2" => ta.sma(hl2,maLen)
"VWAP" => ta.vwap(close[maLen])
"sma" => ta.sma(close,maLen)
"wma" => ta.wma(close,maLen)
"ema" => ta.ema(close,maLen)
"hma" => ta.hma(close,maLen)
meanOfKClosest(value_,target_) =>
closestDistances = array.new_float(numberOfClosestValues, 1e10)
closestValues = array.new_float(numberOfClosestValues, 0.0)
for i = 1 to windowSize
value = value_[i]
distance = math.abs(target_ - value)
maxDistIndex = 0
maxDistValue = closestDistances.get(0)
for j = 1 to numberOfClosestValues - 1
if closestDistances.get(j) > maxDistValue
maxDistIndex := j
maxDistValue := closestDistances.get(j)
if distance < maxDistValue
closestDistances.set(maxDistIndex, distance)
closestValues.set(maxDistIndex, value)
closestValues.sum() / numberOfClosestValues
// Choose the target input based on user
target_in = switch TargetValue
"Price Action" => ta.rma(close,maLen_)
"VWAP" => ta.vwap(close[maLen_])
"Volatility" => ta.atr(14)
"sma" => ta.sma(close,maLen_)
"wma" => ta.wma(close,maLen_)
"ema" => ta.ema(close,maLen_)
"hma" => ta.hma(close,maLen_)
knnMA = meanOfKClosest(value_in,target_in)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ kNN Prediction {
// Function to calculate KNN Classifier
price = math.avg(knnMA, close)
c = ta.rma(knnMA[1], smoothingPeriod)
o = ta.rma(knnMA, smoothingPeriod)
// Defines KNN function to perform classification
knn(price) =>
Pos_count = 0
Neg_count = 0
min_distance = 10e10
nearest_index = 0
for j = 1 to 10
distance = math.sqrt(math.pow(price[j] - price, 2))
if distance < min_distance
min_distance := distance
nearest_index := j
Neg = c[nearest_index] > o[nearest_index]
Pos = c[nearest_index] < o[nearest_index]
if Pos
Pos_count += 1
if Neg
Neg_count += 1
output = Pos_count>Neg_count?1:-1
// Calls KNN function and smooths the prediction
knn_prediction_raw = knn(price)
knn_prediction = ta.wma(knn_prediction_raw, 3)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Plots {
// Plots for display on the chart
knnMA_ = ta.wma(knnMA,5)
knnMA_col = knnMA_>knnMA_[1]?Upknn_col:knnMA_<knnMA_[1]?Dnknn_col:Neuknn_col
Classifier_Line = plot(knnMA_,"Knn Classifier Line", knnMA_col)
MAknn_ = ta.rma(knnMA, smoothingPeriod)
plot(MAknn_,"Average Knn Classifier Line" ,Maknn_col)
green = knn_prediction < 0.5
red = knn_prediction > -0.5
bgcolor( green and bgcolor? color.new(Dn_col,80) :
red and bgcolor ? color.new(Up_col,80) : na)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
=================
도와주심에 항상 감사드립니다. 수고하세요!!!
2025-05-13
394
글번호 190782
지표