当前位置:首页>python>Python编程学动量自化:三线合一低擒主图指标

Python编程学动量自化:三线合一低擒主图指标

  • 2026-10-11 06:21:07
Python编程学动量自化:三线合一低擒主图指标

朋友们大家好今天来学习这个通达信指标算法,注意:本指标源码用于通达信。本文所述模型算法仅限学术探讨,指标公式作为知识免费分享,"基于开源数据集的理论推演",仅用于学习交流。

风险提示:本指标仅供技术研究与学习交流使用。市场具有高度不确定性,任何基于本指标的决策都需要自行承担风险,不构成任何投资建议。

01 指标图例

图一

图二

02 Py源码

下方代码仅用于学习交流使用

import pandas as pd
import talib as ta
import numpy as np

defcalculate_technical_indicators(df):
# 计算基础指标
    df['A'] = (3*df['close'] + df['low'] + df['open'] + df['high']) / 6

# 计算X(加权移动平均)
    weights = np.arange(20, 0, -1)
    total_weight = weights.sum()
for i in range(20):
        df[f'REF_A_{i+1}'] = df['A'].shift(i+1)

# 计算Y(X的5日移动平均)
    df['Y'] = df['X'].rolling(5).mean()

# 生命线(收盘价120日指数移动平均)
    df['生命线'] = ta.EMA(df['close'], timeperiod=120)

# B1-B2系列计算
    df['B1'] = df['close'].rolling(1).mean()
    df['B2'] = df['B1'].ewm(alpha=1/2, adjust=False).mean().ewm(alpha=1/2, adjust=False).mean().ewm(alpha=1/2, adjust=False).mean()
    df['SMA2'] = df['B2'].rolling(3).mean()

# 止损下限
    df['止损下限'] = np.where(df['B2'].rolling(8).mean().rolling(3).min() < df['B2'],
                         df['B2'].rolling(8).mean().rolling(3).min(),
                         df['B2'])

# 平台突破
    df['平台突破'] = df['B2'].rolling(1).mean().rolling(13).max()

# 多周期EMA
    periods = [13, 55, 133, 250]
for period in periods:
        df[f'MA{period}'] = ta.EMA(df['close'], timeperiod=period)

# GFA指标
    df['GFA'] = ta.EMA((ta.EMA(df['close'], 29) + ta.EMA(df['close'], 31) + ta.EMA(df['close'], 33)) / 3, 3)

# 千军万马信号
    df['MA5'] = ta.EMA(df['close'], 5)
    df['MA13'] = ta.EMA(df['close'], 13)
    df['MA34'] = ta.EMA(df['close'], 34)
    df['MA55'] = ta.EMA(df['close'], 55)
    df['YCX'] = df['MA5'] >= df['MA5'].shift(1)
    df['H1'] = df[['MA5', 'MA13', 'MA34']].max(axis=1)
    df['L1'] = df[['MA5', 'MA13', 'MA34']].min(axis=1)
    df['千军万马'] = (df['H1'] < df['close']) & (df['open'] < df['L1']) & df['YCX'] & (df['MA55'] > df['MA55'].shift(1))

# 跳空缺口检测
    df['上跳'] = df['low'] > df['high'].shift(1)
    df['下跳'] = df['high'] < df['low'].shift(1)

# 涨跌停检测
    df['涨停'] = df['close'] > 1.097 * df['close'].shift(1)
    df['跌停'] = df['close'] < 0.907 * df['close'].shift(1)

# 成交量突变
    df['V2V'] = (df['volume'] / df['volume'].shift(1) >= 1.9) & (df['close'] > df['close'].shift(1))

# 资金进出指标
    df['LIJIN1A'] = (2*df['close'] + df['high'] + df['low']) / 4
    df['LIJIN2A'] = df['LIJIN1A'].rolling(7).mean()

# 擒牛加仓信号
    df['A13'] = ta.EMA(df['close'], 55)
    df['A14'] = df['close'].rolling(75).mean()
    df['A15'] = ta.EMA(df['A14'], 3)
    df['A16'] = ta.EMA(df['A15'], 3)
    df['A17'] = (df['high'] + df['low']) / 5
    df['A18'] = df['A17'].rolling(4).mean() - df['A17'].rolling(34).mean()

# 低吸信号
    df['AC'] = df['amount'] / df['volume']
    df['YY'] = df['AC'].rolling(13).mean()
    df['LLL'] = (df['close'] - df['YY']) / df['YY'] * 100

# 布林带指标
    df['MIDC'] = df['close'].rolling(22).mean()
    df['UPPERC'] = df['MIDC'] + 2 * df['close'].rolling(22).std()
    df['LOWERC'] = df['MIDC'] - 2 * df['close'].rolling(22).std()
    df['BBA'] = (df['close'] - df['LOWERC']) / (df['UPPERC'] - df['LOWERC'])

# 突破成妖信号
    df['TJ'] = (df['high'].rolling(10).max() / df['low'].rolling(10).min() < 1.25) & \
              (df['close'].shift(1) < (df['low'].rolling(15).min() + 
               (df['high'].rolling(15).max() - df['low'].rolling(15).min()) * 0.85) & \
              (df['close'] > df['open']) & \
              (df['close'] >= df['high'].rolling(10).max())

# 主力散户指标
    df['LIJIN2S'] = (2*df['close'] + df['high'] + df['low']) / 4
    df['LIJIN4S'] = df['low'].rolling(5).min()
    df['LIJIN5S'] = df['high'].rolling(4).max()
    df['散户'] = ta.EMA((df['LIJIN2S'] - df['LIJIN4S']) / (df['LIJIN5S'] - df['LIJIN4S']) * 100, 4)
    df['庄家'] = ta.EMA(0.667*df['散户'].shift(1) + 0.333*df['散户'], 2)

# 龙头狙击信号
    df['买买'] = ta.EMA(100 * (df['close'] - df['low'].rolling(34).min()) / 
                   (df['high'].rolling(34).max() - df['low'].rolling(34).min()), 3)
    df['卖卖'] = ta.SMA(100 * (df['high'].rolling(34).max() - df['close']) / 
                   (df['high'].rolling(34).max() - df['low'].rolling(34).min()), 2)

return df

顺势而为 长期坚持

学习分享

学术交流:我们专注于市场的学术交流与研究
分享知识:田都元帅,敬神常在,爱人如己,我为人人,与人为善,分享快乐!

最新文章

随机文章