通达信策略5持仓副图指标 源码 贴图
2023-04-20 11:10:00来源:本站整理浏览:714
通达信策略5持仓副图指标 源码 贴图
基准值:=5;
投入金额:=15;
KS:=BARSCOUNT(C)+1;
NF:= YEAR;
NFB:= MOD(NF,2);
HD:=IF(REF(NF,1)<>NF,1,0);{IF(REF(NFB,1)>0 AND NFB=0,1,0);}
KS1:=IF(COUNT(HD=1,KS)=0,KS,SUMBARS(HD,1));
{注意KS与KS1的区别,股票用年画段,期货用月画段}
K2A:= IF(MOD(KS1,2)=1 OR KS1=1,1,0);
K2H:= HHV(H,SUMBARS(K2A,1));
K2L:= LLV(L,SUMBARS(K2A,1));
K2RSV:= (C-LLV(L,SUMBARS(K2A,9)))/(HHV(H,SUMBARS(K2A,9))-LLV(L,SUMBARS(K2A,9)))*100;
K2FK:=(REF(K2RSV,SUMBARS(K2A,1))+2*REF(K2RSV,SUMBARS(K2A,2)))/3;
K2K:=(K2RSV+2*K2FK)/3;
K2FD:=(REF(K2K,SUMBARS(K2A,1))+2*REF(K2K,SUMBARS(K2A,2)))/3;
K2D:=(K2K+2*K2FD)/3;
K2KD:= INTPART(100*(K2K+K2D*2)/3)/100;
K2KDQ:= REF(K2KD,SUMBARS(K2A,1));
K4A:= IF(MOD(KS1,4)=1 OR KS1=1,1,0);
K4H:= HHV(H,SUMBARS(K4A,1));
K4L:= LLV(L,SUMBARS(K4A,1));
K4RSV:= (C-LLV(L,SUMBARS(K4A,9)))/(HHV(H,SUMBARS(K4A,9))-LLV(L,SUMBARS(K4A,9)))*100;
K4FK:=(REF(K4RSV,SUMBARS(K4A,1))+2*REF(K4RSV,SUMBARS(K4A,2)))/3;
K4K:=(K4RSV+2*K4FK)/3;
K4FD:=(REF(K4K,SUMBARS(K4A,1))+2*REF(K4K,SUMBARS(K4A,2)))/3;
K4D:=(K4K+2*K4FD)/3;
K4KD:= INTPART(100*(K4K+K4D*2)/3)/100;
K4KDQ:= REF(K4KD,SUMBARS(K4A,1));
K8A:= IF(MOD(KS1,8)=1 OR KS1=1,1,0);
K8H:= HHV(H,SUMBARS(K8A,1));
K8L:= LLV(L,SUMBARS(K8A,1));
K8RSV:= (C-LLV(L,SUMBARS(K8A,9)))/(HHV(H,SUMBARS(K8A,9))-LLV(L,SUMBARS(K8A,9)))*100;
K8FK:=(REF(K8RSV,SUMBARS(K8A,1))+2*REF(K8RSV,SUMBARS(K8A,2)))/3;
K8K:=(K8RSV+2*K8FK)/3;
K8FD:=(REF(K8K,SUMBARS(K8A,1))+2*REF(K8K,SUMBARS(K8A,2)))/3;
K8D:=(K8K+2*K8FD)/3;
K8KD:= INTPART(100*(K8K+K8D*2)/3)/100;
K8KDQ:= REF(K8KD,SUMBARS(K8A,1));
JQ1A:=IF(K2KDQ<=20,1,0);{开盘确认}
JQ1B:=IF(K4KDQ<=20,1,0);{开盘确认}
JQ1C:=IF(K8KDQ<=20,1,0);{开盘确认}
JQ1D:=IF((JQ1A+JQ1B+JQ1C)>=2,1,0);{开盘确认-建仓区域框架};
{以上为笔者个人经验认为高胜率建仓区域}
{策略计算基准模块}{公式网WWW.GPXIAZAI.COM}
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);
JX1A:=EMA(C,基准值);
JX2A:=EMA(C,基准值*2);
JX3A:=EMA(C,基准值*4);
JX4A:=IF(FRACPART(基准值/2)>=0.5,INTPART(基准值/2)+1,INTPART(基准值/2));
YA:=INTPART((JX1A-JX2A)*1000);
LA:=INTPART(EMA(YA,JX4A));
YB:=INTPART((JX1A-JX3A)*1000);
LB:=INTPART(EMA(YB,JX4A));
{左侧主体-核心:建仓监控-买入-持仓-卖出}
JG1A:=IF(YA>LA,1,0);
JG1B:=IF(COUNT(YA<LA,SUMBARS(JG1A,1))=0,1,0);
JG1C:=IF(REF(JG1B,1)=0 AND JG1B=1,1,0);
JG1D:=IF(REF(JG1B,1)=1 AND JG1B=0,1,0);
JG2A:=IF(YB>LB,1,0);
JG2B:=IF(COUNT(YB<LB,SUMBARS(JG1A,1))=0,1,0);
JG2C:=IF(REF(JG2B,1)=0 AND JG2B=1,1,0);
JG2D:=IF(REF(JG2B,1)=1 AND JG2B=0,1,0);
CSH:=IF((COUNT(JG2C=1,KS)+COUNT(JG2D=1,KS))>=3 AND COUNT(JA2B=1,KS)>=2 AND COUNT(JA3B=1,KS)>=2,1,0);
JG3A:=IF(CSH=1,IF(JG1B=1 AND JG2B=1 AND LA<=0 AND LB<=0,1,0),0);{实盘监控区}
JG3B:=IF(CSH=1,IF(REF(JG3A,1)=0 AND JG3A=1,1,0),0);{实盘监控区-起点}
JG3C:=IF(CSH=1,IF(REF(JG3A,1)=1,1,0),0);{实盘挂单区}
JG3D:=IF(CSH=1,IF(REF(JG3C,1)=0 AND JG3C=1,1,0),0);{实盘挂单区起点}
JG4A:=MIN(O,C);{预计止损价}
JG4B:=IF(JG3A=1,LLV(H,SUMBARS(JG3B,1)+基准值-1),0);{预计建仓价}
JG5A:=IF(JG3C=1,IF(L<=REF(JG4B,1),1,0),0);{挂单成交信号}
JG5B:=IF(JG3C=1,IF(COUNT(JG5A=1,SUMBARS(JG3D,1))>=1,1,0),0);{实盘挂单区有持仓信号-包含卖出/止损信号};
JG6A:=IF(YA>0 OR YB>0,1,0);
JG6B:=IF(REF(JG6A,1)=1 AND JG6A=0,1,0);
JG6C:=IF(JG6B=1,LLV(JG4A,基准值),0);
JG6D:=IF(COUNT(C<REF(JG6C,SUMBARS(JG6B,1)-1),SUMBARS(JG6B,1))=0 AND COUNT(JG6A=1,SUMBARS(JG6B,1))=0,1,0);
JG6E:=IF(JG6A=1 OR JG6D=1,1,0);
JG6F:=IF(REF(JG6E,1)=0 AND JG6E=1,1,0);
JG6G:=IF(COUNT(JG6F=1,KS)>=1,IF(COUNT(JG6E=0,SUMBARS(JG6F,1))=0,1,0),0);
JG6H:=IF(REF(JG6G,1)=0 AND JG6G=1,1,0);
JG6I:=IF(JG6G=1,IF(COUNT(JG5B=1,SUMBARS(JG6H,1))>=1,1,0),0);{从左侧买入顺利过渡到右侧趋势持仓区};
JG7A:=IF(JG5B=1 OR JG6I=1 OR (REF(JG6I,1)=1 AND JG6I=0),1,0);{整体实盘持仓区}
JG7B:=IF(REF(JG7A,1)=0 AND JG7A=1 AND JG5A=1,1,0);{实盘唯一成交信号};
JG7C:=IF(JG7B=1,IF(O<=REF(JG4B,1),O,REF(JG4B,1)),0);{实盘成交价};
JG7D:=IF(COUNT(JG7B=1,KS)>=1,IF(COUNT(JG7A=0,SUMBARS(JG7B,1))=0,1,0),0);
JG7E:=IF(REF(JG7D,1)=1 AND JG7D=0,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*基准值,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 (REF(JC4A,1)=1 AND JC4A=0),1,0);
JC4C:=IF(REF(JC4B,1)=1 AND JC4B=0,1,0);{右侧持仓卖出-开盘卖出}
{右侧趋势与左侧抄底融合模块}
JM1A:=IF(JC4B=1,2,IF(JG7D,1,0));{左侧+右侧融合持仓区域持仓等级};
JM1B:=IF(REF(JM1A,1)=0 AND JM1A>=1,1,0);{融合持仓区起点}
JM1C:=IF(COUNT(JM1B=1,KS)>=1,IF(COUNT(JM1A=0,SUMBARS(JM1B,1))=0,1,0),0);
JM2A:=IF(JM1B=1,IF(JG7B=1 AND JQ1D=1,1,0),0);{重要注释:融合持仓-初次买入点--注意只要在这行代码增减“ AND JQ1D=1”即可实现策略4和策略5的无缝切换};
JM2B:=IF(COUNT(JM2A=1,KS)>=1,IF(COUNT(JM1C=0,SUMBARS(JM2A,1))=0,1,0),0);
TRE:=投入金额*10000;{个股预计投入资金}
TRE1:=INTPART(TRE/3*100)/100;{单次投入三层仓位};
JP1A:=IF(JM2A=1,JG7C,0);{三层底仓成交价}
JP1B:=IF(JM2A=1,INTPART(TRE1/JP1A/100)*100,0);{三层底仓成交数量}
JP1C:=IF(JM2A=1,JP1A*JP1B,0);{三层底仓实际占用资金}
JP1D:=IF(JM2A=1,IF((JP1C*2.5/10000)<5,5,JP1C*2.5/10000)+JP1C/100000,0);
JP2A:=IF(JM2B=1,IF(JC3C=1,IF(COUNT(JC3C,SUMBARS(JM2A,1))=1,1,0),0),0);
JP2B:=IF(JP2A=1,JC3B,0);{初次右侧趋势加仓成交价}
JP2C:=IF(JP2A=1,INTPART((TRE-REF(JP1C,SUMBARS(JM2A,1)-1))/JP2B/100)*100,0);
JP2D:=IF(JP2A=1,JP2B*JP2C,0);{初次右侧趋势加仓成交金额}
JP2E:=IF(JP2A=1,IF((JP2D*2.5/10000)<5,5,JP2D*2.5/10000)+JP2D/100000,0);
JP3A:=IF(JM2B=1,IF((JG7E=1 AND COUNT(JM2B=0,SUMBARS(JG7B,1))=0) OR (JC4C=1 AND COUNT(JM2B=0,SUMBARS(JC3C,1))=0),1,0),0);{融合持仓区-有卖出减仓};
JP3B:=IF(JM2B=1,IF(JP3A=1,IF(COUNT(JP3A=1,SUMBARS(JM2A,1))=1,1,0),0),0);
JP3C:=IF(JM2B=1,IF(JP3B=1,O,0),0);{融合持仓区-首次减仓卖出成交价}
JP3D:=IF(JM2B=1,IF(JP3B=1,REF(JP1B,SUMBARS(JM2A,1)-1),0),0);{融合持仓区-首次减仓卖出成交数量-卖出底仓成交数量}
JP3E:=IF(JM2B=1,IF(JP3B=1,JP3C*JP3D,0),0);{融合持仓区-首次减仓卖出成交金额}
JP3F:=IF(JM2B=1,IF(JP3B=1,IF((JP3E*2.5/10000)<5,5,JP3E*2.5/10000)+JP3E/1000+JP3E/100000,0),0);{卖出成交成本};
JP4A:=IF(JM2B=1,IF(JG7B=1 OR JC3C=1,1,0),0);{融合区-通用买入信号};
JP4B:=IF(JM2B=1,IF(JP4A=1,IF(COUNT(JP2A=1,SUMBARS(JM2A,1))>=1,IF(SUMBARS(JP2A,1)>1 AND COUNT(JP3B=1,SUMBARS(JP2A,1))>=1,1,0),0),0),0);
JP4C:=IF(JM2B=1,IF(JP4B=1,MAX(JG7C,JC3B),0),0);{循环买入-成交价}
JP4D:=IF(JM2B=1,IF(JP4B=1,INTPART(TRE1/JP4C/100)*100,0),0);{循环买入-成交数量}
JP4E:=IF(JM2B=1,IF(JP4B=1,JP4C*JP4D,0),0);{循环买入-成交额}
JP4F:=IF(JM2B=1,IF(JP4B=1,IF((JP4E*2.5/10000)<5,5,JP4E*2.5/10000)+JP4E/100000,0),0);{循环买入-成交成本};
JP5A:=IF(JM2B=1,IF(COUNT(JP4B=1,SUMBARS(JM2A,1))>=1,IF(JP3A=1,1,0),0),0);{循环区-减仓卖出信号};
JP5B:=IF(JM2B=1,IF(JP5A=1,O,0),0);{循环区-减仓卖出-价格}
JP5C:=IF(JM2B=1,IF(JP5A=1,REF(JP4D,SUMBARS(JP4B,1)-1),0),0);{循环区-减仓卖出-数量}
JP5D:=IF(JM2B=1,IF(JP5A=1,JP5B*JP5C,0),0);{循环区-减仓卖出-金额}
JP5E:=IF(JM2B=1,IF(JP5A=1,IF((JP5D*2.5/10000)<5,5,JP5D*2.5/10000)+JP5D/1000+JP5D/100000,0),0);
JP6A:=IF(JM2B=1,SUM(JP1D,SUMBARS(JM2A,1))+SUM(JP2E,SUMBARS(JM2A,1))+SUM(JP3F,SUMBARS(JM2A,1))+SUM(JP4F,SUMBARS(JM2A,1))+SUM(JP5E,SUMBARS(JM2A,1)),0);{融合持仓区-所有交易成本};
JP6B:=IF(JM2B=1,SUM(JP1C,SUMBARS(JM2A,1))+SUM(JP2D,SUMBARS(JM2A,1))+SUM(JP4E,SUMBARS(JM2A,1)),0);{融合持仓区-所有投入金额};
JP6C:=IF(JM2B=1,SUM(JP3E,SUMBARS(JM2A,1))+SUM(JP5D,SUMBARS(JM2A,1)),0);
JP6D:=IF(JM2B=1,JP6B-JP6C,0);{融合持仓区-实际投入金额-用于计算持仓成本}
JP6E:=IF(JM2B=1,SUM(JP1B,SUMBARS(JM2A,1))+SUM(JP2C,SUMBARS(JM2A,1))+SUM(JP4D,SUMBARS(JM2A,1)),0);{融合持仓区-所有买入数量};
JP6F:=IF(JM2B=1,SUM(JP3D,SUMBARS(JM2A,1))+SUM(JP5C,SUMBARS(JM2A,1)),0);
JP6G:=IF(JM2B=1,JP6E-JP6F,0);{融合持仓区-实际持仓数量-用于计算持仓成本};
JP6H:=IF(JM2B=1,(JP6D+JP6A)/JP6G,0);{融合区综合持仓实际成本};
JP6I:=IF(JM2B=1,(C-JP6H)*JP6G,0);{融合区持仓浮盈}
JP6J:=IF(JM2B=1,JP6I/JP6D*100,0);{融合持仓区-浮盈率};
{以下8行代码为输出持仓的详细情况}
持仓成本:IF(JM2B=1,JP6H,0);
持仓数量:IF(JM2B=1,JP6G,0);
持仓投入额:IF(JM2B=1,JP6D,0) COLORFFFFFF;
持仓浮盈:IF(JM2B=1,JP6I,IF(REF(JM2B,1)=1 AND JM2B=0,(O-REF(JP6H,1))*REF(JP6G,1),0)),COLORRED;
持仓浮盈率:IF(JM2B=1,JP6J,IF(REF(JM2B,1)=1 AND JM2B=0,(O-REF(JP6H,1))*REF(JP6G,1)/REF(JP6D,1)*100,0));
交易成本:IF(JM2B=1,JP6A,IF(REF(JM2B,1)=1 AND JM2B=0,REF(JP6A,1)+O*REF(JP6G,1)*12.6/10000,0));
DRAWICON(JM2A=1 OR JP2A=1 OR JP4B=1,JP6D,1);
DRAWICON(JP3B=1 OR JP5A=1 OR (REF(JM2B,1)=1 AND JM2B=0),REF(JP6D,1),2);
{以下12行代码为输出-具体交易信号的交易情况}
底仓买价:JP1A;
底仓买量:JP1B;
底仓买额:JP1C;
加仓买价:JP2B;
加仓买量:JP2C;
加仓买额:JP2D;
循环买价:JP4C;
循环买量:JP4D;
循环买额:JP4E;
减仓卖价:MAX(JP3C,JP5B);
减仓卖量:MAX(JP3D,JP5C);
减仓卖额:MAX(JP3E,JP5D);
{以下代码为赚取策略4的超额收益卖出点提示-仅作为提示用,是否觉定清仓/建仓卖出,还需要结合个人经验综合判断};
MA1L:=MA(L,5);
MA1H:=MA(H,5);
MA2L:=MA(L,10);
MA2H:=MA(H,10);
K1U5:=INTPART((MA1H+2*STD(H,5))*100)/100;
K1L5:=INTPART((MA1L-2*STD(L,5))*100)/100;
K1U10:=INTPART((MA2H+2*STD(H,10))*100)/100;
K1L10:=INTPART((MA2L-2*STD(L,10))*100)/100;
JV1A:=MAX(K1U5,K1U10);
JV1B:=REF(JV1A,1);
JV1C:=IF(JM2B=1,HHV(JV1B,SUMBARS(JM2A,1)),0);{设计超额收益卖出挂单价-开盘确认};
JV1D:=IF(JM2B=1,IF(H>=JV1C,1,0),0);
JV1E:=IF(JM2B=1,IF(JV1D=1,IF(COUNT(JV1D=1,SUMBARS(JM2A,1))>=3,1,0),0),0);
JV1F:=IF(JV1E=1,INTPART(IF(O<=JV1C,JV1C,O)*100)/100,0);{实盘挂单卖出价}
DRAWICON(JV1E=1,JP6D-5000,26);{超额收益清仓/减仓/降成本T+0 卖出信号提示}
DRAWNUMBER(JV1E=1,JP6D+25000,JV1F) COLORRED;{公式网WWW.GPXIAZAI.COM}
{超额收益清仓/减仓/降成本T+0 卖出信号提示-策略计算可成交价};
投入金额:=15;
KS:=BARSCOUNT(C)+1;
NF:= YEAR;
NFB:= MOD(NF,2);
HD:=IF(REF(NF,1)<>NF,1,0);{IF(REF(NFB,1)>0 AND NFB=0,1,0);}
KS1:=IF(COUNT(HD=1,KS)=0,KS,SUMBARS(HD,1));
{注意KS与KS1的区别,股票用年画段,期货用月画段}
K2A:= IF(MOD(KS1,2)=1 OR KS1=1,1,0);
K2H:= HHV(H,SUMBARS(K2A,1));
K2L:= LLV(L,SUMBARS(K2A,1));
K2RSV:= (C-LLV(L,SUMBARS(K2A,9)))/(HHV(H,SUMBARS(K2A,9))-LLV(L,SUMBARS(K2A,9)))*100;
K2FK:=(REF(K2RSV,SUMBARS(K2A,1))+2*REF(K2RSV,SUMBARS(K2A,2)))/3;
K2K:=(K2RSV+2*K2FK)/3;
K2FD:=(REF(K2K,SUMBARS(K2A,1))+2*REF(K2K,SUMBARS(K2A,2)))/3;
K2D:=(K2K+2*K2FD)/3;
K2KD:= INTPART(100*(K2K+K2D*2)/3)/100;
K2KDQ:= REF(K2KD,SUMBARS(K2A,1));
K4A:= IF(MOD(KS1,4)=1 OR KS1=1,1,0);
K4H:= HHV(H,SUMBARS(K4A,1));
K4L:= LLV(L,SUMBARS(K4A,1));
K4RSV:= (C-LLV(L,SUMBARS(K4A,9)))/(HHV(H,SUMBARS(K4A,9))-LLV(L,SUMBARS(K4A,9)))*100;
K4FK:=(REF(K4RSV,SUMBARS(K4A,1))+2*REF(K4RSV,SUMBARS(K4A,2)))/3;
K4K:=(K4RSV+2*K4FK)/3;
K4FD:=(REF(K4K,SUMBARS(K4A,1))+2*REF(K4K,SUMBARS(K4A,2)))/3;
K4D:=(K4K+2*K4FD)/3;
K4KD:= INTPART(100*(K4K+K4D*2)/3)/100;
K4KDQ:= REF(K4KD,SUMBARS(K4A,1));
K8A:= IF(MOD(KS1,8)=1 OR KS1=1,1,0);
K8H:= HHV(H,SUMBARS(K8A,1));
K8L:= LLV(L,SUMBARS(K8A,1));
K8RSV:= (C-LLV(L,SUMBARS(K8A,9)))/(HHV(H,SUMBARS(K8A,9))-LLV(L,SUMBARS(K8A,9)))*100;
K8FK:=(REF(K8RSV,SUMBARS(K8A,1))+2*REF(K8RSV,SUMBARS(K8A,2)))/3;
K8K:=(K8RSV+2*K8FK)/3;
K8FD:=(REF(K8K,SUMBARS(K8A,1))+2*REF(K8K,SUMBARS(K8A,2)))/3;
K8D:=(K8K+2*K8FD)/3;
K8KD:= INTPART(100*(K8K+K8D*2)/3)/100;
K8KDQ:= REF(K8KD,SUMBARS(K8A,1));
JQ1A:=IF(K2KDQ<=20,1,0);{开盘确认}
JQ1B:=IF(K4KDQ<=20,1,0);{开盘确认}
JQ1C:=IF(K8KDQ<=20,1,0);{开盘确认}
JQ1D:=IF((JQ1A+JQ1B+JQ1C)>=2,1,0);{开盘确认-建仓区域框架};
{以上为笔者个人经验认为高胜率建仓区域}
{策略计算基准模块}{公式网WWW.GPXIAZAI.COM}
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);
JX1A:=EMA(C,基准值);
JX2A:=EMA(C,基准值*2);
JX3A:=EMA(C,基准值*4);
JX4A:=IF(FRACPART(基准值/2)>=0.5,INTPART(基准值/2)+1,INTPART(基准值/2));
YA:=INTPART((JX1A-JX2A)*1000);
LA:=INTPART(EMA(YA,JX4A));
YB:=INTPART((JX1A-JX3A)*1000);
LB:=INTPART(EMA(YB,JX4A));
{左侧主体-核心:建仓监控-买入-持仓-卖出}
JG1A:=IF(YA>LA,1,0);
JG1B:=IF(COUNT(YA<LA,SUMBARS(JG1A,1))=0,1,0);
JG1C:=IF(REF(JG1B,1)=0 AND JG1B=1,1,0);
JG1D:=IF(REF(JG1B,1)=1 AND JG1B=0,1,0);
JG2A:=IF(YB>LB,1,0);
JG2B:=IF(COUNT(YB<LB,SUMBARS(JG1A,1))=0,1,0);
JG2C:=IF(REF(JG2B,1)=0 AND JG2B=1,1,0);
JG2D:=IF(REF(JG2B,1)=1 AND JG2B=0,1,0);
CSH:=IF((COUNT(JG2C=1,KS)+COUNT(JG2D=1,KS))>=3 AND COUNT(JA2B=1,KS)>=2 AND COUNT(JA3B=1,KS)>=2,1,0);
JG3A:=IF(CSH=1,IF(JG1B=1 AND JG2B=1 AND LA<=0 AND LB<=0,1,0),0);{实盘监控区}
JG3B:=IF(CSH=1,IF(REF(JG3A,1)=0 AND JG3A=1,1,0),0);{实盘监控区-起点}
JG3C:=IF(CSH=1,IF(REF(JG3A,1)=1,1,0),0);{实盘挂单区}
JG3D:=IF(CSH=1,IF(REF(JG3C,1)=0 AND JG3C=1,1,0),0);{实盘挂单区起点}
JG4A:=MIN(O,C);{预计止损价}
JG4B:=IF(JG3A=1,LLV(H,SUMBARS(JG3B,1)+基准值-1),0);{预计建仓价}
JG5A:=IF(JG3C=1,IF(L<=REF(JG4B,1),1,0),0);{挂单成交信号}
JG5B:=IF(JG3C=1,IF(COUNT(JG5A=1,SUMBARS(JG3D,1))>=1,1,0),0);{实盘挂单区有持仓信号-包含卖出/止损信号};
JG6A:=IF(YA>0 OR YB>0,1,0);
JG6B:=IF(REF(JG6A,1)=1 AND JG6A=0,1,0);
JG6C:=IF(JG6B=1,LLV(JG4A,基准值),0);
JG6D:=IF(COUNT(C<REF(JG6C,SUMBARS(JG6B,1)-1),SUMBARS(JG6B,1))=0 AND COUNT(JG6A=1,SUMBARS(JG6B,1))=0,1,0);
JG6E:=IF(JG6A=1 OR JG6D=1,1,0);
JG6F:=IF(REF(JG6E,1)=0 AND JG6E=1,1,0);
JG6G:=IF(COUNT(JG6F=1,KS)>=1,IF(COUNT(JG6E=0,SUMBARS(JG6F,1))=0,1,0),0);
JG6H:=IF(REF(JG6G,1)=0 AND JG6G=1,1,0);
JG6I:=IF(JG6G=1,IF(COUNT(JG5B=1,SUMBARS(JG6H,1))>=1,1,0),0);{从左侧买入顺利过渡到右侧趋势持仓区};
JG7A:=IF(JG5B=1 OR JG6I=1 OR (REF(JG6I,1)=1 AND JG6I=0),1,0);{整体实盘持仓区}
JG7B:=IF(REF(JG7A,1)=0 AND JG7A=1 AND JG5A=1,1,0);{实盘唯一成交信号};
JG7C:=IF(JG7B=1,IF(O<=REF(JG4B,1),O,REF(JG4B,1)),0);{实盘成交价};
JG7D:=IF(COUNT(JG7B=1,KS)>=1,IF(COUNT(JG7A=0,SUMBARS(JG7B,1))=0,1,0),0);
JG7E:=IF(REF(JG7D,1)=1 AND JG7D=0,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*基准值,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 (REF(JC4A,1)=1 AND JC4A=0),1,0);
JC4C:=IF(REF(JC4B,1)=1 AND JC4B=0,1,0);{右侧持仓卖出-开盘卖出}
{右侧趋势与左侧抄底融合模块}
JM1A:=IF(JC4B=1,2,IF(JG7D,1,0));{左侧+右侧融合持仓区域持仓等级};
JM1B:=IF(REF(JM1A,1)=0 AND JM1A>=1,1,0);{融合持仓区起点}
JM1C:=IF(COUNT(JM1B=1,KS)>=1,IF(COUNT(JM1A=0,SUMBARS(JM1B,1))=0,1,0),0);
JM2A:=IF(JM1B=1,IF(JG7B=1 AND JQ1D=1,1,0),0);{重要注释:融合持仓-初次买入点--注意只要在这行代码增减“ AND JQ1D=1”即可实现策略4和策略5的无缝切换};
JM2B:=IF(COUNT(JM2A=1,KS)>=1,IF(COUNT(JM1C=0,SUMBARS(JM2A,1))=0,1,0),0);
TRE:=投入金额*10000;{个股预计投入资金}
TRE1:=INTPART(TRE/3*100)/100;{单次投入三层仓位};
JP1A:=IF(JM2A=1,JG7C,0);{三层底仓成交价}
JP1B:=IF(JM2A=1,INTPART(TRE1/JP1A/100)*100,0);{三层底仓成交数量}
JP1C:=IF(JM2A=1,JP1A*JP1B,0);{三层底仓实际占用资金}
JP1D:=IF(JM2A=1,IF((JP1C*2.5/10000)<5,5,JP1C*2.5/10000)+JP1C/100000,0);
JP2A:=IF(JM2B=1,IF(JC3C=1,IF(COUNT(JC3C,SUMBARS(JM2A,1))=1,1,0),0),0);
JP2B:=IF(JP2A=1,JC3B,0);{初次右侧趋势加仓成交价}
JP2C:=IF(JP2A=1,INTPART((TRE-REF(JP1C,SUMBARS(JM2A,1)-1))/JP2B/100)*100,0);
JP2D:=IF(JP2A=1,JP2B*JP2C,0);{初次右侧趋势加仓成交金额}
JP2E:=IF(JP2A=1,IF((JP2D*2.5/10000)<5,5,JP2D*2.5/10000)+JP2D/100000,0);
JP3A:=IF(JM2B=1,IF((JG7E=1 AND COUNT(JM2B=0,SUMBARS(JG7B,1))=0) OR (JC4C=1 AND COUNT(JM2B=0,SUMBARS(JC3C,1))=0),1,0),0);{融合持仓区-有卖出减仓};
JP3B:=IF(JM2B=1,IF(JP3A=1,IF(COUNT(JP3A=1,SUMBARS(JM2A,1))=1,1,0),0),0);
JP3C:=IF(JM2B=1,IF(JP3B=1,O,0),0);{融合持仓区-首次减仓卖出成交价}
JP3D:=IF(JM2B=1,IF(JP3B=1,REF(JP1B,SUMBARS(JM2A,1)-1),0),0);{融合持仓区-首次减仓卖出成交数量-卖出底仓成交数量}
JP3E:=IF(JM2B=1,IF(JP3B=1,JP3C*JP3D,0),0);{融合持仓区-首次减仓卖出成交金额}
JP3F:=IF(JM2B=1,IF(JP3B=1,IF((JP3E*2.5/10000)<5,5,JP3E*2.5/10000)+JP3E/1000+JP3E/100000,0),0);{卖出成交成本};
JP4A:=IF(JM2B=1,IF(JG7B=1 OR JC3C=1,1,0),0);{融合区-通用买入信号};
JP4B:=IF(JM2B=1,IF(JP4A=1,IF(COUNT(JP2A=1,SUMBARS(JM2A,1))>=1,IF(SUMBARS(JP2A,1)>1 AND COUNT(JP3B=1,SUMBARS(JP2A,1))>=1,1,0),0),0),0);
JP4C:=IF(JM2B=1,IF(JP4B=1,MAX(JG7C,JC3B),0),0);{循环买入-成交价}
JP4D:=IF(JM2B=1,IF(JP4B=1,INTPART(TRE1/JP4C/100)*100,0),0);{循环买入-成交数量}
JP4E:=IF(JM2B=1,IF(JP4B=1,JP4C*JP4D,0),0);{循环买入-成交额}
JP4F:=IF(JM2B=1,IF(JP4B=1,IF((JP4E*2.5/10000)<5,5,JP4E*2.5/10000)+JP4E/100000,0),0);{循环买入-成交成本};
JP5A:=IF(JM2B=1,IF(COUNT(JP4B=1,SUMBARS(JM2A,1))>=1,IF(JP3A=1,1,0),0),0);{循环区-减仓卖出信号};
JP5B:=IF(JM2B=1,IF(JP5A=1,O,0),0);{循环区-减仓卖出-价格}
JP5C:=IF(JM2B=1,IF(JP5A=1,REF(JP4D,SUMBARS(JP4B,1)-1),0),0);{循环区-减仓卖出-数量}
JP5D:=IF(JM2B=1,IF(JP5A=1,JP5B*JP5C,0),0);{循环区-减仓卖出-金额}
JP5E:=IF(JM2B=1,IF(JP5A=1,IF((JP5D*2.5/10000)<5,5,JP5D*2.5/10000)+JP5D/1000+JP5D/100000,0),0);
JP6A:=IF(JM2B=1,SUM(JP1D,SUMBARS(JM2A,1))+SUM(JP2E,SUMBARS(JM2A,1))+SUM(JP3F,SUMBARS(JM2A,1))+SUM(JP4F,SUMBARS(JM2A,1))+SUM(JP5E,SUMBARS(JM2A,1)),0);{融合持仓区-所有交易成本};
JP6B:=IF(JM2B=1,SUM(JP1C,SUMBARS(JM2A,1))+SUM(JP2D,SUMBARS(JM2A,1))+SUM(JP4E,SUMBARS(JM2A,1)),0);{融合持仓区-所有投入金额};
JP6C:=IF(JM2B=1,SUM(JP3E,SUMBARS(JM2A,1))+SUM(JP5D,SUMBARS(JM2A,1)),0);
JP6D:=IF(JM2B=1,JP6B-JP6C,0);{融合持仓区-实际投入金额-用于计算持仓成本}
JP6E:=IF(JM2B=1,SUM(JP1B,SUMBARS(JM2A,1))+SUM(JP2C,SUMBARS(JM2A,1))+SUM(JP4D,SUMBARS(JM2A,1)),0);{融合持仓区-所有买入数量};
JP6F:=IF(JM2B=1,SUM(JP3D,SUMBARS(JM2A,1))+SUM(JP5C,SUMBARS(JM2A,1)),0);
JP6G:=IF(JM2B=1,JP6E-JP6F,0);{融合持仓区-实际持仓数量-用于计算持仓成本};
JP6H:=IF(JM2B=1,(JP6D+JP6A)/JP6G,0);{融合区综合持仓实际成本};
JP6I:=IF(JM2B=1,(C-JP6H)*JP6G,0);{融合区持仓浮盈}
JP6J:=IF(JM2B=1,JP6I/JP6D*100,0);{融合持仓区-浮盈率};
{以下8行代码为输出持仓的详细情况}
持仓成本:IF(JM2B=1,JP6H,0);
持仓数量:IF(JM2B=1,JP6G,0);
持仓投入额:IF(JM2B=1,JP6D,0) COLORFFFFFF;
持仓浮盈:IF(JM2B=1,JP6I,IF(REF(JM2B,1)=1 AND JM2B=0,(O-REF(JP6H,1))*REF(JP6G,1),0)),COLORRED;
持仓浮盈率:IF(JM2B=1,JP6J,IF(REF(JM2B,1)=1 AND JM2B=0,(O-REF(JP6H,1))*REF(JP6G,1)/REF(JP6D,1)*100,0));
交易成本:IF(JM2B=1,JP6A,IF(REF(JM2B,1)=1 AND JM2B=0,REF(JP6A,1)+O*REF(JP6G,1)*12.6/10000,0));
DRAWICON(JM2A=1 OR JP2A=1 OR JP4B=1,JP6D,1);
DRAWICON(JP3B=1 OR JP5A=1 OR (REF(JM2B,1)=1 AND JM2B=0),REF(JP6D,1),2);
{以下12行代码为输出-具体交易信号的交易情况}
底仓买价:JP1A;
底仓买量:JP1B;
底仓买额:JP1C;
加仓买价:JP2B;
加仓买量:JP2C;
加仓买额:JP2D;
循环买价:JP4C;
循环买量:JP4D;
循环买额:JP4E;
减仓卖价:MAX(JP3C,JP5B);
减仓卖量:MAX(JP3D,JP5C);
减仓卖额:MAX(JP3E,JP5D);
{以下代码为赚取策略4的超额收益卖出点提示-仅作为提示用,是否觉定清仓/建仓卖出,还需要结合个人经验综合判断};
MA1L:=MA(L,5);
MA1H:=MA(H,5);
MA2L:=MA(L,10);
MA2H:=MA(H,10);
K1U5:=INTPART((MA1H+2*STD(H,5))*100)/100;
K1L5:=INTPART((MA1L-2*STD(L,5))*100)/100;
K1U10:=INTPART((MA2H+2*STD(H,10))*100)/100;
K1L10:=INTPART((MA2L-2*STD(L,10))*100)/100;
JV1A:=MAX(K1U5,K1U10);
JV1B:=REF(JV1A,1);
JV1C:=IF(JM2B=1,HHV(JV1B,SUMBARS(JM2A,1)),0);{设计超额收益卖出挂单价-开盘确认};
JV1D:=IF(JM2B=1,IF(H>=JV1C,1,0),0);
JV1E:=IF(JM2B=1,IF(JV1D=1,IF(COUNT(JV1D=1,SUMBARS(JM2A,1))>=3,1,0),0),0);
JV1F:=IF(JV1E=1,INTPART(IF(O<=JV1C,JV1C,O)*100)/100,0);{实盘挂单卖出价}
DRAWICON(JV1E=1,JP6D-5000,26);{超额收益清仓/减仓/降成本T+0 卖出信号提示}
DRAWNUMBER(JV1E=1,JP6D+25000,JV1F) COLORRED;{公式网WWW.GPXIAZAI.COM}
{超额收益清仓/减仓/降成本T+0 卖出信号提示-策略计算可成交价};
- 上一篇公式:通达信凌波微步选股指标 源码 贴图
- 下一篇公式:通达信超级疯牛股副图指标 源码 贴图