커뮤니티

수식 문의

프로필 이미지
흑수돌
2022-06-29 12:14:19
1383
글번호 160271
답변완료
아래 지표는 STD Step Ehlers Optimal Tracking Filter 라는 이동평균선값에서 특정 표준편차값이 넘어가야 움직이도록 설정한 지표입니다. 아래 수식을 예트 수식으로 변환하고 싶습니다. 링크 첨부 했습니다. 도움되시기 바랍니다. 부탁드리겠습니다. 감사합니다. indicator('STD Step Ehlers Optimal Tracking Filter MTF w/ Alerts [Loxx]', shorttitle = "STDSEOTFMTFA [Loxx]", overlay = true, timeframe="", timeframe_gaps = true) greencolor = #2DD204 redcolor = #D2042D _filt(src, len, filt)=> price = src filtdev = filt * ta.stdev(src, len) price := math.abs(price - price[1]) < filtdev ? price[1] : price price _otf(src)=> value1 = 0., value2 = 0., lambda = 0., value3 = 0. value1 := 0.2 * (src - nz(src[1])) + 0.8 * nz(value1[1]) value2 := 0.1 * (high - low) + 0.8 * nz(value2[1]) lambda := math.abs(value1 / value2) alpha = (-lambda * lambda + math.sqrt(lambda * lambda * lambda * lambda + 16 * lambda * lambda)) / 8 value3 := alpha * src + (1 - alpha) * nz(value3[1]) value3 src = input.source(hl2, "Soruce", group= "Basic Settings") filterop = input.string("Both", "Filter Options", options = ["Price", "Ehlers OTF", "Both"], group= "Basic Settings") len = input.int(15, "Filter Length", group= "Basic Settings", minval = 1) filtdev = input.float(0.5, "Filter Devaitions", minval = 0, group= "Basic Settings", step = 0.01) colorbars = input.bool(false, "Color bars?", group= "UI Options") showSigs = input.bool(false, "Show signals?", group= "UI Options") price = filterop == "Both" or filterop == "Price" ? _filt(src, len, filtdev) : src otfout = _otf(price) out = filterop == "Both" or filterop == "Ehlers OTF" ? _filt(otfout, len, filtdev) : otfout goLong_pre = ta.crossover(out, out[1]) goShort_pre = ta.crossunder(out, out[1]) contSwitch = 0 contSwitch := nz(contSwitch[1]) contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch goLong = goLong_pre and ta.change(contSwitch) goShort = goShort_pre and ta.change(contSwitch) plot(out,"EOTF", color = contSwitch == 1 ? greencolor : redcolor, linewidth = 3) barcolor(colorbars ? contSwitch == 1 ? greencolor : redcolor : na) plotshape(showSigs and goLong, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.belowbar, size = size.small) plotshape(showSigs and goShort, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.abovebar, size = size.small) alertcondition(goLong, title="Long", message="Ehlers Step OTF: Long₩nSymbol: {{ticker}}₩nPrice: {{close}}") alertcondition(goShort, title="Short", message="Ehlers Step OTF: Short₩nSymbol: {{ticker}}₩nPrice: {{close}}") https://www.tradingview.com/scr**ipt/4ebYbQYv-STD-Stepped-Ehlers-Optimal-Tracking-Filter-MTF-w-Alerts-Loxx/
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-06-29 15:26:43

