股市指标计算公式 RSI MACD ADL KDJ MSI CCI CMF

我成立了量化交易群,QQ群号为 218048224, 欢迎交流

RSI

https://www.tradingview.com/chart/EURUSD/vbyfu4Ky-Mean-Reversion-Trading-Strategies-and-Indicators/
在这里插入图片描述
在这里插入图片描述

MACD

在这里插入图片描述差与差的9日均值之间的差就是MACD柱

MACD代表股价上升或下降的趋势,RSI代表股价上升或下降的动能

https://www.tradingview.com/pine-script-docs/en/v5/primer/First_indicator.html

//@version=5
indicator("MACD #1")
fast = 12
slow = 26
fastMA = ta.ema(close, fast)
slowMA = ta.ema(close, slow)
macd = fastMA - slowMA
signal = ta.ema(macd, 9)
plot(macd, color = color.blue)
plot(signal, color = color.orange)
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © johnwang9
//@version=5
indicator("MACD #2")
fastInput = input(12, "Fast length")
slowInput = input(26, "Slow length")
[macdLine, signalLine, histLine] = ta.macd(close, fastInput, slowInput, 9)
plot(macdLine, color = color.blue)
plot(signalLine, color = color.orange)
plot(histLine, color = histLine > 0 ? color.green : color.red, linewidth = 2, style = plot.style_histogram)

QQQ 125天的均线有一定的指导意义

ADL

在这里插入图片描述

CMF

佳庆资金流量指标基于这样的假设,即强势市场(处于上升趋势的市场)通常都伴随着位于日最高价与最低价之间上半部分的收盘价以及放大的成交量。与此相反,弱势市场(处于下跌趋势的市场)通常都伴随着位于日最高价与最低价之间的下半部分的收盘价以及放大的成交量。
如果在成交量放大的同时,价格持续收于日最高价与最低价之间的上半部分,那么该指标将会是正值,表示该证券处于强势之中。相反,如果在成交量放大的同时,价格持续收于日最高价与最低价之间的下半部分,那么该指标将是负值,表示该证券处于弱势之中。
简单的说,CMF其实可以用中国人常用的“热钱指数”来形容,它是用图表来将买家的购买力和卖家的抛售力度形像化。在一个图表上,以零为中位线,上限是正0.3,下限是负0.3。
多空对比(CLV)=(2×收盘价-最高价-最低价)÷(最高价-最低价) (当最高价=最低价时,CLV=0)
CMF[K]=Σ(Vol[K-J])×CLV[K-J])÷Σ(Vol[K-J]) (0≤J<n)

McClellan Summation Index

While the McClellan Oscillator puts a little momentum into the AD Line, the Summation Index takes a little out by slowing down the oscillator. The Summation Index is also quite a few steps removed from the original indicator, which is Net Advances. In other words, it takes three separate calculations to produce Summation Index values. The first derivatives (steps) are the 19-day EMA of Net Advances and 39-day EMA of Net Advances. The second derivative is the McClellan Oscillator, which is the 19-day EMA of Net Advances less the 39-day EMA of Net Advances. The third derivative is the Summation Index, which is a cumulative McClellan Oscillator. Each additional calculation changes Net Advances from its original form.

在这里插入图片描述直接从OSC看出下降通道有三次背离,下降通道目前只有两次,应该还有上升空间,但目前点位太高,等运行至下轨再买入指数

indicator("McClellan Summation Index", shorttitle="McClellan Summation Index",  precision=1)

type=input.string("MSI", options=["MSI RSI", "MO", "MSI"])
//type=input.string("MO", options=["MSI RSI", "MO"])
limecolor = #00FF00
period_msi = timeframe.period
//period_msi = "D" //fixed to daily
prev = 1

headwind = input(70, title="Head Wind")
tailwind = input(30, title="Tail Wind")

length = input(14, title="RSI length")
exchange = input.string(defval="NYSE", title="Choose Exchange", options=["NASDAQ", "NYSE", "NASDAQ+NYSE"])

nasdaq_adv = request.security("ADVQ", period_msi, close)
nasdaq_dec = request.security("DECLQ", period_msi, close)
nyse_adv = request.security("ADVN", period_msi, close)
nyse_dec = request.security("DECN", period_msi, close)

adv = (exchange == "NASDAQ") ? nasdaq_adv : (exchange == "NYSE") ? nyse_adv : nasdaq_adv + nyse_adv
dec = (exchange == "NASDAQ") ? nasdaq_dec : (exchange == "NYSE") ? nyse_dec : nasdaq_dec + nyse_dec

// rana = ratio_adjusted_ned_advance
// rana = (sym(advissues) - sym(decissues)) / (sym(advissues) + sym(decissues)) * 1000
rana = (adv - dec) / (adv + dec) * 1000

advnema19 = ta.ema(rana, 19)
advnema39 = ta.ema(rana, 39)
osci = advnema19-advnema39
msi = ta.cum(osci)

// McClellan Oscillator
rsi_msi = ta.rsi(msi, length)
isMSIUpTrend() => rsi_msi > rsi_msi[prev]
isMSIDownTrend() => rsi_msi <= rsi_msi[prev]
isHeadWind() => rsi_msi >= headwind
isTailWind() => rsi_msi <= tailwind
crossDownHeadWind() => rsi_msi
crossUpTailWind() => rsi_msi


