高级版公式源码 - 四、六西格玛算法高级版

公式名称:2三价信号  

适用平台:通达信

适用版本:进阶版

公式类型:副图指标

公式说明:将《六西格玛操盘术》九种形态信号、18种入场点信号在本公式表达出来

公式代码:

RUN:=TDXDLL3(0,CLOSE,N,0); {必须放第一行运行}
{数据区}
PRICE1UCL:=TDXDLL3(4,CLOSE,N,0); {PRICE1UCL价位台阶上沿}
PRICE1LCL:=TDXDLL3(5,CLOSE,N,0); {PRICE1LCL价位台阶下沿};
COSTUCL:=TDXDLL3(6,CLOSE,N,0); {COSTUCL价格中枢上沿}
COSTLCL:=TDXDLL3(7,CLOSE,N,0); {COSTLCL价格中枢下沿}
COSTMID:=TDXDLL3(12,CLOSE,N,0); {COSTMID价格中枢中位线}
VALUEUCL:=TDXDLL3(8,CLOSE,N,0); {VALUEUCL价值区间上沿}
VALUELCL:=TDXDLL3(9,CLOSE,N,0); {VALUELCL价值区间下沿}
VALUEMID:=TDXDLL3(13,CLOSE,N,0); {VALUEMID价值中枢中位线}
POWPEAK:=TDXDLL3(15,CLOSE,N,0); {POWPEAK波峰波谷}
DIFFVIEW:=TDXDLL3(16,CLOSE,N,0); {DIFF监控}
DEAVIEW:=TDXDLL3(17,CLOSE,N,0); {DEA监控}
ISPRICEUP:=TDXDLL3(26,CLOSE,N,0); {ISPRICEUP价位台阶上封信号}
ISPRICEDOWN:=TDXDLL3(27,CLOSE,N,0); {ISPRICEDOWN价位台阶下封信号}
TOPPRICETURNCNT:=TDXDLL3(36,CLOSE,N,0)*10; {TOPPRICETURNINGCOUNT向上价位台阶序数}
BOTPRICETURNCNT:=TDXDLL3(37,CLOSE,N,0)*10; {BOTPRICETURNINGCOUNT向下价位台阶序数}
PRICEUPCLSBARS:=TDXDLL3(22,CLOSE,N,0); {PRICEUPCLOSEBARS台阶关闭所需周期}
PRICEDWCLSBARS:=TDXDLL3(23,CLOSE,N,0); {PRICEDWCLOSEBARS台阶关闭所需周期}
{中枢区间}
ISCOSTUP:=TDXDLL3(28,CLOSE,N,0); {ISCOSTUP价格中枢上封信号}
ISCOSTDOWN:=TDXDLL3(29,CLOSE,N,0); {ISCOSTDOWN价格中枢下封信号}
TOPCOSTTURNCNT:=TDXDLL3(38,CLOSE,N,0)*10; {TOPCOSTTURNINGCOUNT向上价格中枢封闭次数}
BOTCOSTTURNCNT:=TDXDLL3(39,CLOSE,N,0)*10; {BOTCOSTTURNINGCOUNT向下价格中枢封闭次数} 

{价格筹码收敛度}
COSTCVG1:=0-TDXDLL3(43,CLOSE,N,0)*0.2; {COSTCVG价格筹码收敛度}
COSTCVG2:=TDXDLL3(43,CLOSE,N,0)*0.2; {COSTCVG价格筹码收敛度}

{中枢发散区,即中断-反转区}
TOPCOSTCVGCNT:=IF(COSTCVG2>0,TOPCOSTTURNCNT,0);
BOTCOSTCVGCNT:=IF(COSTCVG2>0,BOTCOSTTURNCNT,0);

{价格中枢即将封闭所需周期}
COSTUPCLSBARS:=TDXDLL3(20,CLOSE,N,0); {COSTUPCLOSEBARS价格中枢关闭所需周期}
COSTDWCLSBARS:=TDXDLL3(21,CLOSE,N,0); {COSTDWCLOSEBARS价格中枢关闭所需周期}

{反转与中继区}
ISCOSTUP1:=REF(TOPCOSTCVGCNT,1)=0 AND TOPCOSTCVGCNT>0; {价格发散}
ISCOSTDOWN1:=REF(BOTCOSTCVGCNT,1)=0 AND BOTCOSTCVGCNT<0; {价格发散}

{价格中枢向上封闭序数}
TOPVALUETURNCNT:=TDXDLL3(40,CLOSE,N,0)*10; {TOPVALUETURNINGCOUNT向上价格中枢封闭次数}
BOTVALUETURNCNT:=TDXDLL3(41,CLOSE,N,0)*10; {BOTVALUETURNINGCOUNT向下价格中枢封闭次数} 


