·Î±×ÀÎ
|
ȸ¿ø°¡ÀÔ
|
ȸ»ç¼Ò°³
|
»çÀÌÆ®¸Ê
Ä¿¹Â´ÏƼ | ¼ö½ÄÀÛ¼º Q&A
ÀÛ¼ºÀÚ :
µ¥´Ï¾ó
ÀÛ¼ºÀÏ : 2025-05-10 ¿ÀÀü 10:55:38 Á¶È¸¼ö : 42
ÁöÇ¥Àüȯ ¿äû
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ºÐºÀ¿¡¼¶óµµ °¡´ÉÇÏ´Ù¸é µ¹¾Æ°¡°Ô °¡´ÉÇÒÁö¿ä ºÎʵå·Áº¾´Ï´Ù
¼ö½Ä ¼öÁ¤ ºÎʵ右´Ï´Ù.
¼ö½Äº¯È¯¿äûµå¸³´Ï´Ù
°ü·Ã ±Û ¸®½ºÆ®
ÇöÀç±Û
ÁöÇ¥Àüȯ ¿äû
µ¥´Ï¾ó
2025.05.10
42
Re : ÁöÇ¥Àüȯ ¿äû
¿¹½º½ºÅ¹
2025.05.12
37