showosi() => ("MO" == type) ? true : false

plot(showosi() ? osci : na, style=plot.style_line, title="MO", linewidth=2, color=color.black)
plot(showosi() ? 0 : na, style=plot.style_line, title="0", linewidth=1, color=color.new(color.gray, 30))
plot(showosi() ? -100 : na, color=na)
plot(showosi() ? 100  : na, color=na)

ma_length = input(9, title="MO MA Length")
ma_mo = ta.ema(osci, ma_length)
plot(showosi() ? ma_mo : na, title="MA", linewidth=2, color=color.red)


isMOUpTrend() => ma_mo > ma_mo[prev]
isMODownTrend() => ma_mo <= ma_mo[prev]

bgcolor(showosi() ? (isMOUpTrend() ? color.new(limecolor, 80) : na  ) : na)
bgcolor(showosi() ? (isMODownTrend() ? color.new(color.red , 80): na) : na)

// McClellan Summation Index
showmsi() => ("MSI RSI" == type) ? true : false

plot(showmsi() ? 50 : na, title="50", style=plot.style_line, linewidth=1, color=color.new(color.gray, 30))
headline=plot(showmsi() ? headwind : na, style=plot.style_line, color=color.new(color.green, 20), title="headwind")
tailline=plot(showmsi() ? tailwind : na, style=plot.style_line, color=color.new(color.red, 20), title="tailwind")
rsiline= plot(showmsi() ? rsi_msi  : na, style=plot.style_line, color=color.black, linewidth=2, title="RSI_MSI")

headcolor = showmsi() ? (isHeadWind() and isMSIDownTrend() ? color.red : na) : na
tailcolor = showmsi() ? (isTailWind() and isMSIUpTrend()  ? limecolor : na ) : na
//fill(rsiline, headline, color=color.new(headcolor, 50))
//fill(rsiline, tailline, color=color.new(tailcolor, 50))
//bgcolor(showmsi() ? (isMSIUpTrend() ? color.new(limecolor, 80) : na  ) : na)
//bgcolor(showmsi() ? (isMSIDownTrend() ? color.new(color.red, 80): na) : na)

// McClellan Summation Index
headwind1 = input(1600, title="Head Wind")
alarm = input(800, title ="top alarm")
tailwind1 = input(-800, title="Tail Wind")
rana1 = (adv - dec)
advnema191 = ta.ema(rana1, 19)
advnema391 = ta.ema(rana1, 39)
osci1 = advnema191-advnema391
msi1 = ta.cum(osci1)
msiema = ta.ema(msi1, 10)
showrealmsi() => ("MSI" == type) ? true : false
headline1=plot(showrealmsi() ? headwind1 : na, style=plot.style_line, color=color.new(color.green, 0), title="headwind")
tailline1=plot(showrealmsi() ? tailwind1 : na, style=plot.style_line, color=color.new(color.red, 0), title="tailwind")
alarmline1=plot(showrealmsi() ? alarm : na, style=plot.style_line, color=color.new(color.blue, 0), title="alarmwind")
plot(showrealmsi() ? 0 : na, style=plot.style_line, title="0", linewidth=1, color=color.new(color.gray, 30))
msiline= plot(showrealmsi() ? msiema : na, style=plot.style_line, color=color.black, linewidth=2, title="MSI")

//headcolor = showmsi() ? (isHeadWind() and isMSIDownTrend() ? color.red : na) : na
//tailcolor = showmsi() ? (isTailWind() and isMSIUpTrend()  ? limecolor : na ) : na
//fill(rsiline, headline, color=color.new(headcolor, 50))
//fill(rsiline, tailline, color=color.new(tailcolor, 50))
//bgcolor(showmsi() ? (isMSIUpTrend() ? color.new(limecolor, 80) : na  ) : na)
//bgcolor(showmsi() ? (isMSIDownTrend() ? color.new(color.red, 80): na) : na)

https://www.tradingview.com/chart/SPY/hViFFEl6-McClellan-Summation-Index/

CCI

https://www.oanda.com/bvi-ft/lab-education/technical_analysis/commodity-channel-index/
CCI包含了統計學上的平均差原則。計算上稍微複雜,但是簡單地說來,就是呈現「現值與根據一定期間平均價格的移動平均之間的乖離程度」。在計算的特徵為,使用Typical Price(TP),因此其性質能敏感反應市場的價格變動。
平均偏差一个单位时对应当天价值与均值的偏差值。

【CCI的計算式】

CCI=(TP-MA)/0.015×MD
TP=(最高價+最低價+收盤價)/3
MA=n日間的TP移動平均
MD=TP-MA的平均偏差

類似的技術指標還有「移動平均乖離率」,但此技術指標只是單純地顯示與移動平均線的乖離程度。相對地,CCI乃是根據平均差的原則,因此其圖形能反應價格震盪幅度(波動性(volatility))。

另外,基本上參數使用14。

https://www.investopedia.com/terms/c/commoditychannelindex.asp

在这里插入图片描述

KDJ

在这里插入图片描述

https://www.mitrade.com/zh/insights/others/technical-analysis/kdj-0526
在这里插入图片描述

在这里插入图片描述通过上图可以看到KDJ只表示短期市场趋势,J其实就是放大KD间的差,表示收盘与最低点之间的关系,表示股市近段时间日内强弱。

  • 25
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值