通达信交易策略(左侧抄底+右侧趋势)副图 开源 附图

{策略4 持仓源码如下}

基准值:=5;
投入金额:=15;
KS:=BARSCOUNT(C)+1;{上市交易以来有效K线数,例如:日线图中表示上市交易天数}
{策略计算基准模块}
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));
{策略3主体-核心:建仓监控-买入-持仓-卖出}
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);{左侧-实盘持仓区-开盘卖出}
{策略1主体核心: 建仓区域监控-买入-持仓-卖出模块}
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);
{唯一建仓后-持仓区持仓区-包含收盘时提示卖出信号K线-注意卖出价设计为下一根K线开盘价-右侧持仓区};
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);{融合持仓区-包含卖出K线};
JM2A:=IF(JM1B=1,IF(JG7B=1,1,0),0);{融合持仓-初次买入点};
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));
持仓浮盈率: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 交易源码如下}

基准值:=5;
投入金额:=15;
KS:=BARSCOUNT(C)+1;{上市交易以来有效K线数,例如:日线图中表示上市交易天数}
{策略计算基准模块}
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));
{策略3主体-核心:建仓监控-买入-持仓-卖出}
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);{左侧-实盘持仓区-开盘卖出}
{策略1主体核心: 建仓区域监控-买入-持仓-卖出模块}
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);
{唯一建仓后-持仓区持仓区-包含收盘时提示卖出信号K线-注意卖出价设计为下一根K线开盘价-右侧持仓区};
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);{融合持仓区-包含卖出K线};
JM2A:=IF(JM1B=1,IF(JG7B=1,1,0),0);{融合持仓-初次买入点};
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));
持仓浮盈率:=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);



来函数检测结果如下:
该公式没有未来函数

解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式

联系我们  |  股票指标网  |  指标网   |  指标公式  |   加入收藏   |  设为主页

@2005-2023 粤ICP备2023063687号-2 股票指标网别名指标网仅为互联网文章,所有股票指标公式及文章仅供学习研究,并不构成投资建议,请勿以此为依据进行股票交易,由此引起的投资亏损与本站无关。股票指标网均来源互联网收集整理,如不慎侵犯了你的权益,请联系我们告知,我们将做删除处理
QQ:88652583 微信 88652583
sitemap站点地图