안녕하세요 예스스탁입니다. 1 지표 input : filterop("Both"),len(15),filtdev(0.5); var : src(0),filtdev1(0),_filt1(0),price(0),otfout(0),out(0); var : lambda(0),alpha(0),filtdev2(0),_filt2(0); var : goLong_pre(False),goShort_pre(False),contSwitch(0),goLong(False),goShort(False); src = (h+l)/2; filtdev1 = filtdev * std(src, len); _filt1 = iff(abs(src - src[1]) < filtdev1, src[1] , src); price = iff(filterop == "Both" or filterop == "Price" , _filt1 , src); value1 = 0; value2 = 0; lambda = 0; value3 = 0; value1 = 0.2 * (price - iff(isnan(price[1])==true,0,price[1])) + 0.8 * iff(isnan(value1[1]) == true,0,value1[1]); value2 = 0.1 * (high - low) + 0.8 * IFf(IsNan(Value2[1]) == true,0,value2[1]); lambda = abs(value1 / value2); alpha = (-lambda * lambda + sqrt(lambda * lambda * lambda * lambda + 16 * lambda * lambda)) / 8; otfout = alpha * src + (1 - alpha) * IFf(IsNan(Value3[1]) == true,0,value3[1]); filtdev2 = filtdev * std(otfout, len); _filt2 = iff(abs(otfout - otfout[1]) < filtdev1, otfout[1] , otfout); out = iff(filterop == "Both" or filterop == "Ehlers OTF" , _filt2 , otfout); goLong_pre = CrossUp(out, out[1]); goShort_pre = CrossDown(out, out[1]); contSwitch = iff(goLong_pre , 1 ,iff(goShort_pre , -1 , contSwitch)); goLong = goLong_pre and contSwitch != contSwitch[1]; goShort = goShort_pre and contSwitch != contSwitch[1]; plot1(out,"EOTF", iff(contSwitch == 1 , green , red)); 2 강조 input : filterop("Both"),len(15),filtdev(0.5),showSigs(false); var : src(0),filtdev1(0),_filt1(0),price(0),otfout(0),out(0); var : lambda(0),alpha(0),filtdev2(0),_filt2(0); var : goLong_pre(False),goShort_pre(False),contSwitch(0),goLong(False),goShort(False); src = (h+l)/2; filtdev1 = filtdev * std(src, len); _filt1 = iff(abs(src - src[1]) < filtdev1, src[1] , src); price = iff(filterop == "Both" or filterop == "Price" , _filt1 , src); value1 = 0; value2 = 0; lambda = 0; value3 = 0; value1 = 0.2 * (price - iff(isnan(price[1])==true,0,price[1])) + 0.8 * iff(isnan(value1[1]) == true,0,value1[1]); value2 = 0.1 * (high - low) + 0.8 * IFf(IsNan(Value2[1]) == true,0,value2[1]); lambda = abs(value1 / value2); alpha = (-lambda * lambda + sqrt(lambda * lambda * lambda * lambda + 16 * lambda * lambda)) / 8; otfout = alpha * src + (1 - alpha) * IFf(IsNan(Value3[1]) == true,0,value3[1]); filtdev2 = filtdev * std(otfout, len); _filt2 = iff(abs(otfout - otfout[1]) < filtdev1, otfout[1] , otfout); out = iff(filterop == "Both" or filterop == "Ehlers OTF" , _filt2 , otfout); goLong_pre = CrossUp(out, out[1]); goShort_pre = CrossDown(out, out[1]); contSwitch = iff(goLong_pre , 1 ,iff(goShort_pre , -1 , contSwitch)); goLong = goLong_pre and contSwitch != contSwitch[1]; goShort = goShort_pre and contSwitch != contSwitch[1]; PlotPaintBar(H,L,"강조",iff(contSwitch == 1 , green , red)); 3 시스템 input : filterop("Both"),len(15),filtdev(0.5); var : src(0),filtdev1(0),_filt1(0),price(0),otfout(0),out(0); var : lambda(0),alpha(0),filtdev2(0),_filt2(0); var : goLong_pre(False),goShort_pre(False),contSwitch(0),goLong(False),goShort(False); src = (h+l)/2; filtdev1 = filtdev * std(src, len); _filt1 = iff(abs(src - src[1]) < filtdev1, src[1] , src); price = iff(filterop == "Both" or filterop == "Price" , _filt1 , src); value1 = 0; value2 = 0; lambda = 0; value3 = 0; value1 = 0.2 * (price - iff(isnan(price[1])==true,0,price[1])) + 0.8 * iff(isnan(value1[1]) == true,0,value1[1]); value2 = 0.1 * (high - low) + 0.8 * IFf(IsNan(Value2[1]) == true,0,value2[1]); lambda = abs(value1 / value2); alpha = (-lambda * lambda + sqrt(lambda * lambda * lambda * lambda + 16 * lambda * lambda)) / 8; otfout = alpha * src + (1 - alpha) * IFf(IsNan(Value3[1]) == true,0,value3[1]); filtdev2 = filtdev * std(otfout, len); _filt2 = iff(abs(otfout - otfout[1]) < filtdev1, otfout[1] , otfout); out = iff(filterop == "Both" or filterop == "Ehlers OTF" , _filt2 , otfout); goLong_pre = CrossUp(out, out[1]); goShort_pre = CrossDown(out, out[1]); contSwitch = iff(goLong_pre , 1 ,iff(goShort_pre , -1 , contSwitch)); goLong = goLong_pre and contSwitch != contSwitch[1]; goShort = goShort_pre and contSwitch != contSwitch[1]; if goLong Then Buy("long"); if goshort Then Sell("short"); 즐거운 하루되세요 > 흑수돌 님이 쓴 글입니다. > 제목 : 수식 문의 > 아래 지표는 STD Step Ehlers Optimal Tracking Filter 라는 이동평균선값에서 특정 표준편차값이 넘어가야 움직이도록 설정한 지표입니다. 아래 수식을 예트 수식으로 변환하고 싶습니다. 링크 첨부 했습니다. 도움되시기 바랍니다. 부탁드리겠습니다. 감사합니다. indicator('STD Step Ehlers Optimal Tracking Filter MTF w/ Alerts [Loxx]', shorttitle = "STDSEOTFMTFA [Loxx]", overlay = true, timeframe="", timeframe_gaps = true) greencolor = #2DD204 redcolor = #D2042D _filt(src, len, filt)=> price = src filtdev = filt * ta.stdev(src, len) price := math.abs(price - price[1]) < filtdev ? price[1] : price price _otf(src)=> value1 = 0., value2 = 0., lambda = 0., value3 = 0. value1 := 0.2 * (src - nz(src[1])) + 0.8 * nz(value1[1]) value2 := 0.1 * (high - low) + 0.8 * nz(value2[1]) lambda := math.abs(value1 / value2) alpha = (-lambda * lambda + math.sqrt(lambda * lambda * lambda * lambda + 16 * lambda * lambda)) / 8 value3 := alpha * src + (1 - alpha) * nz(value3[1]) value3 src = input.source(hl2, "Soruce", group= "Basic Settings") filterop = input.string("Both", "Filter Options", options = ["Price", "Ehlers OTF", "Both"], group= "Basic Settings") len = input.int(15, "Filter Length", group= "Basic Settings", minval = 1) filtdev = input.float(0.5, "Filter Devaitions", minval = 0, group= "Basic Settings", step = 0.01) colorbars = input.bool(false, "Color bars?", group= "UI Options") showSigs = input.bool(false, "Show signals?", group= "UI Options") price = filterop == "Both" or filterop == "Price" ? _filt(src, len, filtdev) : src otfout = _otf(price) out = filterop == "Both" or filterop == "Ehlers OTF" ? _filt(otfout, len, filtdev) : otfout goLong_pre = ta.crossover(out, out[1]) goShort_pre = ta.crossunder(out, out[1]) contSwitch = 0 contSwitch := nz(contSwitch[1]) contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch goLong = goLong_pre and ta.change(contSwitch) goShort = goShort_pre and ta.change(contSwitch) plot(out,"EOTF", color = contSwitch == 1 ? greencolor : redcolor, linewidth = 3) barcolor(colorbars ? contSwitch == 1 ? greencolor : redcolor : na) plotshape(showSigs and goLong, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.belowbar, size = size.small) plotshape(showSigs and goShort, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.abovebar, size = size.small) alertcondition(goLong, title="Long", message="Ehlers Step OTF: Long₩nSymbol: {{ticker}}₩nPrice: {{close}}") alertcondition(goShort, title="Short", message="Ehlers Step OTF: Short₩nSymbol: {{ticker}}₩nPrice: {{close}}") https://www.tradingview.com/scr**ipt/4ebYbQYv-STD-Stepped-Ehlers-Optimal-Tracking-Filter-MTF-w-Alerts-Loxx/