均线sma-均线sma和ma有何区别

2023-04-19 技术指标 0次阅读 admin
均线sma.jpg

关于均线sma的问题,我们总结了以下几点,给你解答:

均线SMA是什么意思


均线SMA是什么意思

1.EMA比MA多一个E.
2.权重不同
3.一个波动大,一个平滑和稳定.
各有长短. 看你需要

纯均线好。


均线sma


均线sma


def sma(self, data, n, array=False):
result = talib.SMA(data, timeperiod=n)
if array:
return result
return result[-1]

# 计算EMA指数移动平均线
def ema(self, data, n, array=False):
result = talib.EMA(data, timeperiod=n)
if array:
return result
return result[-1]

# 计算MACD
def macd(self, data, fastperiod=12, slowperiod=26, signalperiod=9):
macd, signal, hist = talib.MACD(data, fastperiod=fastperiod, slowperiod=slowperiod, signalperiod=signalperiod)
return macd[-1], signal[-1], hist[-1]

# 计算KDJ
def kdj(self, data, fastk_period=9, slowk_period=3, slowd_period=3):
slowk, slowd = talib.STOCH(data, fastk_period=fastk_period, slowk_period=slowk_period, slowd_period=slowd_period)
return slowk[-1], slowd[-1]

# 计算RSI
def rsi(self, data, n):
result = talib.RSI(data, timeperiod=n)
return result[-1]

# 计算ATR
def atr(self, data, n):
result = talib.ATR(data, timeperiod=n)
return result[-1]

# 计算BBANDS
def bbands(self, data, n):
upperband, middleband, lowerband = talib.BBANDS(data, timeperiod=n)
return upperband[-1], middleband[-1], lowerband[-1]

# 计算均线突破
def ma_break(self, data, n):
ma = self.sma(data, n, array=True)
if data[-1] > ma[-1] and data[-2] < ma[-2]:
return 1
elif data[-1] < ma[-1] and data[-2] > ma[-2]:
return -1
else:
return 0

# 计算EMA突破
def ema_break(self, data, n):
ema = self.ema(data, n, array=True)
if data[-1] > ema[-1] and data[-2] < ema[-2]:
return 1
elif data[-1] < ema[-1] and data[-2] > ema[-2]:
return -1
else:
return 0

# 计算MACD突破
def macd_break(self, data):
macd, signal, hist = self.macd(data)
if hist[-1] > 0 and hist[-2] < 0:
return 1
elif hist[-1] < 0 and hist[-2] > 0:
return -1
else:
return 0

# 计算KDJ突破
def kdj_break(self, data):
slowk, slowd = self.kdj(data)
if slowk[-1] > slowd[-1] and slowk[-2] < slowd[-2]:
return 1
elif slowk[-1] < slowd[-1] and slowk[-2] > slowd[-2]:
return -1
else:
return 0

# 计算RSI突破
def rsi_break(self, data, n):
rsi = self.rsi(data, n)
if rsi[-1] > 50 and rsi[-2] < 50:
return 1
elif rsi[-1] < 50 and rsi[-2] > 50:
return -1
else:
return 0

# 计算BBANDS突破
def bbands_break(self, data, n):
upperband, middleband, lowerband = self.bbands(data, n)
if data[-1] > upperband and data[-2] < upperband:
return 1
elif data[-1] < lowerband and data[-2] > lowerband:
return -1
else:
return 0

# 计算布林带突破
def boll_break(self, data, n):
upperband, middleband, lowerband = self.bbands(data, n)
if data[-1] > upperband and data[-2] < upperband:
return 1
elif data[-1] < lowerband and data[-2] > lowerband:
return -1
else:
return 0

# 计算均线反转
def ma_rev(self, data, n):
ma = self.sma(data, n, array=True)
if data[-1] > ma[-1] and data[-2] > ma[-2]:
return 1
elif data[-1] < ma[-1] and data[-2] < ma[-2]:
return -1
else:
return 0

# 计算EMA反转
def ema_rev(self, data, n):
ema = self.ema(data, n, array=True)
if data[-1] > ema[-1] and data[-2] > ema[-2]:
return 1
elif data[-1] < ema[-1] and data[-2] < ema[-2]:
return -1
else:
return 0

# 计算MACD反转
def macd_rev(self, data):
macd, signal, hist = self.macd(data)
if hist[-1] > 0 and hist[-2] > 0:
return 1
elif hist[-1] < 0 and hist[-2] < 0:
return -1
else:
return 0

# 计算KDJ反转
def kdj_rev(self, data):
slowk, slowd = self.kdj(data)
if slowk[-1] > slowd[-1] and slowk[-2] > slowd[-2]:
return 1
elif slowk[-1] < slowd[-1] and slowk[-2] < slowd[-2]:
return -1
else:
return 0

# 计算RSI反转
def rsi_rev(self, data, n):
rsi = self.rsi(data, n)
if rsi[-1] > 50 and rsi[-2] > 50:
return 1
elif rsi[-1] < 50 and rsi[-2] < 50:
return -1
else:
return 0

# 计算BBANDS反转
def bbands_rev(self, data, n):
upperband, middleband, lowerband = self.bbands(data, n)
if data[-1] > middleband and data[-2] > middleband:
return 1
elif data[-1] < middleband and data[-2] < middleband:
return -1
else:
return 0

# 计算布林带反转
def boll_rev(self, data, n):
upperband, middleband, lowerband = self.bbands(data, n)
if data[-1] > middleband and data[-2] > middleband:
return 1
elif data[

均线sma和ma有何区别


均线sma和ma有何区别

M频班鸡益止代困A,是简单移动平均线。 经常使用的都是这个。
EMA,指数移动平均线。相对上面的线来说,平滑一些,同时也延迟了。
SMA,是[N日权重]移动平均线。编写公式时,极少用护剧众到。
根据思路编写公式,修改公式。盘中预警,条件选股。公式解密,去除时间限制。
帝念型呼短围草超胜过如需要,点我图像私信谈。
点点采纳就好。

猜你感兴趣: 均线sma