OPEN-SOURCE SCRIPT
Composite Market Momentum Indicator

//version=5
indicator("Composite Market Momentum Indicator", shorttitle="CMMI", overlay=false)
// Define Inputs
lenRSI = input.int(14, title="RSI Length")
lenMom = input.int(9, title="Momentum Length")
lenShortRSI = input.int(3, title="Short RSI Length")
lenShortRSISma = input.int(3, title="Short RSI SMA Length")
lenSMA1 = input.int(9, title="Composite SMA 1 Length")
lenSMA2 = input.int(34, title="Composite SMA 2 Length")
// Step 1: Create a 9-period momentum indicator of the 14-period RSI
rsiValue = ta.rsi(close, lenRSI)
momRSI = ta.mom(rsiValue, lenMom)
// Step 2: Create a 3-period RSI and a 3-period SMA of that RSI
shortRSI = ta.rsi(close, lenShortRSI)
shortRSISmoothed = ta.sma(shortRSI, lenShortRSISma)
// Step 3: Add Step 1 and Step 2 together to create the Composite Index
compositeIndex = momRSI + shortRSISmoothed
// Step 4: Create two simple moving averages of the Composite Index
sma1 = ta.sma(compositeIndex, lenSMA1)
sma2 = ta.sma(compositeIndex, lenSMA2)
// Step 5: Plot the composite index and its two simple moving averages
plot(compositeIndex, title="Composite Index", color=color.new(#f7cf05, 0), linewidth=2)
plot(sma1, title="SMA 13", color=color.new(#f32121, 0), linewidth=1, style=plot.style_line)
plot(sma2, title="SMA 33", color=color.new(#105eef, 0), linewidth=1, style=plot.style_line)
// Add horizontal lines for reference
hline(0, "Zero Line", color.new(color.gray, 50))
indicator("Composite Market Momentum Indicator", shorttitle="CMMI", overlay=false)
// Define Inputs
lenRSI = input.int(14, title="RSI Length")
lenMom = input.int(9, title="Momentum Length")
lenShortRSI = input.int(3, title="Short RSI Length")
lenShortRSISma = input.int(3, title="Short RSI SMA Length")
lenSMA1 = input.int(9, title="Composite SMA 1 Length")
lenSMA2 = input.int(34, title="Composite SMA 2 Length")
// Step 1: Create a 9-period momentum indicator of the 14-period RSI
rsiValue = ta.rsi(close, lenRSI)
momRSI = ta.mom(rsiValue, lenMom)
// Step 2: Create a 3-period RSI and a 3-period SMA of that RSI
shortRSI = ta.rsi(close, lenShortRSI)
shortRSISmoothed = ta.sma(shortRSI, lenShortRSISma)
// Step 3: Add Step 1 and Step 2 together to create the Composite Index
compositeIndex = momRSI + shortRSISmoothed
// Step 4: Create two simple moving averages of the Composite Index
sma1 = ta.sma(compositeIndex, lenSMA1)
sma2 = ta.sma(compositeIndex, lenSMA2)
// Step 5: Plot the composite index and its two simple moving averages
plot(compositeIndex, title="Composite Index", color=color.new(#f7cf05, 0), linewidth=2)
plot(sma1, title="SMA 13", color=color.new(#f32121, 0), linewidth=1, style=plot.style_line)
plot(sma2, title="SMA 33", color=color.new(#105eef, 0), linewidth=1, style=plot.style_line)
// Add horizontal lines for reference
hline(0, "Zero Line", color.new(color.gray, 50))
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。