RicardoSantos

[RS]Convergence Divergence Impulse Counter V0

EXPERIMENTAL:
Counts the number of impulses with the same direction within a larger trend.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
study(title='[RS]Convergence Divergence Impulse Counter V0', shorttitle='CDIC', overlay=false)
length01 = input(20)
length02 = input(100)
src = input(close)
ma01 = ema(src, length01)
ma02 = ema(src, length02)

cd01 = src - ma01
cd02 = ma01 - ma02

imp = src > ma01 and ma01 > ma02 ? cd01 : src < ma01 and ma01 < ma02 ? cd01 : 0
count = na(count[1]) ? 0 :
        change(crossover(cd02, 0)) > 0 ? 1 :
        change(crossunder(cd02, 0)) > 0 ? -1 :
        count[1] > 0 and change(crossover(cd01, 0)) > 0 ? count[1] + 1 :
        count[1] < 0 and change(crossunder(cd01, 0)) > 0 ? count[1] - 1 :
        count[1]

//plot(series=imp, color=black, style=columns)
//plot(series=cross(cd02, 0) ? 0 : na, color=color(aqua, 0), style=circles, linewidth=4)
plot(series=count, color=black, style=columns)
hline(0)