通达信完整交易策略分享 右侧波段持仓策略
KS:=BARSCOUNT(C)+1;
STBZ:=IF(NAMEINCLUDE('ST'),0,1);
GPDM:=STR2CON(CODE);
GPJD:=REF(C,1);
ZGB:=FINANCE(1);
ZSZ:=INTPART(GPJD*ZGB/10000/10000);
SCXZA:=IF(GPDM>=1 AND GPDM<2000,1,IF(GPDM>=2000 AND GPDM<300000,2,
IF(GPDM>=300000 AND GPDM<600000,3,IF(GPDM>=600000 AND GPDM<688000,4,
IF(GPDM>=688000 AND GPDM<690000,5,0)))));
{个股所属市场表示,1-深圳主板,2-深圳中小板,3-深圳创业板,4-上海主板,
5-上海科创板,6-全市场所有股票}
JA1A:=IF(板块选择=6,1,IF(板块选择=SCXZA,1,0));
JA1B:=IF(GPJD<=股价上限 AND GPJD>=股价下限,1,0);
JA1C:=IF(ZSZ<=市值上限 AND ZSZ>=市值下限,1,0);
JA1D:=IF((JA1A+JA1B+JA1C+STBZ)=4,1,0);
JX1:=INTPART(MA(C,基准值)*100)/100;
JX2:=INTPART(MA(C,基准值*2)*100)/100;
JX3:=INTPART(MA(C,基准值*4)*100)/100;
JA2A:=IF(JX1<JX2 AND JX2<JX3,1,0);
JA2B:=IF(REF(JA2A,1)=1 AND JA2A=0,1,0);
JA3A:=IF(JX1>JX2 AND JX2>JX3,1,0);
JA3B:=IF(REF(JA3A,1)=0 AND JA3A=1,1,0);
CSH:=IF(COUNT(JA2B=1,KS)>=2 AND COUNT(JA3B=1,KS)>=2,1,0);
JB1A:=IF(CSH=1,
IF(COUNT(JX1<JX2,SUMBARS(JA3B,1))=0 AND COUNT(JX2<JX3,SUMBARS(JA3B,1))=0,1,0),0);
JB1B:=IF(CSH=1,IF(JA3A=1 OR JB1A=1,1,0),0);
JB1C:=IF(REF(JB1B,1)=0 AND JB1B=1,1,0);
JB2A:=IF(JX1>JX2,1,0);
JB2B:=IF(COUNT(JX1<JX2,SUMBARS(JB2A,1))=0,1,0);
JB2C:=IF(REF(JB2B,1)=1 AND JB2B=0,1,0);
JB2D:=IF(JB2C=1,LLV(L,3),0);
JB2E:=IF(COUNT(JB2C=1,KS)>=1,IF(COUNT(C<REF(JB2D,SUMBARS(JB2C,1)-1),SUMBARS(JB2C,1))=0
AND COUNT(JB2B=1,SUMBARS(JB2C,1))=0,1,0),0);
JB2F:=IF(JB2B=1 OR JB2E=1,1,0);
JC1A:=IF(JB1B=1,IF(SUMBARS(JB1C,1)<=基准值 AND SUMBARS(JA2B,1)<=2*基准值
AND COUNT(JA1D=1,SUMBARS(JB1C,1))>=1,1,0),0);
JC1B:=IF(REF(JC1A,1)=1,1,0);
JC1C:=IF(REF(JC1B,1)=0 AND JC1B=1,1,0);
JC2A:=IF(JC1A=1,JX2,0);
JC3A:=IF(JC1B=1,IF(L<=REF(JC2A,1),1,0),0);
JC3B:=IF(JC1B=1,IF(JC3A=1,IF(O<REF(JC2A,1),O,REF(JC2A,1)),0),0);
JC3C:=IF(JC1B=1,IF(JC3A=1,IF(COUNT(JC3A=1,SUMBARS(JC1C,1))=1,1,0),0),0);
JC4A:=IF(COUNT(JC3C=1,KS)>=1,IF(COUNT(JB2F=0,SUMBARS(JC3C,1))=0,1,0),0);
JC4B:=IF(JC4A=1 OR (JC4A=0 AND REF(JC4A,1)=1),1,0);
TRE:=投入金额*10000;
JD1A:=IF(CSH=1,IF(REF(JC4B,1)=0 AND JC4B=1 AND JC3C=1,1,0),0);
JD1B:=IF(COUNT(JD1A=1,KS)>=1,IF(JC4B=1,IF(COUNT(JC4B=0,SUMBARS(JD1A,1))=0,1,0),0),0);
JD2A:=IF(JD1A=1,JC3B,0);
JD2B:=IF(JD1A=1,INTPART(TRE/JD2A/100)*100,0);
JD2C:=IF(JD1A=1,JD2A*JD2B,0);
JD2D:=IF(JD1B=1,REF(JD2A,SUMBARS(JD1A,1)-1),0);
JD2E:=IF(JD1B=1,REF(JD2B,SUMBARS(JD1A,1)-1),0);
JD2F:=IF(JD1B=1,REF(JD2C,SUMBARS(JD1A,1)-1),0);
JD2G:=IF(JD1B=1,(C-JD2D)*JD2E,
IF(REF(JD1B,1)=1 AND JD1B=0,(O-REF(JD2D,1))*REF(JD2E,1),0));
JD2H:=IF(JD1B=1,JD2G/JD2F*100,IF(REF(JD1B,1)=1 AND JD1B=0,JD2G/REF(JD2F,1)*100,0));
买价格:JD2A;
买数量:JD2B;
买金额:JD2C;
持成本:JD2D;
持数量:JD2E;
持投入额:JD2F;
持盈亏:JD2G;
持盈亏率%:JD2H;
卖价:IF(REF(JD1B,1)=1 AND JD1B=0,O,0);
DRAWICON(JD1A,JD2C,1);
DRAWICON(REF(JD1B,1)=1 AND JD1B=0,IF(JD2G>REF(JD2F,1),JD2G,REF(JD2F,1)),2);
未来函数检测结果如下:
该公式包含未来函数:FINANCE
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
KS赋值:C的有效数据周期数+1
STBZ赋值:IF(NAMEINCLUDE('ST'),0,1)
GPDM赋值:STR2CON(CODE)
GPJD赋值:1日前的C
ZGB赋值:FINANCE(1)
ZSZ赋值:INTPART(GPJD*ZGB/10000/10000)
SCXZA赋值:IF(GPDM>=1 AND GPDM<2000,1,IF(GPDM>=2000 AND GPDM<300000,2, IF(GPDM>=300000 AND GPDM<600000,3,IF(GPDM>=600000 AND GPDM<688000,4, IF(GPDM>=688000 AND GPDM<690000,5,0)))))
{个股所属市场表示,1-深圳主板,2-深圳中小板,3-深圳创业板,4-上海主板,5-上海科创板,6-全市场所有股票}JA1A赋值:IF(板块选择=6,1,IF(板块选择=SCXZA,1,0))
如果GPJD<=股价上限 AND GPJD>=股价下限返回1否则返回0
如果ZSZ<=市值上限 AND ZSZ>=市值下限返回1否则返回0
JA1D赋值:IF((JA1A+JA1B+JA1C+STBZ)=4,1,0)
JX1赋值:INTPART(C的基准值日简单移动平均*100)/100
JX2赋值:INTPART(C的基准值*2日简单移动平均*100)/100
JX3赋值:INTPART(C的基准值*4日简单移动平均*100)/100
如果JX1JA2B赋值:IF(1日前的JA2A=1 AND JA2A=0,1,0)
如果JX1>JX2 AND JX2>JX3返回1否则返回0
JA3B赋值:IF(1日前的JA3A=0 AND JA3A=1,1,0)
CSH赋值:IF(统计KS日满足JA2B=1的天数>=2 AND 统计KS日满足JA3B=1的天数>=2,1,0)
JB1A赋值:IF(CSH=1, IF(统计JA3B累加至1的天数日满足JX1JB1B赋值:IF(CSH=1,IF(JA3A=1 OR JB1A=1,1,0),0)
JB1C赋值:IF(1日前的JB1B=0 AND JB1B=1,1,0)
如果JX1>JX2返回1否则返回0
JB2B赋值:IF(统计JB2A累加至1的天数日满足JX1JB2C赋值:IF(1日前的JB2B=1 AND JB2B=0,1,0)
JB2D赋值:IF(JB2C=1,3日内L最低值,0)
JB2E赋值:IF(统计KS日满足JB2C=1的天数>=1,IF(COUNT(C如果JB2B=1 OR JB2E=1返回1否则返回0
JC1A赋值:IF(JB1B=1,IF(JB1C累加至1的天数<=基准值 AND JA2B累加至1的天数<=2*基准值 AND 统计JB1C累加至1的天数日满足JA1D=1的天数>=1,1,0),0)
JC1B赋值:IF(1日前的JC1A=1,1,0)
JC1C赋值:IF(1日前的JC1B=0 AND JC1B=1,1,0)
如果JC1A=1返回JX2否则返回0
JC3A赋值:IF(JC1B=1,IF(L<=1日前的JC2A,1,0),0)
JC3B赋值:IF(JC1B=1,IF(JC3A=1,IF(O<1日前的JC2A,O,1日前的JC2A),0),0)
JC3C赋值:IF(JC1B=1,IF(JC3A=1,IF(统计JC1C累加至1的天数日满足JC3A=1的天数=1,1,0),0),0)
JC4A赋值:IF(统计KS日满足JC3C=1的天数>=1,IF(统计JC3C累加至1的天数日满足JB2F=0的天数=0,1,0),0)
JC4B赋值:IF(JC4A=1 OR (JC4A=0 AND 1日前的JC4A=1),1,0)
TRE赋值:投入金额*10000
JD1A赋值:IF(CSH=1,IF(1日前的JC4B=0 AND JC4B=1 AND JC3C=1,1,0),0)
JD1B赋值:IF(统计KS日满足JD1A=1的天数>=1,IF(JC4B=1,IF(统计JD1A累加至1的天数日满足JC4B=0的天数=0,1,0),0),0)
如果JD1A=1返回JC3B否则返回0
JD2B赋值:IF(JD1A=1,INTPART(TRE/JD2A/100)*100,0)
如果JD1A=1返回JD2A*JD2B否则返回0
JD2D赋值:IF(JD1B=1,JD1A累加至1的天数-1日前的JD2A,0)
JD2E赋值:IF(JD1B=1,JD1A累加至1的天数-1日前的JD2B,0)
JD2F赋值:IF(JD1B=1,JD1A累加至1的天数-1日前的JD2C,0)
JD2G赋值:IF(JD1B=1,(C-JD2D)*JD2E, IF(1日前的JD1B=1 AND JD1B=0,(O-1日前的JD2D)*1日前的JD2E,0))
JD2H赋值:IF(JD1B=1,JD2G/JD2F*100,IF(1日前的JD1B=1 AND JD1B=0,JD2G/1日前的JD2F*100,0))
输出买价格:JD2A
输出买数量:JD2B
输出买金额:JD2C
输出持成本:JD2D
输出持数量:JD2E
输出持投入额:JD2F
输出持盈亏:JD2G
持盈亏率%:JD2H
输出卖价:IF(1日前的JD1B=1 AND JD1B=0,O,0)
当满足条件JD1A时,在JD2C和1之间画图标
DRAWICON(1日前的JD1B=1 AND JD1B=0,IF(JD2G>1日前的JD2F,JD2G,1日前的JD2F),2)