커뮤니티

지표전환 요청

프로필 이미지
데니얼
2025-05-10 10:55:38
349
글번호 190706
답변완료
study("Divergence Histogram for many indicator", overlay=false, max_bars_back = 4000) lrb = input(5, title="Pivot Point Period", minval = 1) mindiv = input(1, title="Minimum #Num of Divergence for Alert", minval = 1) chcut = input(false, title = "Check Cut-Through in indicators") // RSI rsi = rsi(close, 14) // MACD [macd, signal, deltamacd] = macd(close, 12, 26, 9) // Momentum moment = mom(close, 10) // CCI cci = cci(close, 10) // OBV Obv = obv // cum(change(close) > 0 ? volume : change(close) < 0 ? -volume : 0 * volume) // Stoch stk = sma(stoch(close, high, low, 14), 3) // DIOSC DI = change(high) - (-change(low)) trur = rma(tr, 14) diosc = fixnan(100 * rma(DI, 14) / trur) // volume weighted macd maFast = vwma(close, 12) maSlow = vwma(close, 26) vwmacd = maFast - maSlow // Chaikin money flow Cmfm = ((close-low) - (high-close)) / (high - low) Cmfv = Cmfm * volume cmf = sma(Cmfv, 21) / sma(volume,21) // Moneyt Flow Index Mfi = mfi(close, 14) float top = na float bot = na top := pivothigh(lrb, lrb) bot := pivotlow(lrb, lrb) topc = 0, botc = 0 topc := top ? lrb : nz(topc[1]) + 1 botc := bot ? lrb : nz(botc[1]) + 1 // Negative Divergence (checking possible higher highs(lb=0)) newtop = pivothigh(lrb, 0) // check only left side emptyh = true if not na(newtop) and newtop > high[topc] // there must not close price higher than the line between last PH and current high diff = (newtop - high[topc]) / topc hline = newtop - diff // virtual line to check there is no close price higher than it for x = 1 to topc -1 if close[x] > hline emptyh := false break hline := hline - diff else emptyh := false // check cut-through in indicators nocut1(indi, len)=> _ret = true diff = (indi - nz(indi[len])) / len ln = indi - diff for x = 1 to len -1 if nz(indi[x]) > ln _ret := false break ln := ln - diff _ret rsiokn = nocut1(rsi, topc) macdokn = nocut1(macd, topc) deltamacdokn = nocut1(deltamacd, topc) momentokn = nocut1(moment, topc) cciokn = nocut1(cci, topc) obvokn = nocut1(obv, topc) stkokn = nocut1(stk, topc) dioscokn = nocut1(diosc, topc) vwmacdokn = nocut1(vwmacd, topc) cmfokn = nocut1(cmf, topc) mfiokn = nocut1(Mfi, topc) negadiv(indi, isok)=> _ret = (emptyh and not na(newtop) and indi[topc] > indi and (not chcut or isok)) // Positive Divergence (checking possible Lower lows(lb=0)) newbot = pivotlow(lrb, 0) // check only left side emptyl = true if not na(newbot) and newbot < low[botc] // there must not close price lower than the line between last PL and current low diff = (newbot - low[botc]) / botc lline = newbot - diff // virtual line to check there is no close price lower than it for x = 1 to botc -1 if close[x] < lline emptyl := false break lline := lline - diff else emptyl := false // check cut-through in indicators nocut2(indi, len)=> _ret = true diff = (indi - nz(indi[len])) / len ln = indi - diff for x = 1 to len -1 if nz(indi[x]) < ln _ret := false break ln := ln - diff _ret rsiokp = nocut2(rsi, botc) macdokp = nocut2(macd, botc) deltamacdokp = nocut2(deltamacd, botc) momentokp = nocut2(moment, botc) cciokp = nocut2(cci, botc) obvokp = nocut2(obv, botc) stkokp = nocut2(stk, botc) dioscokp = nocut2(diosc, botc) vwmacdokp = nocut2(vwmacd, botc) cmfokp = nocut2(cmf, botc) mfiokp = nocut2(Mfi, botc) posidiv(indi, isok)=> _ret = (emptyl and not na(newbot) and indi[botc] < indi and (not chcut or isok)) indi1 = iff(posidiv(rsi, rsiokp), 1, iff(negadiv(rsi, rsiokn), -1, 0)) indi2 = iff(posidiv(macd, macdokp), 1, iff(negadiv(macd, macdokn), -1, 0)) indi3 = iff(posidiv(deltamacd, deltamacdokp), 1, iff(negadiv(deltamacd, deltamacdokn), -1, 0)) indi4 = iff(posidiv(moment, momentokp), 1, iff(negadiv(moment, momentokn), -1, 0)) indi5 = iff(posidiv(cci, cciokp), 1, iff(negadiv(cci, cciokn), -1, 0)) indi6 = iff(posidiv(Obv, obvokp), 1, iff(negadiv(Obv, obvokn), -1, 0)) indi7 = iff(posidiv(stk, stkokp), 1, iff(negadiv(stk, stkokn), -1, 0)) indi8 = iff(posidiv(diosc, dioscokp), 1, iff(negadiv(diosc, dioscokn), -1, 0)) indi9 = iff(posidiv(vwmacd, vwmacdokp), 1, iff(negadiv(vwmacd, vwmacdokn), -1, 0)) indi10 = iff(posidiv(cmf, cmfokp), 1, iff(negadiv(cmf, cmfokn), -1, 0)) indi11 = iff(posidiv(Mfi, mfiokp), 1, iff(negadiv(Mfi, mfiokn), -1, 0)) totaldiv = indi1 + indi2 + indi3 + indi4 + indi5 + indi6 + indi7 + indi8 + indi9 + indi10 + indi11 hline(0, color = color.gray, linestyle = hline.style_dotted) plot(abs(totaldiv), color = totaldiv > 0 ? color.new(color.lime, 0) :totaldiv < 0 ? color.new(color.red, 0) : na, style = plot.style_columns, linewidth = 6) if totaldiv != 0 label.new(x = bar_index, y = abs(totaldiv), text = tostring(abs(totaldiv)), color = color.new(color.white, 100), textcolor = totaldiv < 0 ? color.red : color.lime) alertcondition(totaldiv >= mindiv, title='Positive Divergence', message='Positive Divergence') alertcondition(totaldiv <= -mindiv, title='Negative Divergence', message='Negative Divergence') 파인스크립트지표입니다 실력이 부족해서 예스랭귀지로 전환요청 부탁드립니다 -다른 모델에서 타주기참조로 전환이 어렵다 답변받았는데 가능하다면 5분봉에서라도 가능하다면 돌아가게 가능할지요 부탁드려봅니다
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-12 11:33:46

