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提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。