{价值回归域}
ISVALUEUP:=TDXDLL3(30,CLOSE,N,0); {ISVALUEUP价值区间上封信号}
ISVALUEDOWN:=TDXDLL3(31,CLOSE,N,0); {ISVALUEDOWN价值区间下封信号}

{价值筹码收敛度}
VALUECVG:=TDXDLL3(44,CLOSE,N,0); {VALUECVG价值筹码收敛度}
VALUECVG1:=0-VALUECVG*0.2;
VALUECVG2:=VALUECVG*0.2; 

{价值区间中的价格发散区}
TOPVALUECVGCNT:=IF(VALUECVG>0,TOPVALUETURNCNT,0);
BOTVALUECVGCNT:=IF(VALUECVG>0,BOTVALUETURNCNT,0);
VALUEUPCLSBARS:=TDXDLL3(24,CLOSE,N,0)*1.5; {VALUEUPCLOSEBARS区间关闭所需周期}
VALUEDWCLSBARS:=TDXDLL3(25,CLOSE,N,0)*1.5; {VALUEDWCLOSEBARS区间关闭所需周期}

{价格离散形态起如信号}
ISVALUEUP1:=REF(TOPVALUECVGCNT,1)=0 AND TOPVALUECVGCNT>0; {价格发散}
ISVALUEDOWN1:=REF(BOTVALUECVGCNT,1)=0 AND BOTVALUECVGCNT<0; {价格发散}