안녕하세요 예스스탁입니다. 함수내 정확한 계산방법을 알수 없어 몇몇 지표들은 내부계산에 차이가 있어 값이 다를수 있습니다. input : lrb(5); input : mindiv(1); input : chcut(false); var : R(0),MACDV(0),signal(0),deltamacd(0),moment(0),cciv(0); var : ob(0),stk(0),DI(0),Trur(0),diosc(0); var : A1(0),Rmav(0),maFast(0),maSlow(0),vwmacd(0); var : Cmfm(0),Cmfv(0),cmf(0),MFIV(0); var : top(Nan),bot(Nan),topc(0),botc(0),newTop(0); var : emptyh(False),diff(0),hline(0),x(0); var : newbot(0),emptyl(false),lline(0); var : rsiokn(False),macdokn(False),deltamacdokn(False); var : momentokn(False),cciokn(False),obvokn(False); var : stkokn(False),dioscokn(False),vwmacdokn(False); var : cmfokn(false),mfiokn(False); var : rsiokp(False),macdokp(False),deltamacdokp(False); var : momentokp(False),cciokp(False),obvokp(False); var : stkokp(False),dioscokp(False),vwmacdokp(False); var : cmfokp(False),mfiokp(False); var : N1(False),P1(False),indi1(0); var : N2(False),P2(False),indi2(0); var : N3(False),P3(False),indi3(0); var : N4(False),P4(False),indi4(0); var : N5(False),P5(False),indi5(0); var : N6(False),P6(False),indi6(0); var : N7(False),P7(False),indi7(0); var : N8(False),P8(False),indi8(0); var : N9(False),P9(False),indi9(0); var : N10(False),P10(False),indi10(0); var : N11(False),P11(False),indi11(0); var : totaldiv(0); R = rsi(14); macdv = macd(12, 26); signal = ema(macdv,9); deltamacd = macdv-signal; moment = close-close[10]; cciv = cci(10); Ob = obv; stk = ma(Fastk(14), 3); DI = (high-High[1]) - (-(low-Low[1])); A1 = 1 / 14; trur = IFf(IsNan(trur[1]) == true, ma(TrueRange,14) , A1 * TrueRange + (1 - A1) * IFf(isnan(trur[1])==true,0,trur[1])); Rmav = IFf(IsNan(Rmav[1]) == true, ma(DI,14) , A1 * DI + (1 - A1) * IFf(isnan(Rmav[1])==true,0,Rmav[1])); diosc = 100 * Rmav / trur; maFast = ma(C*V,12)/ma(V,12); maSlow = ma(C*V,26)/ma(V,26); vwmacd = maFast - maSlow; Cmfm = ((close-low) - (high-close)) / (high - low); Cmfv = Cmfm * volume; cmf = ma(Cmfv, 21) / ma(volume,21); Mfiv = mfi(14); if SwingHigh(1,H,lrb,lrb,lrb*2+1) != -1 Then { top = H[lrb]; topc = Lrb; } Else { top = Nan; topc = topc+1; } if Swinglow(1,L,lrb,lrb,lrb*2+1) != -1 Then { bot = L[lrb]; botc = lrb; } Else { bot = Nan; botc = botc+1; } if SwingHigh(1,H,lrb,0,lrb*1+1) != -1 Then newtop = H; Else newtop = Nan; emptyh = true; if newtop > 0 and newtop > high[topc] Then { diff = (newtop - high[topc]) / topc; hline = newtop - diff; for x = 1 to topc -1 { if emptyh == true and close[x] > hline Then { emptyh = false; } hline = hline - diff; } } else { emptyh = false; } rsiokn = nocut1(r, topc); macdokn = nocut1(macdv, topc); deltamacdokn = nocut1(deltamacd, topc); momentokn = nocut1(moment, topc); cciokn = nocut1(cciv, topc); obvokn = nocut1(ob, topc); stkokn = nocut1(stk, topc); dioscokn = nocut1(diosc, topc); vwmacdokn = nocut1(vwmacd, topc); cmfokn = nocut1(cmf, topc); mfiokn = nocut1(Mfiv, topc); if SwingLow(1,L,lrb,0,lrb*1+1) != -1 Then newbot = L; Else newbot = Nan; emptyl = true; if newbot > 0 and newbot < low[botc] Then { diff = (newbot - low[botc]) / botc; lline = newbot - diff; for x = 1 to botc -1 { if emptyl == true and close[x] < lline then { emptyl = false; } lline = lline - diff; } } else emptyl = false; rsiokp = nocut2(R, botc); macdokp = nocut2(macdv, botc); deltamacdokp = nocut2(deltamacd, botc); momentokp = nocut2(moment, botc); cciokp = nocut2(cciv, botc); obvokp = nocut2(ob, botc); stkokp = nocut2(stk, botc); dioscokp = nocut2(diosc, botc); vwmacdokp = nocut2(vwmacd, botc); cmfokp = nocut2(cmf, botc); mfiokp = nocut2(Mfiv, botc); P1 = emptyl and newbot > 0 and R[botc] < R and (chcut == False or rsiokp == true); N1 = emptyh and newtop > 0 and R[topc] > R and (chcut == False or rsiokn == true); indi1 = iff(P1, 1, iff(N1, -1, 0)); P2 = emptyl and newbot > 0 and macdv[botc] < macdv and (chcut == False or macdokp == true); N2 = emptyh and newtop > 0 and macdv[topc] > macdv and (chcut == False or macdokn == true); indi2 = iff(P2, 1, iff(N2, -1, 0)); P3 = emptyl and newbot > 0 and deltamacd[botc] < deltamacd and (chcut == false or deltamacdokp == true); N3 = emptyh and newtop > 0 and deltamacd[topc] > deltamacd and (chcut == false or deltamacdokn == true); indi3 = iff(P3, 1, iff(N3, -1, 0)); P4 = emptyl and newbot > 0 and moment[botc] < moment and (chcut == false or momentokp == true); N4 = emptyh and newtop > 0 and moment[topc] > moment and (chcut == false or momentokn == true); indi4 = iff(P4, 1, iff(N4, -1, 0)); P5 = emptyl and newbot > 0 and cciv[botc] < cciv and (chcut == false or cciokp == true); N5 = emptyh and newtop > 0 and cciv[topc] > cciv and (chcut == false or cciokn == true); indi5 = iff(P5, 1, iff(N5, -1, 0)); P6 = emptyl and newbot > 0 and Ob[botc] < Ob and (chcut == false or obvokp == true); N6 = emptyh and newtop > 0 and Ob[topc] > Ob and (chcut == false or obvokn == true); indi6 = iff(P6, 1, iff(N6, -1, 0)); P7 = emptyl and newbot > 0 and stk[botc] < stk and (chcut == false or stkokp == true); N7 = emptyh and newtop > 0 and stk[topc] > stk and (chcut == false or stkokn == true); indi7 = iff(P7, 1, iff(N7, -1, 0)); P8 = emptyl and newbot > 0 and diosc[botc] < diosc and (chcut == false or dioscokp == true); N8 = emptyh and newtop > 0 and diosc[topc] > diosc and (chcut == false or dioscokn == true); indi8 = iff(P8, 1, iff(N8, -1, 0)); P9 = emptyl and newbot > 0 and vwmacd[botc] < vwmacd and (chcut == false or vwmacdokp == true); N9 = emptyh and newtop > 0 and vwmacd[topc] > vwmacd and (chcut == false or vwmacdokn == true); indi9 = iff(P9, 1, iff(N9, -1, 0)); P10 = emptyl and newbot > 0 and cmf[botc] < cmf and (chcut == false or cmfokp == true); N10 = emptyh and newtop > 0 and cmf[topc] > cmf and (chcut == false or cmfokn == true); indi10 = iff(P10, 1, iff(N10, -1, 0)); P11 = emptyl and newbot > 0 and Mfiv[botc] < Mfiv and (chcut == false or mfiokp == true); N11 = emptyh and newtop > 0 and Mfiv[topc] > Mfiv and (chcut == false or mfiokn == true); indi11 = iff(P11, 1, iff(N11, -1, 0)); totaldiv = indi1 + indi2 + indi3 + indi4 + indi5 + indi6 + indi7 + indi8 + indi9 + indi10 + indi11; PlotBaseLine1(0,"0선",gray); plot1(abs(totaldiv), "totaldiv", IFf( totaldiv > 0 , lime , iff(totaldiv < 0 , red , Black))); var : tx(0); if totaldiv != 0 Then { tx = Text_New_Self(sDate,sTime,abs(totaldiv),NumToStr(abs(totaldiv),0)); Text_SetColor(tx,iff(totaldiv < 0 ,red , lime)); Text_SetStyle(tx,2,1); } 즐거운 하루되세요 > 데니얼 님이 쓴 글입니다. > 제목 : 지표전환 요청 > study("Divergence Histogram for many indicator", overlay=false, max_bars_back = 4000) lrb = input(5, title="Pivot Point Period", minval = 1) mindiv = input(1, title="Minimum #Num of Divergence for Alert", minval = 1) chcut = input(false, title = "Check Cut-Through in indicators") // RSI rsi = rsi(close, 14) // MACD [macd, signal, deltamacd] = macd(close, 12, 26, 9) // Momentum moment = mom(close, 10) // CCI cci = cci(close, 10) // OBV Obv = obv // cum(change(close) > 0 ? volume : change(close) < 0 ? -volume : 0 * volume) // Stoch stk = sma(stoch(close, high, low, 14), 3) // DIOSC DI = change(high) - (-change(low)) trur = rma(tr, 14) diosc = fixnan(100 * rma(DI, 14) / trur) // volume weighted macd maFast = vwma(close, 12) maSlow = vwma(close, 26) vwmacd = maFast - maSlow // Chaikin money flow Cmfm = ((close-low) - (high-close)) / (high - low) Cmfv = Cmfm * volume cmf = sma(Cmfv, 21) / sma(volume,21) // Moneyt Flow Index Mfi = mfi(close, 14) float top = na float bot = na top := pivothigh(lrb, lrb) bot := pivotlow(lrb, lrb) topc = 0, botc = 0 topc := top ? lrb : nz(topc[1]) + 1 botc := bot ? lrb : nz(botc[1]) + 1 // Negative Divergence (checking possible higher highs(lb=0)) newtop = pivothigh(lrb, 0) // check only left side emptyh = true if not na(newtop) and newtop > high[topc] // there must not close price higher than the line between last PH and current high diff = (newtop - high[topc]) / topc hline = newtop - diff // virtual line to check there is no close price higher than it for x = 1 to topc -1 if close[x] > hline emptyh := false break hline := hline - diff else emptyh := false // check cut-through in indicators nocut1(indi, len)=> _ret = true diff = (indi - nz(indi[len])) / len ln = indi - diff for x = 1 to len -1 if nz(indi[x]) > ln _ret := false break ln := ln - diff _ret rsiokn = nocut1(rsi, topc) macdokn = nocut1(macd, topc) deltamacdokn = nocut1(deltamacd, topc) momentokn = nocut1(moment, topc) cciokn = nocut1(cci, topc) obvokn = nocut1(obv, topc) stkokn = nocut1(stk, topc) dioscokn = nocut1(diosc, topc) vwmacdokn = nocut1(vwmacd, topc) cmfokn = nocut1(cmf, topc) mfiokn = nocut1(Mfi, topc) negadiv(indi, isok)=> _ret = (emptyh and not na(newtop) and indi[topc] > indi and (not chcut or isok)) // Positive Divergence (checking possible Lower lows(lb=0)) newbot = pivotlow(lrb, 0) // check only left side emptyl = true if not na(newbot) and newbot < low[botc] // there must not close price lower than the line between last PL and current low diff = (newbot - low[botc]) / botc lline = newbot - diff // virtual line to check there is no close price lower than it for x = 1 to botc -1 if close[x] < lline emptyl := false break lline := lline - diff else emptyl := false // check cut-through in indicators nocut2(indi, len)=> _ret = true diff = (indi - nz(indi[len])) / len ln = indi - diff for x = 1 to len -1 if nz(indi[x]) < ln _ret := false break ln := ln - diff _ret rsiokp = nocut2(rsi, botc) macdokp = nocut2(macd, botc) deltamacdokp = nocut2(deltamacd, botc) momentokp = nocut2(moment, botc) cciokp = nocut2(cci, botc) obvokp = nocut2(obv, botc) stkokp = nocut2(stk, botc) dioscokp = nocut2(diosc, botc) vwmacdokp = nocut2(vwmacd, botc) cmfokp = nocut2(cmf, botc) mfiokp = nocut2(Mfi, botc) posidiv(indi, isok)=> _ret = (emptyl and not na(newbot) and indi[botc] < indi and (not chcut or isok)) indi1 = iff(posidiv(rsi, rsiokp), 1, iff(negadiv(rsi, rsiokn), -1, 0)) indi2 = iff(posidiv(macd, macdokp), 1, iff(negadiv(macd, macdokn), -1, 0)) indi3 = iff(posidiv(deltamacd, deltamacdokp), 1, iff(negadiv(deltamacd, deltamacdokn), -1, 0)) indi4 = iff(posidiv(moment, momentokp), 1, iff(negadiv(moment, momentokn), -1, 0)) indi5 = iff(posidiv(cci, cciokp), 1, iff(negadiv(cci, cciokn), -1, 0)) indi6 = iff(posidiv(Obv, obvokp), 1, iff(negadiv(Obv, obvokn), -1, 0)) indi7 = iff(posidiv(stk, stkokp), 1, iff(negadiv(stk, stkokn), -1, 0)) indi8 = iff(posidiv(diosc, dioscokp), 1, iff(negadiv(diosc, dioscokn), -1, 0)) indi9 = iff(posidiv(vwmacd, vwmacdokp), 1, iff(negadiv(vwmacd, vwmacdokn), -1, 0)) indi10 = iff(posidiv(cmf, cmfokp), 1, iff(negadiv(cmf, cmfokn), -1, 0)) indi11 = iff(posidiv(Mfi, mfiokp), 1, iff(negadiv(Mfi, mfiokn), -1, 0)) totaldiv = indi1 + indi2 + indi3 + indi4 + indi5 + indi6 + indi7 + indi8 + indi9 + indi10 + indi11 hline(0, color = color.gray, linestyle = hline.style_dotted) plot(abs(totaldiv), color = totaldiv > 0 ? color.new(color.lime, 0) :totaldiv < 0 ? color.new(color.red, 0) : na, style = plot.style_columns, linewidth = 6) if totaldiv != 0 label.new(x = bar_index, y = abs(totaldiv), text = tostring(abs(totaldiv)), color = color.new(color.white, 100), textcolor = totaldiv < 0 ? color.red : color.lime) alertcondition(totaldiv >= mindiv, title='Positive Divergence', message='Positive Divergence') alertcondition(totaldiv <= -mindiv, title='Negative Divergence', message='Negative Divergence') 파인스크립트지표입니다 실력이 부족해서 예스랭귀지로 전환요청 부탁드립니다 -다른 모델에서 타주기참조로 전환이 어렵다 답변받았는데 가능하다면 5분봉에서라도 가능하다면 돌아가게 가능할지요 부탁드려봅니다