커뮤니티

수식 전환 부탁드립니다

프로필 이미지
seayun1
2023-09-10 17:18:35
1395
글번호 172312
답변완료
안녕하세요 항상 감사드립니다 트레이딩뷰 지표 두가지인데 예트수식으로 전환부탁드립니다 1) study("Cumulative Delta Volume", "CDV") linestyle = input(defval = 'Candle', title = "Style", options = ['Candle', 'Line']) hacandle = input(defval = true, title = "Heikin Ashi Candles?") showma1 = input(defval = false, title = "SMA 1", inline = "ma1") ma1len = input(defval = 50, title = "", minval = 1, inline = "ma1") ma1col = input(defval = color.lime, title = "", inline = "ma1") showma2 = input(defval = false, title = "SMA 2", inline = "ma2") ma2len = input(defval = 200, title = "", minval = 1, inline = "ma2") ma2col = input(defval = color.red, title = "", inline = "ma2") showema1 = input(defval = false, title = "EMA 1", inline = "ema1") ema1len = input(defval = 50, title = "", minval = 1, inline = "ema1") ema1col = input(defval = color.lime, title = "", inline = "ema1") showema2 = input(defval = false, title = "EMA 2", inline = "ema2") ema2len = input(defval = 200, title = "", minval = 1, inline = "ema2") ema2col = input(defval = color.red, title = "", inline = "ema2") colorup = input(defval = color.lime, title = "Body", inline = "bcol") colordown = input(defval = color.red, title = "", inline = "bcol") bcolup = input(defval = #74e05e, title = "Border", inline = "bocol") bcoldown = input(defval = #ffad7d, title = "", inline = "bocol") wcolup = input(defval = #b5b5b8, title = "Wicks", inline = "wcol") wcoldown = input(defval = #b5b5b8, title = "", inline = "wcol") tw = high - max(open, close) bw = min(open, close) - low body = abs(close - open) _rate(cond) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := nz(ret) == 0 ? 0.5 : ret ret deltaup = volume * _rate(open <= close) deltadown = volume * _rate(open > close) delta = close >= open ? deltaup : -deltadown cumdelta = cum(delta) float ctl = na float o = na float h = na float l = na float c = na if linestyle == 'Candle' o := cumdelta[1] h := max(cumdelta, cumdelta[1]) l := min(cumdelta, cumdelta[1]) c := cumdelta ctl else ctl := cumdelta plot(ctl, title = "CDV Line", color = color.blue, linewidth = 2) float haclose = na float haopen = na float hahigh = na float halow = na haclose := (o + h + l + c) / 4 haopen := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2 hahigh := max(h, max(haopen, haclose)) halow := min(l, min(haopen, haclose)) c_ = hacandle ? haclose : c o_ = hacandle ? haopen : o h_ = hacandle ? hahigh : h l_ = hacandle ? halow : l plotcandle(o_, h_, l_, c_, title='CDV Candles', color = o_ <= c_ ? colorup : colordown, bordercolor = o_ <= c_ ? bcolup : bcoldown, wickcolor = o_ <= c_ ? bcolup : bcoldown) plot(showma1 and linestyle == "Candle" ? sma(c_, ma1len) : na, title = "SMA 1", color = ma1col) plot(showma2 and linestyle == "Candle" ? sma(c_, ma2len) : na, title = "SMA 2", color = ma2col) plot(showema1 and linestyle == "Candle" ? ema(c_, ema1len) : na, title = "EMA 1", color = ema1col) plot(showema2 and linestyle == "Candle" ? ema(c_, ema2len) : na, title = "EMA 2", color = ema2col) 2) indicator(title='HA Market Bias', shorttitle='HA Market Bias', overlay=true) tf(_res, _exp, gaps_on) => gaps_on == 0 ? request.security(syminfo.tickerid, _res, _exp) : gaps_on == true ? request.security(syminfo.tickerid, _res, _exp, barmerge.gaps_on, barmerge.lookahead_off) : request.security(syminfo.tickerid, _res, _exp, barmerge.gaps_off, barmerge.lookahead_off) ha_htf = '' show_ha = input.bool(true, "Show HA Plot/ Market Bias", group="HA Market Bias") ha_len = input(100, 'Period', group="HA Market Bias") ha_len2 = input(100, 'Smoothing', group="HA Market Bias") // Calculations { o = ta.ema(open, ha_len) c = ta.ema(close, ha_len) h = ta.ema(high, ha_len) l = ta.ema(low, ha_len) haclose = tf(ha_htf, (o + h + l + c) / 4, 0) xhaopen = tf(ha_htf, (o + c) / 2, 0) haopen = na(xhaopen[1]) ? (o + c) / 2 : (xhaopen[1] + haclose[1]) / 2 hahigh = math.max(h, math.max(haopen, haclose)) halow = math.min(l, math.min(haopen, haclose)) o2 = tf(ha_htf, ta.ema(haopen, ha_len2), 0) c2 = tf(ha_htf, ta.ema(haclose, ha_len2), 0) h2 = tf(ha_htf, ta.ema(hahigh, ha_len2), 0) l2 = tf(ha_htf, ta.ema(halow, ha_len2), 0) ha_avg = (h2 + l2) / 2 // } // Oscillator { osc_len = input.int(7, "Oscillator Period", group="HA Market Bias") osc_bias = 100 *(c2 - o2) osc_smooth = ta.ema(osc_bias, osc_len) sigcolor = (osc_bias > 0) and (osc_bias >= osc_smooth) ? color.new(color.lime, 35) : (osc_bias > 0) and (osc_bias < osc_smooth) ? color.new(color.lime, 75) : (osc_bias < 0) and (osc_bias <= osc_smooth) ? color.new(color.red, 35) : (osc_bias < 0) and (osc_bias > osc_smooth) ? color.new(color.red, 75) : na // } // Plots { p_h = plot(h2, "Bias High", color=color(na), display=display.none, editable=false) p_l = plot(l2, "Bias Low", color=color(na), display=display.none, editable=false) p_avg = plot(ha_avg, "Bias Avergae", color=color(na), display=display.none, editable=false) fill(p_l, p_h, show_ha ? sigcolor : na) col = o2 > c2 ? color.red : color.lime plotcandle(show_ha ? o2 : na, h2, l2, c2, title='heikin smoothed', color=col) // }
지표
답변 2
프로필 이미지

예스스탁 예스스탁 답변

2023-09-11 13:52:22

안녕하세요 예스스탁입니다. 1 예스랭귀지는 별도로 봉을 그리는 기능은 없습니다. 해당식 중 봉을 그리는 내용은 예스랭귀지에서 강조식으로 작성해 보시는 방법뿐이 없습니다. 강조식2개 지표식 하나로 별도로 작성해 드립니다. 1-1 강조 input : linestyle("Candle"); input : hacandle(true); input : showma1(false); input : ma1len(50); input : ma1col(lime); input : showma2(false); input : ma2len( 200); input : ma2col(red); input : showema1(false); input : ema1len(50); input : ema1col(lime); input : showema2(false); input : ema2len(200); input : ema2col(red); input : colorup(lime); input : colordown(red); input : bcolup(Green); input : bcoldown(Orange); input : wcolup(Gray); input : wcoldown(gray); var : tw(0),bw(0),body(0),ret1(0),ret2(0); var : deltaup(0),deltadown(0),delta(0),cumdelta(0); var : ctl(Nan),oo(Nan),hh(Nan),ll(Nan),cc(Nan); var : haclose(0),haopen(0),hahigh(0),halow(0); var : c_(0),h_(0),l_(0),o_(0); tw = high - max(open, close) ; bw = min(open, close) - low ; body = abs(close - open) ; #_rate(cond) => # ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) # ret := nz(ret) == 0 ? 0.5 : ret # ret ret1 = 0.5 * (tw + bw + IFf(open <= close , 2 * body , 0)) / (tw + bw + body) ; ret1 = iff(isnan(ret1) == true , 0.5 , ret1); ret2 = 0.5 * (tw + bw + IFf(open > close , 2 * body , 0)) / (tw + bw + body) ; ret2 = iff(isnan(ret2) == true , 0.5 , ret2); deltaup = volume * ret1; deltadown = volume * ret2; delta = iff(close >= open , deltaup , -deltadown); cumdelta = Accum(delta); if linestyle == "Candle" Then { oo = cumdelta[1]; hh = max(cumdelta, cumdelta[1]); ll = min(cumdelta, cumdelta[1]); cc = cumdelta; PlotPaintBar(HH,LL,OO,CC,"강조"); } 1-2 지표 input : linestyle("Candle"); input : hacandle(true); input : showma1(false); input : ma1len(50); input : ma1col(lime); input : showma2(false); input : ma2len( 200); input : ma2col(red); input : showema1(false); input : ema1len(50); input : ema1col(lime); input : showema2(false); input : ema2len(200); input : ema2col(red); input : colorup(lime); input : colordown(red); input : bcolup(Green); input : bcoldown(Orange); input : wcolup(Gray); input : wcoldown(gray); var : tw(0),bw(0),body(0),ret1(0),ret2(0); var : deltaup(0),deltadown(0),delta(0),cumdelta(0); var : ctl(Nan),oo(Nan),hh(Nan),ll(Nan),cc(Nan); var : haclose(0),haopen(0),hahigh(0),halow(0); var : c_(0),h_(0),l_(0),o_(0); tw = high - max(open, close) ; bw = min(open, close) - low ; body = abs(close - open) ; #_rate(cond) => # ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) # ret := nz(ret) == 0 ? 0.5 : ret # ret ret1 = 0.5 * (tw + bw + IFf(open <= close , 2 * body , 0)) / (tw + bw + body) ; ret1 = iff(isnan(ret1) == true , 0.5 , ret1); ret2 = 0.5 * (tw + bw + IFf(open > close , 2 * body , 0)) / (tw + bw + body) ; ret2 = iff(isnan(ret2) == true , 0.5 , ret2); deltaup = volume * ret1; deltadown = volume * ret2; delta = iff(close >= open , deltaup , -deltadown); cumdelta = Accum(delta); if linestyle == "Candle" Then { oo = cumdelta[1]; hh = max(cumdelta, cumdelta[1]); ll = min(cumdelta, cumdelta[1]); cc = cumdelta; } else { ctl = cumdelta; plot1(ctl, "CDV Line"); } haclose = (o + h + l + c) / 4; haopen = iff(IsNan(haopen[1]) == true , (o + c) / 2 , (haopen[1] + haclose[1]) / 2); hahigh = max(h, max(haopen, haclose)); halow = min(l, min(haopen, haclose)); c_ = iff(hacandle , haclose , c); o_ = iff(hacandle , haopen , o); h_ = iff(hacandle , hahigh , h); l_ = iff(hacandle , halow , l); plot2(iff(showma1 and linestyle == "Candle" , ma(c_, ma1len) , Nan),"SMA 1",ma1col); plot3(iff(showma2 and linestyle == "Candle" , ma(c_, ma2len) , Nan), "SMA 2", ma2col); plot4(iff(showema1 and linestyle == "Candle", ema(c_, ema1len) , Nan), "EMA 1", ema1col); plot5(iff(showema2 and linestyle == "Candle", ema(c_, ema2len) , Nan), "EMA 2", ema2col); 1-3 강조 input : linestyle("Candle"); input : hacandle(true); input : showma1(false); input : ma1len(50); input : ma1col(lime); input : showma2(false); input : ma2len( 200); input : ma2col(red); input : showema1(false); input : ema1len(50); input : ema1col(lime); input : showema2(false); input : ema2len(200); input : ema2col(red); input : colorup(lime); input : colordown(red); input : bcolup(Green); input : bcoldown(Orange); input : wcolup(Gray); input : wcoldown(gray); var : tw(0),bw(0),body(0),ret1(0),ret2(0); var : deltaup(0),deltadown(0),delta(0),cumdelta(0); var : ctl(Nan),oo(Nan),hh(Nan),ll(Nan),cc(Nan); var : haclose(0),haopen(0),hahigh(0),halow(0); var : c_(0),h_(0),l_(0),o_(0); tw = high - max(open, close) ; bw = min(open, close) - low ; body = abs(close - open) ; #_rate(cond) => # ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) # ret := nz(ret) == 0 ? 0.5 : ret # ret ret1 = 0.5 * (tw + bw + IFf(open <= close , 2 * body , 0)) / (tw + bw + body) ; ret1 = iff(isnan(ret1) == true , 0.5 , ret1); ret2 = 0.5 * (tw + bw + IFf(open > close , 2 * body , 0)) / (tw + bw + body) ; ret2 = iff(isnan(ret2) == true , 0.5 , ret2); deltaup = volume * ret1; deltadown = volume * ret2; delta = iff(close >= open , deltaup , -deltadown); cumdelta = Accum(delta); haclose = (o + h + l + c) / 4; haopen = iff(IsNan(haopen[1]) == true , (o + c) / 2 , (haopen[1] + haclose[1]) / 2); hahigh = max(h, max(haopen, haclose)); halow = min(l, min(haopen, haclose)); c_ = iff(hacandle , haclose , c); o_ = iff(hacandle , haopen , o); h_ = iff(hacandle , hahigh , h); l_ = iff(hacandle , halow , l); PlotPaintBar(h_, l_, o_, c_, "CDV Candles",IFf( o_ <= c_ , colorup , colordown)); 2 수식내에 security로 다른데이터를 호출하는 경우에는 내용 파악을 할 수 없어 수식 변환이 가능하지 않습니다. 즐거운 하루되세요 > seayun1 님이 쓴 글입니다. > 제목 : 수식 전환 부탁드립니다 > 안녕하세요 항상 감사드립니다 트레이딩뷰 지표 두가지인데 예트수식으로 전환부탁드립니다 1) study("Cumulative Delta Volume", "CDV") linestyle = input(defval = 'Candle', title = "Style", options = ['Candle', 'Line']) hacandle = input(defval = true, title = "Heikin Ashi Candles?") showma1 = input(defval = false, title = "SMA 1", inline = "ma1") ma1len = input(defval = 50, title = "", minval = 1, inline = "ma1") ma1col = input(defval = color.lime, title = "", inline = "ma1") showma2 = input(defval = false, title = "SMA 2", inline = "ma2") ma2len = input(defval = 200, title = "", minval = 1, inline = "ma2") ma2col = input(defval = color.red, title = "", inline = "ma2") showema1 = input(defval = false, title = "EMA 1", inline = "ema1") ema1len = input(defval = 50, title = "", minval = 1, inline = "ema1") ema1col = input(defval = color.lime, title = "", inline = "ema1") showema2 = input(defval = false, title = "EMA 2", inline = "ema2") ema2len = input(defval = 200, title = "", minval = 1, inline = "ema2") ema2col = input(defval = color.red, title = "", inline = "ema2") colorup = input(defval = color.lime, title = "Body", inline = "bcol") colordown = input(defval = color.red, title = "", inline = "bcol") bcolup = input(defval = #74e05e, title = "Border", inline = "bocol") bcoldown = input(defval = #ffad7d, title = "", inline = "bocol") wcolup = input(defval = #b5b5b8, title = "Wicks", inline = "wcol") wcoldown = input(defval = #b5b5b8, title = "", inline = "wcol") tw = high - max(open, close) bw = min(open, close) - low body = abs(close - open) _rate(cond) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := nz(ret) == 0 ? 0.5 : ret ret deltaup = volume * _rate(open <= close) deltadown = volume * _rate(open > close) delta = close >= open ? deltaup : -deltadown cumdelta = cum(delta) float ctl = na float o = na float h = na float l = na float c = na if linestyle == 'Candle' o := cumdelta[1] h := max(cumdelta, cumdelta[1]) l := min(cumdelta, cumdelta[1]) c := cumdelta ctl else ctl := cumdelta plot(ctl, title = "CDV Line", color = color.blue, linewidth = 2) float haclose = na float haopen = na float hahigh = na float halow = na haclose := (o + h + l + c) / 4 haopen := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2 hahigh := max(h, max(haopen, haclose)) halow := min(l, min(haopen, haclose)) c_ = hacandle ? haclose : c o_ = hacandle ? haopen : o h_ = hacandle ? hahigh : h l_ = hacandle ? halow : l plotcandle(o_, h_, l_, c_, title='CDV Candles', color = o_ <= c_ ? colorup : colordown, bordercolor = o_ <= c_ ? bcolup : bcoldown, wickcolor = o_ <= c_ ? bcolup : bcoldown) plot(showma1 and linestyle == "Candle" ? sma(c_, ma1len) : na, title = "SMA 1", color = ma1col) plot(showma2 and linestyle == "Candle" ? sma(c_, ma2len) : na, title = "SMA 2", color = ma2col) plot(showema1 and linestyle == "Candle" ? ema(c_, ema1len) : na, title = "EMA 1", color = ema1col) plot(showema2 and linestyle == "Candle" ? ema(c_, ema2len) : na, title = "EMA 2", color = ema2col) 2) indicator(title='HA Market Bias', shorttitle='HA Market Bias', overlay=true) tf(_res, _exp, gaps_on) => gaps_on == 0 ? request.security(syminfo.tickerid, _res, _exp) : gaps_on == true ? request.security(syminfo.tickerid, _res, _exp, barmerge.gaps_on, barmerge.lookahead_off) : request.security(syminfo.tickerid, _res, _exp, barmerge.gaps_off, barmerge.lookahead_off) ha_htf = '' show_ha = input.bool(true, "Show HA Plot/ Market Bias", group="HA Market Bias") ha_len = input(100, 'Period', group="HA Market Bias") ha_len2 = input(100, 'Smoothing', group="HA Market Bias") // Calculations { o = ta.ema(open, ha_len) c = ta.ema(close, ha_len) h = ta.ema(high, ha_len) l = ta.ema(low, ha_len) haclose = tf(ha_htf, (o + h + l + c) / 4, 0) xhaopen = tf(ha_htf, (o + c) / 2, 0) haopen = na(xhaopen[1]) ? (o + c) / 2 : (xhaopen[1] + haclose[1]) / 2 hahigh = math.max(h, math.max(haopen, haclose)) halow = math.min(l, math.min(haopen, haclose)) o2 = tf(ha_htf, ta.ema(haopen, ha_len2), 0) c2 = tf(ha_htf, ta.ema(haclose, ha_len2), 0) h2 = tf(ha_htf, ta.ema(hahigh, ha_len2), 0) l2 = tf(ha_htf, ta.ema(halow, ha_len2), 0) ha_avg = (h2 + l2) / 2 // } // Oscillator { osc_len = input.int(7, "Oscillator Period", group="HA Market Bias") osc_bias = 100 *(c2 - o2) osc_smooth = ta.ema(osc_bias, osc_len) sigcolor = (osc_bias > 0) and (osc_bias >= osc_smooth) ? color.new(color.lime, 35) : (osc_bias > 0) and (osc_bias < osc_smooth) ? color.new(color.lime, 75) : (osc_bias < 0) and (osc_bias <= osc_smooth) ? color.new(color.red, 35) : (osc_bias < 0) and (osc_bias > osc_smooth) ? color.new(color.red, 75) : na // } // Plots { p_h = plot(h2, "Bias High", color=color(na), display=display.none, editable=false) p_l = plot(l2, "Bias Low", color=color(na), display=display.none, editable=false) p_avg = plot(ha_avg, "Bias Avergae", color=color(na), display=display.none, editable=false) fill(p_l, p_h, show_ha ? sigcolor : na) col = o2 > c2 ? color.red : color.lime plotcandle(show_ha ? o2 : na, h2, l2, c2, title='heikin smoothed', color=col) // }
프로필 이미지

seayun1

2023-09-11 15:36:24

항상감사드립니다. 아래 변환해주신 강조1-1과 지표식이 그려지지않읍니다 다시한번만 확인부탁드립니다 > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 전환 부탁드립니다 > 안녕하세요 예스스탁입니다. 1 예스랭귀지는 별도로 봉을 그리는 기능은 없습니다. 해당식 중 봉을 그리는 내용은 예스랭귀지에서 강조식으로 작성해 보시는 방법뿐이 없습니다. 강조식2개 지표식 하나로 별도로 작성해 드립니다. 1-1 강조 input : linestyle("Candle"); input : hacandle(true); input : showma1(false); input : ma1len(50); input : ma1col(lime); input : showma2(false); input : ma2len( 200); input : ma2col(red); input : showema1(false); input : ema1len(50); input : ema1col(lime); input : showema2(false); input : ema2len(200); input : ema2col(red); input : colorup(lime); input : colordown(red); input : bcolup(Green); input : bcoldown(Orange); input : wcolup(Gray); input : wcoldown(gray); var : tw(0),bw(0),body(0),ret1(0),ret2(0); var : deltaup(0),deltadown(0),delta(0),cumdelta(0); var : ctl(Nan),oo(Nan),hh(Nan),ll(Nan),cc(Nan); var : haclose(0),haopen(0),hahigh(0),halow(0); var : c_(0),h_(0),l_(0),o_(0); tw = high - max(open, close) ; bw = min(open, close) - low ; body = abs(close - open) ; #_rate(cond) => # ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) # ret := nz(ret) == 0 ? 0.5 : ret # ret ret1 = 0.5 * (tw + bw + IFf(open <= close , 2 * body , 0)) / (tw + bw + body) ; ret1 = iff(isnan(ret1) == true , 0.5 , ret1); ret2 = 0.5 * (tw + bw + IFf(open > close , 2 * body , 0)) / (tw + bw + body) ; ret2 = iff(isnan(ret2) == true , 0.5 , ret2); deltaup = volume * ret1; deltadown = volume * ret2; delta = iff(close >= open , deltaup , -deltadown); cumdelta = Accum(delta); if linestyle == "Candle" Then { oo = cumdelta[1]; hh = max(cumdelta, cumdelta[1]); ll = min(cumdelta, cumdelta[1]); cc = cumdelta; PlotPaintBar(HH,LL,OO,CC,"강조"); } 1-2 지표 input : linestyle("Candle"); input : hacandle(true); input : showma1(false); input : ma1len(50); input : ma1col(lime); input : showma2(false); input : ma2len( 200); input : ma2col(red); input : showema1(false); input : ema1len(50); input : ema1col(lime); input : showema2(false); input : ema2len(200); input : ema2col(red); input : colorup(lime); input : colordown(red); input : bcolup(Green); input : bcoldown(Orange); input : wcolup(Gray); input : wcoldown(gray); var : tw(0),bw(0),body(0),ret1(0),ret2(0); var : deltaup(0),deltadown(0),delta(0),cumdelta(0); var : ctl(Nan),oo(Nan),hh(Nan),ll(Nan),cc(Nan); var : haclose(0),haopen(0),hahigh(0),halow(0); var : c_(0),h_(0),l_(0),o_(0); tw = high - max(open, close) ; bw = min(open, close) - low ; body = abs(close - open) ; #_rate(cond) => # ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) # ret := nz(ret) == 0 ? 0.5 : ret # ret ret1 = 0.5 * (tw + bw + IFf(open <= close , 2 * body , 0)) / (tw + bw + body) ; ret1 = iff(isnan(ret1) == true , 0.5 , ret1); ret2 = 0.5 * (tw + bw + IFf(open > close , 2 * body , 0)) / (tw + bw + body) ; ret2 = iff(isnan(ret2) == true , 0.5 , ret2); deltaup = volume * ret1; deltadown = volume * ret2; delta = iff(close >= open , deltaup , -deltadown); cumdelta = Accum(delta); if linestyle == "Candle" Then { oo = cumdelta[1]; hh = max(cumdelta, cumdelta[1]); ll = min(cumdelta, cumdelta[1]); cc = cumdelta; } else { ctl = cumdelta; plot1(ctl, "CDV Line"); } haclose = (o + h + l + c) / 4; haopen = iff(IsNan(haopen[1]) == true , (o + c) / 2 , (haopen[1] + haclose[1]) / 2); hahigh = max(h, max(haopen, haclose)); halow = min(l, min(haopen, haclose)); c_ = iff(hacandle , haclose , c); o_ = iff(hacandle , haopen , o); h_ = iff(hacandle , hahigh , h); l_ = iff(hacandle , halow , l); plot2(iff(showma1 and linestyle == "Candle" , ma(c_, ma1len) , Nan),"SMA 1",ma1col); plot3(iff(showma2 and linestyle == "Candle" , ma(c_, ma2len) , Nan), "SMA 2", ma2col); plot4(iff(showema1 and linestyle == "Candle", ema(c_, ema1len) , Nan), "EMA 1", ema1col); plot5(iff(showema2 and linestyle == "Candle", ema(c_, ema2len) , Nan), "EMA 2", ema2col); 1-3 강조 input : linestyle("Candle"); input : hacandle(true); input : showma1(false); input : ma1len(50); input : ma1col(lime); input : showma2(false); input : ma2len( 200); input : ma2col(red); input : showema1(false); input : ema1len(50); input : ema1col(lime); input : showema2(false); input : ema2len(200); input : ema2col(red); input : colorup(lime); input : colordown(red); input : bcolup(Green); input : bcoldown(Orange); input : wcolup(Gray); input : wcoldown(gray); var : tw(0),bw(0),body(0),ret1(0),ret2(0); var : deltaup(0),deltadown(0),delta(0),cumdelta(0); var : ctl(Nan),oo(Nan),hh(Nan),ll(Nan),cc(Nan); var : haclose(0),haopen(0),hahigh(0),halow(0); var : c_(0),h_(0),l_(0),o_(0); tw = high - max(open, close) ; bw = min(open, close) - low ; body = abs(close - open) ; #_rate(cond) => # ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) # ret := nz(ret) == 0 ? 0.5 : ret # ret ret1 = 0.5 * (tw + bw + IFf(open <= close , 2 * body , 0)) / (tw + bw + body) ; ret1 = iff(isnan(ret1) == true , 0.5 , ret1); ret2 = 0.5 * (tw + bw + IFf(open > close , 2 * body , 0)) / (tw + bw + body) ; ret2 = iff(isnan(ret2) == true , 0.5 , ret2); deltaup = volume * ret1; deltadown = volume * ret2; delta = iff(close >= open , deltaup , -deltadown); cumdelta = Accum(delta); haclose = (o + h + l + c) / 4; haopen = iff(IsNan(haopen[1]) == true , (o + c) / 2 , (haopen[1] + haclose[1]) / 2); hahigh = max(h, max(haopen, haclose)); halow = min(l, min(haopen, haclose)); c_ = iff(hacandle , haclose , c); o_ = iff(hacandle , haopen , o); h_ = iff(hacandle , hahigh , h); l_ = iff(hacandle , halow , l); PlotPaintBar(h_, l_, o_, c_, "CDV Candles",IFf( o_ <= c_ , colorup , colordown)); 2 수식내에 security로 다른데이터를 호출하는 경우에는 내용 파악을 할 수 없어 수식 변환이 가능하지 않습니다. 즐거운 하루되세요 > seayun1 님이 쓴 글입니다. > 제목 : 수식 전환 부탁드립니다 > 안녕하세요 항상 감사드립니다 트레이딩뷰 지표 두가지인데 예트수식으로 전환부탁드립니다 1) study("Cumulative Delta Volume", "CDV") linestyle = input(defval = 'Candle', title = "Style", options = ['Candle', 'Line']) hacandle = input(defval = true, title = "Heikin Ashi Candles?") showma1 = input(defval = false, title = "SMA 1", inline = "ma1") ma1len = input(defval = 50, title = "", minval = 1, inline = "ma1") ma1col = input(defval = color.lime, title = "", inline = "ma1") showma2 = input(defval = false, title = "SMA 2", inline = "ma2") ma2len = input(defval = 200, title = "", minval = 1, inline = "ma2") ma2col = input(defval = color.red, title = "", inline = "ma2") showema1 = input(defval = false, title = "EMA 1", inline = "ema1") ema1len = input(defval = 50, title = "", minval = 1, inline = "ema1") ema1col = input(defval = color.lime, title = "", inline = "ema1") showema2 = input(defval = false, title = "EMA 2", inline = "ema2") ema2len = input(defval = 200, title = "", minval = 1, inline = "ema2") ema2col = input(defval = color.red, title = "", inline = "ema2") colorup = input(defval = color.lime, title = "Body", inline = "bcol") colordown = input(defval = color.red, title = "", inline = "bcol") bcolup = input(defval = #74e05e, title = "Border", inline = "bocol") bcoldown = input(defval = #ffad7d, title = "", inline = "bocol") wcolup = input(defval = #b5b5b8, title = "Wicks", inline = "wcol") wcoldown = input(defval = #b5b5b8, title = "", inline = "wcol") tw = high - max(open, close) bw = min(open, close) - low body = abs(close - open) _rate(cond) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := nz(ret) == 0 ? 0.5 : ret ret deltaup = volume * _rate(open <= close) deltadown = volume * _rate(open > close) delta = close >= open ? deltaup : -deltadown cumdelta = cum(delta) float ctl = na float o = na float h = na float l = na float c = na if linestyle == 'Candle' o := cumdelta[1] h := max(cumdelta, cumdelta[1]) l := min(cumdelta, cumdelta[1]) c := cumdelta ctl else ctl := cumdelta plot(ctl, title = "CDV Line", color = color.blue, linewidth = 2) float haclose = na float haopen = na float hahigh = na float halow = na haclose := (o + h + l + c) / 4 haopen := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2 hahigh := max(h, max(haopen, haclose)) halow := min(l, min(haopen, haclose)) c_ = hacandle ? haclose : c o_ = hacandle ? haopen : o h_ = hacandle ? hahigh : h l_ = hacandle ? halow : l plotcandle(o_, h_, l_, c_, title='CDV Candles', color = o_ <= c_ ? colorup : colordown, bordercolor = o_ <= c_ ? bcolup : bcoldown, wickcolor = o_ <= c_ ? bcolup : bcoldown) plot(showma1 and linestyle == "Candle" ? sma(c_, ma1len) : na, title = "SMA 1", color = ma1col) plot(showma2 and linestyle == "Candle" ? sma(c_, ma2len) : na, title = "SMA 2", color = ma2col) plot(showema1 and linestyle == "Candle" ? ema(c_, ema1len) : na, title = "EMA 1", color = ema1col) plot(showema2 and linestyle == "Candle" ? ema(c_, ema2len) : na, title = "EMA 2", color = ema2col) 2) indicator(title='HA Market Bias', shorttitle='HA Market Bias', overlay=true) tf(_res, _exp, gaps_on) => gaps_on == 0 ? request.security(syminfo.tickerid, _res, _exp) : gaps_on == true ? request.security(syminfo.tickerid, _res, _exp, barmerge.gaps_on, barmerge.lookahead_off) : request.security(syminfo.tickerid, _res, _exp, barmerge.gaps_off, barmerge.lookahead_off) ha_htf = '' show_ha = input.bool(true, "Show HA Plot/ Market Bias", group="HA Market Bias") ha_len = input(100, 'Period', group="HA Market Bias") ha_len2 = input(100, 'Smoothing', group="HA Market Bias") // Calculations { o = ta.ema(open, ha_len) c = ta.ema(close, ha_len) h = ta.ema(high, ha_len) l = ta.ema(low, ha_len) haclose = tf(ha_htf, (o + h + l + c) / 4, 0) xhaopen = tf(ha_htf, (o + c) / 2, 0) haopen = na(xhaopen[1]) ? (o + c) / 2 : (xhaopen[1] + haclose[1]) / 2 hahigh = math.max(h, math.max(haopen, haclose)) halow = math.min(l, math.min(haopen, haclose)) o2 = tf(ha_htf, ta.ema(haopen, ha_len2), 0) c2 = tf(ha_htf, ta.ema(haclose, ha_len2), 0) h2 = tf(ha_htf, ta.ema(hahigh, ha_len2), 0) l2 = tf(ha_htf, ta.ema(halow, ha_len2), 0) ha_avg = (h2 + l2) / 2 // } // Oscillator { osc_len = input.int(7, "Oscillator Period", group="HA Market Bias") osc_bias = 100 *(c2 - o2) osc_smooth = ta.ema(osc_bias, osc_len) sigcolor = (osc_bias > 0) and (osc_bias >= osc_smooth) ? color.new(color.lime, 35) : (osc_bias > 0) and (osc_bias < osc_smooth) ? color.new(color.lime, 75) : (osc_bias < 0) and (osc_bias <= osc_smooth) ? color.new(color.red, 35) : (osc_bias < 0) and (osc_bias > osc_smooth) ? color.new(color.red, 75) : na // } // Plots { p_h = plot(h2, "Bias High", color=color(na), display=display.none, editable=false) p_l = plot(l2, "Bias Low", color=color(na), display=display.none, editable=false) p_avg = plot(ha_avg, "Bias Avergae", color=color(na), display=display.none, editable=false) fill(p_l, p_h, show_ha ? sigcolor : na) col = o2 > c2 ? color.red : color.lime plotcandle(show_ha ? o2 : na, h2, l2, c2, title='heikin smoothed', color=col) // }