{定位第一类买卖点(6第一买点-6第一卖点,4反弹点-4回调点,2支撑点,-2压力点)}
ONEPOSITION:=TDXDLL3(46,CLOSE,N,0)*2,COLORWHITE,DOTLINE,LINETHICK1; {ONEPOSITION价位台阶买卖信号}
{///定位第二、三类买卖点(6第三买点-6第三卖点,4第二买点-4第二卖点,2向上中继点-2向下中断点,3向上反转点,-3向下反转点)}
TWOPOSITION:=TDXDLL3(47,CLOSE,N,0); {TWOPOSITION价格中枢买卖信号}
{定位第四类买卖点(2低吸点-2高抛点,4第四买点-4第四卖点)}
THREEPOSITION:=TDXDLL3(48,CLOSE,N,0); {THREEPOSITION价值区间买卖信号}

{关键入场点============================================}
一买:=IF(ONEPOSITION=6,ONEPOSITION,0); {一买一卖信号}
一买1:=一买*0.85;
一卖:=IF(ONEPOSITION=-6,ONEPOSITION,0); {一买一卖信号}
一卖1:=一卖*0.85;
支撑:=IF(ONEPOSITION=2,ONEPOSITION,0); {支撑压力信号}
支撑1:=支撑*0.8;
压力:=IF(ONEPOSITION=-2,ONEPOSITION,0); {支撑压力信号}
压力1:=压力*0.8;
反弹:=IF(ONEPOSITION=4,ONEPOSITION,0); {反弹回调信号}
反弹1:=反弹*0.8;
回调:=IF(ONEPOSITION=-4,ONEPOSITION,0); {反弹回调信号}
回调1:=回调*0.8;

二买:=IF(TWOPOSITION=4,TWOPOSITION,0);
二买1:=二买/2;
二卖:=IF(TWOPOSITION=-4,TWOPOSITION,0);
二卖1:=二卖/2;
三买:=IF(TWOPOSITION=6,TWOPOSITION,0);
三买1:=三买/1.5;
三买2:=三买/3;
三卖:=IF(TWOPOSITION=-6,TWOPOSITION,0);
三卖1:=三卖/1.5;
三卖2:=三卖/3;

涨中继:=IF(TWOPOSITION=2,TWOPOSITION,0);
涨中继1:=涨中继*0.2;
跌中继:=IF(TWOPOSITION=-2,TWOPOSITION,0);
跌中继1:=跌中继*0.2;

涨反转:=IF(TWOPOSITION=-3,TWOPOSITION,0);
涨反转1:=涨反转*0.5;
跌反转:=IF(TWOPOSITION=3,TWOPOSITION,0);
跌反转1:=跌反转*0.5;

低吸:=IF(THREEPOSITION=2,THREEPOSITION,0);
低吸1:=低吸*0.85;
低吸2:=低吸*0.6;
低吸3:=低吸*0.4;
高抛:=IF(THREEPOSITION=-2,THREEPOSITION,0);
高抛1:=高抛*0.85;
高抛2:=高抛*0.6;
高抛3:=高抛*0.4;


四买:=IF(THREEPOSITION=4,THREEPOSITION,0);
四买1:=四买*0.85;
四买2:=四买*0.6;
四买3:=四买*0.4;
四卖:=IF(THREEPOSITION=-4,THREEPOSITION,0);
四卖1:=四卖*0.85;
四卖2:=四卖*0.6;
四卖3:=四卖*0.4;

{以下是信号绘制区}

{绘制各区间背景}
DRAWBAND(TOPVALUETURNCNT,RGB(255,102,102),BOTVALUETURNCNT,RGB(255,102,102));{价值回归}
DRAWBAND(TOPVALUECVGCNT,RGB(255,150,150),BOTVALUECVGCNT,RGB(255,150,150)); {价格发散}
DRAWBAND(TOPCOSTTURNCNT,RGB(180,180,180),BOTCOSTTURNCNT,RGB(180,180,180)); {二三买卖区}
DRAWBAND(TOPCOSTCVGCNT,RGB(200,200,200),BOTCOSTCVGCNT,RGB(200,200,200)); {反转中继区}
DRAWBAND(TOPPRICETURNCNT,RGB(85,85,85),BOTPRICETURNCNT,RGB(85,85,85)); {价位台阶区}

{绘制预警信号}

{价格中枢封闭预警}
STICKLINE(COSTUPCLSBARS>0,0 ,(TOPCOSTTURNCNT+5)*1.0/2,4,0 ),COLORFFCC00;
STICKLINE(COSTUPCLSBARS>0,0 ,(TOPCOSTTURNCNT+5)*0.8/2,4,0 ),COLORFF9900;
STICKLINE(COSTUPCLSBARS>0,0 ,(TOPCOSTTURNCNT+5)*0.6/2,4,0 ),COLORFF6600;
STICKLINE(COSTUPCLSBARS>0,0 ,(TOPCOSTTURNCNT+5)*0.4/2,4,0 ),COLORFF3300;
STICKLINE(COSTUPCLSBARS>0,0 ,(TOPCOSTTURNCNT+5)*0.2/2,4,0 ),COLORFF0000;
STICKLINE(COSTDWCLSBARS>0,0 ,0-(-BOTCOSTTURNCNT+5)*1.0/2,4,0 ),COLORFFCC00;
STICKLINE(COSTDWCLSBARS>0,0 ,0-(-BOTCOSTTURNCNT+5)*0.8/2,4,0 ),COLORFF9900;
STICKLINE(COSTDWCLSBARS>0,0 ,0-(-BOTCOSTTURNCNT+5)*0.6/2,4,0 ),COLORFF6600;
STICKLINE(COSTDWCLSBARS>0,0 ,0-(-BOTCOSTTURNCNT+5)*0.4/2,4,0 ),COLORFF3300;
STICKLINE(COSTDWCLSBARS>0,0 ,0-(-BOTCOSTTURNCNT+5)*0.2/2,4,0 ),COLORFF0000; 

{价位台阶封闭预警}  
STICKLINE(PRICEUPCLSBARS>0,0 ,(TOPPRICETURNCNT+3)*1.0/2,4,0 ),COLOR00EEFF;
STICKLINE(PRICEUPCLSBARS>0,0 ,(TOPPRICETURNCNT+3)*0.8/2,4,0 ),COLOR00BBFF;
STICKLINE(PRICEUPCLSBARS>0,0 ,(TOPPRICETURNCNT+3)*0.6/2,4,0 ),COLOR0099FF;
STICKLINE(PRICEUPCLSBARS>0,0 ,(TOPPRICETURNCNT+3)*0.4/2,4,0 ),COLOR0066FF;
STICKLINE(PRICEUPCLSBARS>0,0 ,(TOPPRICETURNCNT+3)*0.2/2,4,0 ),COLOR0000FF;
STICKLINE(PRICEDWCLSBARS>0,0 ,0-(-BOTPRICETURNCNT+3)*1.0/2,4,0 ),COLOR00EEFF;
STICKLINE(PRICEDWCLSBARS>0,0 ,0-(-BOTPRICETURNCNT+3)*0.8/2,4,0 ),COLOR00BBFF;
STICKLINE(PRICEDWCLSBARS>0,0 ,0-(-BOTPRICETURNCNT+3)*0.6/2,4,0 ),COLOR0099FF;
STICKLINE(PRICEDWCLSBARS>0,0 ,0-(-BOTPRICETURNCNT+3)*0.4/2,4,0 ),COLOR0066FF;
STICKLINE(PRICEDWCLSBARS>0,0 ,0-(-BOTPRICETURNCNT+3)*0.2/2,4,0 ),COLOR0000FF; 

{价值区间封闭预警}

STICKLINE(VALUEUPCLSBARS>0,0 ,(TOPVALUETURNCNT+5)*1.0/2,4,0 ),COLOR10EE55;
STICKLINE(VALUEUPCLSBARS>0,0 ,(TOPVALUETURNCNT+5)*0.8/2,4,0 ),COLOR10BB55;
STICKLINE(VALUEUPCLSBARS>0,0 ,(TOPVALUETURNCNT+5)*0.6/2,4,0 ),COLOR109955;
STICKLINE(VALUEUPCLSBARS>0,0 ,(TOPVALUETURNCNT+5)*0.4/2,4,0 ),COLOR106655;
STICKLINE(VALUEUPCLSBARS>0,0 ,(TOPVALUETURNCNT+5)*0.2/2,4,0 ),COLOR100055;
STICKLINE(VALUEDWCLSBARS>0,0 ,0-(-BOTVALUETURNCNT+5)*1.0/2,4,0 ),COLOR10EE55;
STICKLINE(VALUEDWCLSBARS>0,0 ,0-(-BOTVALUETURNCNT+5)*0.8/2,4,0 ),COLOR10BB55;
STICKLINE(VALUEDWCLSBARS>0,0 ,0-(-BOTVALUETURNCNT+5)*0.6/2,4,0 ),COLOR109955;
STICKLINE(VALUEDWCLSBARS>0,0 ,0-(-BOTVALUETURNCNT+5)*0.4/2,4,0 ),COLOR106655;
STICKLINE(VALUEDWCLSBARS>0,0 ,0-(-BOTVALUETURNCNT+5)*0.2/2,4,0 ),COLOR100055;

{绘制形态起始信号}

{价值回归}
STICKLINE(ISVALUEUP>0,0 ,(TOPVALUETURNCNT),5,0 ),COLORBROWN;
STICKLINE(ISVALUEDOWN>0,0 ,0-(-BOTVALUETURNCNT),5,0 ),COLORBROWN; 

{价格发散}
STICKLINE(ISVALUEUP1,0,(TOPVALUETURNCNT)*1,5,0 ),COLORBROWN;
STICKLINE(ISVALUEDOWN1,0 ,0-(-BOTVALUETURNCNT)*1,5,0 ),COLORBROWN;

{价格中枢}
STICKLINE(ISCOSTUP>0,0 ,(TOPCOSTTURNCNT)*1,5,0 ),COLORBROWN;
STICKLINE(ISCOSTDOWN>0,0 ,0-(-BOTCOSTTURNCNT)*1,5,0 ),COLORBROWN; 

{中继.反转}
STICKLINE(ISCOSTUP1,0,(TOPCOSTTURNCNT)*1,5,0 ),COLORBROWN;
STICKLINE(ISCOSTDOWN1,0 ,0-(-BOTCOSTTURNCNT)*1,5,0 ),COLORBROWN;

{价位台阶:启动、加速、衰竭}
STICKLINE(ISPRICEUP>0,0 ,(TOPPRICETURNCNT),5,0 ),COLORBROWN;
STICKLINE(ISPRICEDOWN>0,0 ,0-(-BOTPRICETURNCNT),5,0 ),COLORBROWN;

{向上价值区间走势形态文字}
DRAWTEXT(ISVALUEUP>0 && TOPVALUETURNCNT>0,TOPVALUETURNCNT,'&>&价&值&回&归'),COLORWHITE;
DRAWTEXT(ISVALUEUP1>0 && TOPVALUETURNCNT>0,TOPVALUETURNCNT,'&>&价&格&发&散'),COLORWHITE;


{向下价值区间走势形态文字}

DRAWTEXT(ISVALUEDOWN>0 && BOTVALUETURNCNT<0,BOTVALUETURNCNT+10,'&价&值&回&归&>'),COLORWHITE;
DRAWTEXT(ISVALUEDOWN1>0 && BOTVALUETURNCNT<0,BOTVALUETURNCNT+10,'&价&格&发&散&>'),COLORWHITE;

{绘制价格中枢文字}

DRAWTEXT(ISCOSTUP>0 && TOPCOSTTURNCNT>0,TOPCOSTTURNCNT,'&>&三&买&.&二&卖'),COLORWHITE;
DRAWTEXT(ISCOSTDOWN>0 && BOTCOSTTURNCNT<0,BOTCOSTTURNCNT+10,'&三&卖&.&二&买&>'),COLORWHITE;
{绘制走势转折-中继区文字}
DRAWTEXT(ISCOSTUP1>0 && TOPCOSTTURNCNT>0,TOPCOSTTURNCNT,'&>&反&转&-&中&继'),COLORWHITE;
DRAWTEXT(ISCOSTDOWN1>0 && BOTCOSTTURNCNT<0,BOTCOSTTURNCNT+10,'&反&转&.&中&继&>'),COLORWHITE;

{绘制各台阶形态文字}

DRAWTEXT(ISPRICEUP>0 AND TOPPRICETURNCNT=10,TOPPRICETURNCNT,'&>&回&调&形&态'),COLORWHITE;
DRAWTEXT(ISPRICEUP>0 AND TOPPRICETURNCNT>=20,TOPPRICETURNCNT,'&>&一&卖&建&构'),COLORWHITE;
DRAWTEXT(ISPRICEDOWN>0 AND BOTPRICETURNCNT=-10,BOTPRICETURNCNT+10,'&反&弹&形&态&>'),COLORWHITE;
DRAWTEXT(ISPRICEDOWN>0 AND BOTPRICETURNCNT<=-20,BOTPRICETURNCNT+10,'&一&买&建&构&>'),COLORWHITE;

{绘制入场点信号}
DRAWBAND(一买,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(一买1,RGB(155,0,0),0,RGB(155,0,0));
DRAWBAND(一卖,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(一卖1,RGB(0,155,0),0,RGB(0,155,0));
DRAWBAND(反弹,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(反弹1,RGB(0,0,0),0,RGB(0,0,0));
DRAWBAND(回调,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(回调1,RGB(0,0,0),0,RGB(0,0,0));
STICKLINE(ONEPOSITION=2,0,ONEPOSITION*1,5,1),COLORYELLOW; {支撑点}
STICKLINE(ONEPOSITION=2,0,ONEPOSITION*0.5,5,0),COLORRED; {支撑点}
STICKLINE(ONEPOSITION=-2,0,ONEPOSITION*1,5,1),COLORBLUE; {压力点}
STICKLINE(ONEPOSITION=-2,0,ONEPOSITION*0.5,5,0),COLORGREEN; {压力点}

DRAWBAND(二买,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(二买1,RGB(200,0,0),0,RGB(200,0,0));

DRAWBAND(二卖,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(二卖1,RGB(0,200,0),0,RGB(0,200,0));

DRAWBAND(三买,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(三买1,RGB(200,0,0),0,RGB(200,0,0));
DRAWBAND(三买2,RGB(150,0,0),0,RGB(150,0,0));

DRAWBAND(三卖,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(三卖1,RGB(0,200,0),0,RGB(0,200,0));
DRAWBAND(三卖2,RGB(0,150,0),0,RGB(0,150,0));

DRAWBAND(涨中继,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(涨中继1,RGB(155,0,0),0,RGB(155,0,0));
DRAWBAND(跌中继,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(跌中继1,RGB(0,155,0),0,RGB(0,155,0));

DRAWBAND(涨反转,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(涨反转1,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(跌反转,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(跌反转1,RGB(0,255,0),0,RGB(0,255,0));

DRAWBAND(高抛,RGB(0,255,0),0,RGB(0,255,0));
DRAWBAND(高抛1,RGB(0,210,0),0,RGB(0,210,0));
DRAWBAND(高抛2,RGB(0,180,0),0,RGB(0,180,0));
DRAWBAND(高抛3,RGB(0,150,0),0,RGB(0,150,0));
DRAWBAND(低吸,RGB(255,0,0),0,RGB(255,0,0));
DRAWBAND(低吸1,RGB(210,0,0),0,RGB(210,0,0));
DRAWBAND(低吸2,RGB(180,0,0),0,RGB(180,0,0));
DRAWBAND(低吸3,RGB(150,0,0),0,RGB(150,0,0));


{DRAWBAND(四买卖/2,RGB(100,0,0),0,RGB(0,100,0));
DRAWBAND(四买卖1/2,RGB(150,0,0),0,RGB(0,150,0));
DRAWBAND(四买卖2/2,RGB(200,0,0),0,RGB(0,200,0));
DRAWBAND(四买卖3/2,RGB(255,0,0),0,RGB(0,255,0));};

∑六西格玛操盘术官网
鄂ICP备2021013451号 Copyright © 2021-2059 SixSigma All rights reserved.

风险提示:本站所有算法模型仅作为学习研究、统计、模拟分析等辅助,不可作为投资决策依据。风险自担!