커뮤니티

수식 부탁드립니다

프로필 이미지
사노소이
2025-06-04 19:22:10
199
글번호 191421
답변완료
지표식 부탁 드립니다. //@version=5 indicator("HTF Ribbon", overlay = false) // ───── INPUTS ───── length = input.int(10, "Trend Length", minval = 1) htf_tf = input.timeframe("", "HTF Timeframe") htf_color_up = input.color(#00ffaa, "HTF Up Color") htf_color_dn = input.color(#e91e63, "HTF Down Color") // ───── FUNCTION: HTF TREND ───── getHTFTrend(tf, len) => atr = request.security(syminfo.tickerid, tf, ta.sma(ta.atr(200), 200)) * 0.8 smaHigh = request.security(syminfo.tickerid, tf, ta.sma(high, len)) + atr smaLow = request.security(syminfo.tickerid, tf, ta.sma(low, len)) - atr crossUp = request.security(syminfo.tickerid, tf, ta.crossover(close, smaHigh)) crossDn = request.security(syminfo.tickerid, tf, ta.crossunder(close, smaLow)) var bool trend = na trend := crossUp ? true : crossDn ? false : trend trend // ───── TREND STATES ───── htf_trend = getHTFTrend(htf_tf, length) // ───── RIBBON LEVELS ───── base = 0 height = 2 // ───── RIBBON PLOTS ───── plot(htf_trend ? base + height : na, title = "HTF Up", color = htf_color_up, style = plot.style_columns, histbase = base) plot(htf_trend == false ? base + height : na, title = "HTF Down", color = htf_color_dn, style = plot.style_columns, histbase = base)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-06-05 12:55:29

안녕하세요 예스스탁입니다. 해당식 계산식 중에 과거로부터 계산하면서 현재봉쪽으로 오는 내용들이 있습니다. 해당 값들이 차트 과거봉에 따라 값이 달라질 수 있는데 차트의 봉수가 충분치 않아 타주기를 작성하기 어렵습니다. 1번식은 기본차트 주기로 계산하는 식이고 2번은 참조데이터를 이용하는 식입니다. 타주기를 이용하고 할 경우 2번식을 이용하셔야 합니다. 차트에 기본차트와 동일한 종목을 참조데이터로 추가하고 참조데이터를 기본차트와 다른 원하시는 주기로 셋팅한 후에 2번식 적용하시면 됩니다. 1 input : length(10); input : htf_color_up(Lime); input : htf_color_dn(Red); var : base(0),height(0); var : alpha(0),A(0),ATRV(0); var : smahigh(0),smalow(0),csUP(False),csDn(False),htf_trend(False); alpha = 1 / 200; base = 0; height = 2; A = IFf(IsNan(A[1]) == true, ma(TrueRange,200) , alpha * TrueRange + (1 - alpha) * IFf(isnan(A[1])==true,0,A[1])); ATRV = ma(A,200)*0.8; smaHigh = ma(high,length)+ATRV; smaLow = ma(low,length)-ATRV; csUp = CrossUp(close,smahigh); csDn = CrossDown(close,smaLow); if csUp == true Then htf_trend = true; if csDn == true Then htf_trend = False; if htf_trend == true then plot1(base + height,"HTF",htf_color_up); Else plot1(base + height,"HTF",htf_color_dn); 2 input : length(10); input : htf_color_up(Lime); input : htf_color_dn(Red); var : base(0,Data2),height(0,Data2); var : alpha(0,Data2),A(0,Data2),ATRV(0,Data2); var : smahigh(0,Data2),smalow(0,Data2),csUP(False,Data2),csDn(False,Data2),htf_trend(False,Data2); alpha = 1 / 200; base = 0; height = 2; A = data2(IFf(IsNan(A[1]) == true, ma(TrueRange,200) , alpha * TrueRange + (1 - alpha) * IFf(isnan(A[1])==true,0,A[1]))); ATRV = data2(ma(A,200)*0.8); smaHigh = data2(ma(high,length)+ATRV); smaLow = data2(ma(low,length)-ATRV); csUp = data2(CrossUp(close,smahigh)); csDn = data2(CrossDown(close,smaLow)); if csUp == true Then htf_trend = true; if csDn == true Then htf_trend = False; if htf_trend == true then plot1(base + height,"HTF",htf_color_up); Else plot1(base + height,"HTF",htf_color_dn); 즐거운 하루되세요 > 사노소이 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다 > 지표식 부탁 드립니다. //@version=5 indicator("HTF Ribbon", overlay = false) // ───── INPUTS ───── length = input.int(10, "Trend Length", minval = 1) htf_tf = input.timeframe("", "HTF Timeframe") htf_color_up = input.color(#00ffaa, "HTF Up Color") htf_color_dn = input.color(#e91e63, "HTF Down Color") // ───── FUNCTION: HTF TREND ───── getHTFTrend(tf, len) => atr = request.security(syminfo.tickerid, tf, ta.sma(ta.atr(200), 200)) * 0.8 smaHigh = request.security(syminfo.tickerid, tf, ta.sma(high, len)) + atr smaLow = request.security(syminfo.tickerid, tf, ta.sma(low, len)) - atr crossUp = request.security(syminfo.tickerid, tf, ta.crossover(close, smaHigh)) crossDn = request.security(syminfo.tickerid, tf, ta.crossunder(close, smaLow)) var bool trend = na trend := crossUp ? true : crossDn ? false : trend trend // ───── TREND STATES ───── htf_trend = getHTFTrend(htf_tf, length) // ───── RIBBON LEVELS ───── base = 0 height = 2 // ───── RIBBON PLOTS ───── plot(htf_trend ? base + height : na, title = "HTF Up", color = htf_color_up, style = plot.style_columns, histbase = base) plot(htf_trend == false ? base + height : na, title = "HTF Down", color = htf_color_dn, style = plot.style_columns, histbase = base)