优化一线宝塔线指标 公式 源码[同花顺公式]
指标代码分析及参考建议使用:
这段代码是一个股票交易的分析指标,主要包含了一些条件判断和绘制图形的操作。
首先定义了两个变量B1和B2,分别表示昨天和前天的收盘价。
然后定义了一个变量SS,通过比较当天收盘价与昨天和前天的收盘价的大小关系,来确定股票的趋势方向。1表示上涨,-1表示下跌,2表示股票连续上涨,-2表示股票连续下跌,0表示无明显趋势。
接下来定义了变量SM,用于记录最近连续的趋势方向,当前的趋势方向如果不为0,则直接使用当前的趋势方向;否则,向前逐个判断之前的趋势方向,直到找到一个不为0的趋势方向为止。
变量mc根据趋势方向SS和SM的值来确定需要标记的价格。具体标记方式按照如下规则:如果昨天的趋势方向不为0,则标记前天的收盘价B2;否则,如果SM的值大于0,则标记昨天和前天收盘价中较小的值;否则,标记昨天和前天收盘价中较大的值。并将标记的线条颜色设置为紫色(COLORff00ff)。
接下来的代码部分主要用于判断股票的买入信号和卖出信号,并绘制相应的图形。
变量CXH1到CXH18分别表示了不同的买入信号和卖出信号的条件,具体的判断规则请参考代码注释。通过这些条件的判断,最后得到了两个变量CXH100和CXH200,分别表示买入信号和卖出信号的发生情况。
使用STICKLINE函数将买入信号和卖出信号标记在图上,买入信号用红色标记,卖出信号用绿色标记。
根据这段代码的逻辑,可以通过监控股票的趋势方向和买入/卖出信号,制定相应的操作策略。对于买入信号,可以考虑适时买入股票;对于卖出信号,则可以考虑适时卖出股票。当然,具体的操作策略还需要根据市场行情和个人风险偏好进行综合考量,建议在实际操作中结合其他指标和自身的交易策略进行决策。
源码:
B1:=REF(C,1);B2:=REF(C,2);
SS:=IF(C>REF(C,1) AND REF(C,1)>=REF(C,2),1,IF(C<REF(C,1) AND REF(C,1)<=REF(C,2),-1,IF(C>REF(C,2) AND REF(C,2)>REF(C,1),2,IF(C<REF(C,2) AND REF(C,2)<REF(C,1),-2,0))));
SM:=IF(REF(SS,1)<>0,REF(SS,1),IF(REF(SS,2)<>0,REF(SS,2),IF(REF(SS,3)<>0,REF(SS,3),IF(REF(SS,5)<>0,REF(SS,5),IF(REF(SS,6)<>0,REF(SS,6),IF(REF(SS,7)<>0,REF(SS,7),0))))));
mc:IF(REF(SS,1)<>0,B2,IF(SM>0,MIN(B1,B2),MAX(B1,B2))),COLORff00ff;
CXH1:=CLOSE>REF(CLOSE,1) AND CLOSE>REF(CLOSE,2);{cxh99.com}
CXH2:=REF(CXH1,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH3:=REF(CXH2,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH4:=REF(CXH3,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH5:=REF(CXH4,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH6:=REF(CXH5,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH7:=REF(CXH6,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH8:=REF(CXH7,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH9:=REF(CXH8,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXHA:=REF(CXH9,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXHB:=REF(CXHA,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXHC:=REF(CXHB,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXHD:=CLOSE<REF(CLOSE,1) AND CLOSE<REF(CLOSE,2);
CXHE:=REF(CXHD,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXHF:=REF(CXHE,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH10:=REF(CXHF,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH11:=REF(CXH10,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH12:=REF(CXH11,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH13:=REF(CXH12,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH14:=REF(CXH13,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH15:=REF(CXH14,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH16:=REF(CXH15,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH17:=REF(CXH16,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH18:=REF(CXH17,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH100:=CXH1 OR CXH2 OR CXH3 OR CXH4 OR CXH5 OR CXH6 OR CXH7 OR CXH8
OR CXH9 OR CXHA OR CXHB OR CXHC;
STICKLINE(CXH100,CLOSE,REF(CLOSE,1),8,1),colorred;
CXH200:=CXHD OR CXHE OR CXHF OR CXH10 OR CXH11 OR CXH12 OR CXH13 OR
CXH14 OR CXH15 OR CXH16 OR CXH17 OR CXH18;
STICKLINE(CXH200,CLOSE,REF(CLOSE,1),8,0),COLORGREEN;//http://www.cxh99.com
CXH200:=REF(CXHD OR CXHE OR CXHF OR CXH10 OR CXH11 OR CXH12 OR CXH13
OR CXH14 OR CXH15 OR CXH16 OR CXH17 OR CXH18,1) AND CXH1;
STICKLINE(CXH200,REF(CLOSE,1),REF(CLOSE,2),8,0),COLORGREEN;//http://www.cxh99.com
CXH400:=REF(CXH1 OR CXH2 OR CXH3 OR CXH4 OR CXH5 OR CXH6 OR CXH7 OR
CXH8 OR CXH9 OR CXHA OR CXHB OR CXHC,1) AND CXHD;
STICKLINE(CXH400,REF(CLOSE,1),REF(CLOSE,2),8,1),colorred;
主图可以把均线指标参数修改这个
B1:=REF(C,1);B2:=REF(C,2);
SS:=IF(C>REF(C,1) AND REF(C,1)>=REF(C,2),1,IF(C<REF(C,1) AND REF(C,1)<=REF(C,2),-1,IF(C>REF(C,2) AND REF(C,2)>REF(C,1),2,IF(C<REF(C,2) AND REF(C,2)<REF(C,1),-2,0))));
SM:=IF(REF(SS,1)<>0,REF(SS,1),IF(REF(SS,2)<>0,REF(SS,2),IF(REF(SS,3)<>0,REF(SS,3),IF(REF(SS,5)<>0,REF(SS,5),IF(REF(SS,6)<>0,REF(SS,6),IF(REF(SS,7)<>0,REF(SS,7),0))))));
mc:IF(REF(SS,1)<>0,B2,IF(SM>0,MIN(B1,B2),MAX(B1,B2))),COLORff00ff;
可以和上面均线合并使用 同花顺电脑版
CXH1:=CLOSE>REF(CLOSE,1) AND CLOSE>REF(CLOSE,2);
CXH2:=REF(CXH1,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH3:=REF(CXH2,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH4:=REF(CXH3,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH5:=REF(CXH4,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH6:=REF(CXH5,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH7:=REF(CXH6,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH8:=REF(CXH7,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH9:=REF(CXH8,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXHA:=REF(CXH9,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXHB:=REF(CXHA,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXHC:=REF(CXHB,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
STICKLINE(CXH1 OR CXH2 OR CXH3 OR CXH4 OR CXH5 OR CXH6 OR CXH7 OR CXH8 OR CXH9 OR CXHA OR CXHB OR CXHC,CLOSE,REF(CLOSE,1),9,1),colorred;
CXHD:=CLOSE<REF(CLOSE,1) AND CLOSE<REF(CLOSE,2);
CXHE:=REF(CXHD,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXHF:=REF(CXHE,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH10:=REF(CXHF,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH11:=REF(CXH10,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH12:=REF(CXH11,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH13:=REF(CXH12,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH14:=REF(CXH13,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH15:=REF(CXH14,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH16:=REF(CXH15,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
CXH17:=REF(CXH16,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
CXH18:=REF(CXH17,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
STICKLINE(CXHD OR CXHE OR CXHF OR CXH10 OR CXH11 OR CXH12 OR CXH13 OR CXH14 OR CXH15 OR CXH16 OR CXH17 OR CXH18,CLOSE,REF(CLOSE,1),9,0),COLORGREEN;//http://www.cxh99.com
CXH19:=REF(CXHD OR CXHE OR CXHF OR CXH10 OR CXH11 OR CXH12 OR CXH13 OR CXH14 OR CXH15 OR CXH16 OR CXH17 OR CXH18,1) AND CXH1;
STICKLINE(CXH19,REF(CLOSE,1),REF(CLOSE,2),9,0) , COLORGREEN;//http://www.cxh99.com
CXH1A:=REF(CXH1 OR CXH2 OR CXH3 OR CXH4 OR CXH5 OR CXH6 OR CXH7 OR CXH8 OR CXH9 OR CXHA OR CXHB OR CXHC,1) AND CXHD;
STICKLINE(CXH1A,REF(CLOSE,1),REF(CLOSE,2),9,1),colorred;
//程序化交易 www.cxh99.com
//程序化交易 www.cxh99.com
公式导入教程: 【通达信公式源码导入方法教程】 【同花顺公式源码导入方法教程】 【大智慧新一代公式源码导入方法教程】
有思路,想编写各种指标公式,交易模型,选股公式,还原公式的朋友
可联系技术人员 QQ: 262069696 或微信:cxhjy888 进行 有偿收费 编写!(注:由于人数限制,QQ或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)
(注:由于人数限制,QQ或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)
相关文章
-
没有相关内容