MA(CLOSE,5);
//福安賺差價的人,設(shè)計QQ624544691
//高低點一定是前6天和后6天的最高點和最低點//
BD1:=LOW<=LLV(LOW,6) AND REFX(LOW,1)>=LOW AND REFX(LOW,2)>=LOW AND REFX(LOW,3)>=LOW
AND REFX(LOW,4)>=LOW
AND REFX(LOW,5)>=LOW
;//筆高,粗選//
BG1:= HIGH>=HHV(HIGH,6) AND REFX(HIGH,1)<=HIGH AND REFX(HIGH,2)<=HIGH
AND REFX(HIGH,3)<=HIGH
AND REFX(HIGH,4)<=HIGH AND REFX(HIGH,5)<=HIGH ;//筆低,粗選//
BDQ:=(REFX(BD1,1)=1 AND BARSLAST(BG1)>=3)
OR (REFX(BD1,1)=1 AND COUNT(BD1,BARPOS)=0 AND COUNT(BG1,BARPOS)=0)
;
BDQ1:=(BDQ AND COUNT(BDQ,BARSLAST(BG1))=1)
OR (
BARSSINCE(BDQ)=0);
BD2:=(BD1 AND BARSLAST(BG1)>3 AND LOW<=LLV(LOW,BARSLAST(BDQ1)) AND COUNT(BG1,BARSLAST(BDQ1))=0)
OR (BD1 AND
LOW<=LLV(LOW,BARSLAST(BDQ1)) AND COUNT(BG1,BARPOS)=0
);
BDDW:=BACKSET(BD2,BARSLAST(BDQ1));
//DRAWTEXT(BDDW,HIGH,'1');
//DRAWTEXT((BDDW AND REFX(BDDW,1)=0),LOW*0.94,'第二低點');//
BD3:=(BDDW AND REFX(BDDW,1)=0)
OR (BDDW AND ISLASTBAR) OR
(BD1 AND BARSLAST(BG1)<4);//修改過,去除高低點在同一根//
//筆高前一根//
BGQ:=(REFX(BG1,1)=1 AND BARSLAST(BD1)>=3)
OR (REFX(BG1,1)=1 AND COUNT(BD1,BARPOS)=0 AND COUNT(BG1,BARPOS)=0);
//DRAWTEXT(BGQ ,HIGH,'前')COL OR YELLOW;//測試低點//
BGQ1:=(BGQ AND COUNT(BGQ,BARSLAST(BD1))=1)
OR ( BARSSINCE(BGQ)=0);
//DRAWTEXT(BGQ1 ,HIGH*1.03,'第一前')COL OR
CYAN;//測試低點//
//新筆高//
BG2:=(BG1 AND BARSLAST(BD1)>3 AND HIGH>=HHV(HIGH,BARSLAST(BGQ1)) AND COUNT(BD1,BARSLAST(BGQ1))=0
) OR (BG1 AND
HIGH>=HHV(HIGH,BARSLAST(BGQ1)) AND COUNT(BD1,BARPOS)=0
);
BGDW:=BACKSET(BG2,BARSLAST(BGQ1));
//DRAWTEXT((BGDW AND REFX(BGDW,1)=0),HIGH*1.03,'第二高');//
BG3:=(BGDW AND REFX(BGDW,1)=0)
OR
(BGDW AND ISLASTBAR) OR
(BG1 AND BARSLAST(BD1)<4)
;
//跟前面的筆高距離小于4,并且價格是最低的//
//筆低前一根//
BDQ30:=(REFX(BD1,1)=1 )
OR (REFX(BD1,1)=1 AND COUNT(BD1,BARPOS)=0 AND COUNT(BG1,BARPOS)=0)
;
BDQ130:=(BDQ30 AND COUNT(BDQ30,BARSLAST(BG1))=1)
OR (
BARSSINCE(BDQ30)=0);
//DRAWTEXT(BDQ ,LOW*0.98,'前')COL OR
YELLOW;//測試低點//
//DRAWTEXT(BDQ1,LOW*0.96,'第一前')COL OR
CYAN;//測試低點//
//新BD2//
BD230:=(BD1
AND LOW<=LLV(LOW,BARSLAST(BDQ130)) AND COUNT(BG1,BARSLAST(BDQ130))=0 )
OR (BD1 AND
LOW<=LLV(LOW,BARSLAST(BDQ130)) AND COUNT(BG1,BARPOS)=0
);
BDDW30:=BACKSET(BD230,BARSLAST(BDQ130));
BD4:=BDDW30 AND REFX(BDDW30,1)=0;
BD5:=BD3 OR (BD4 AND BARSLAST(BG1)<4
) ;
//跟前面的筆低距離小于4,并且價格是最高的//
//筆高前一根//
BGQ30:=(REFX(BG1,1)=1 )
OR (REFX(BG1,1)=1 AND COUNT(BD1,BARPOS)=0 AND COUNT(BG1,BARPOS)=0);
//DRAWTEXT(BGQ ,HIGH,'前')COL OR YELLOW;//測試低點//
BGQ130:=(BGQ30 AND COUNT(BGQ30,BARSLAST(BD1))=1)
OR ( BARSSINCE(BGQ30)=0);
//DRAWTEXT(BGQ1 ,HIGH*1.03,'第一前')COL OR
CYAN;//測試低點//
//新筆高//
BG230:=(BG1
AND HIGH>=HHV(HIGH,BARSLAST(BGQ130)) AND COUNT(BD1,BARSLAST(BGQ130))=0)
OR (BG1 AND
HIGH>=HHV(HIGH,BARSLAST(BGQ130)) AND COUNT(BD1,BARPOS)=0
);
BGDW30:=BACKSET(BG230,BARSLAST(BGQ130));
BG4:=BGDW30 AND REFX(BGDW30,1)=0;
BG5:=BG3 OR
(BG4 AND BARSLAST(BD1)<4) ;
//去掉絕對錯誤低點//
BD6:=(BD5 AND LOW>=REF(HIGH,BARSLAST(BG5))
) ;//最低價大于前筆高//
BD7:=
BD5 AND REFX(HIGH,1)>=REF(HIGH,BARSLAST(BG5))
;//筆低后面一根最高價大于前高//
//DRAWTEXT(BD7,HIGH,'錯誤低點');//
BD:=BD5 AND BD6=0 AND BD7=0;
//去掉絕對錯誤高點//
BG6:=BG5 AND HIGH<=REF(LOW,BARSLAST(BD5));
BG7:=BG5 AND REFX(LOW,1)<=REF(LOW,BARSLAST(BD5))
;
BG:=
BG5 AND BG6=0 AND BG7=0;
//DRAWTEXT(BD5 ,LOW,'低點')COL OR RED;//測試低點//
//DRAWTEXT(BG5,HIGH,'高點')COL OR GREEN;//測試高點//
//DRAWTEXT(BD1 ,LOW,'低點') ;//測試低點//
//DRAWTEXT(BG1,HIGH,'高點') ;//測試高點//
//DRAWTEXT(BD,LOW ,'Y低點');//測試低點//
//DRAWTEXT(BG,HIGH ,'Y高點') ;//測試高點//
JQD:=BARSLAST(BD);//距前低//
JQG:=BARSLAST(BG);//距前高//
//K線包含處理//
//前面頂部左側(cè)K線第1根是否跟前一根重合//
DQBHGG:=(REF(LOW,JQG+1)<=REF(LOW,JQG+2) AND REF(HIGH,JQG+1)>=REF(HIGH,JQG+2)) OR (REF(LOW,JQG+1)>=REF(LOW,JQG+2) AND REF(HIGH,JQG+1)<=REF(HIGH,JQG+2));
//前面底部的左側(cè)第一根K線是否跟前一根重合//
DDQQBBHH:=(REF(LOW,JQD+1)<=REF(LOW,JQD+2) AND REF(HIGH,JQD+1)>=REF(HIGH,JQD+2)) OR (REF(LOW,JQD+1)>=REF(LOW,JQD+2) AND REF(HIGH,JQD+1)<=REF(HIGH,JQD+2));
//當(dāng)前位置左右側(cè)跟前面高點點最高點是否包含判斷//
ADQGYCA:=(REFX(LOW,1)<=REFX(LOW,2) AND REFX(HIGH,1)>=REFX(HIGH,2)) OR (REFX(LOW,1)>=REFX(LOW,2) AND REFX(HIGH,JQG+1)<=REFX(HIGH,2));
KAKDZC:=(REF(LOW,1)<=REF(LOW,2) AND REF(HIGH,1)>=REF(HIGH,2)) OR (REF(LOW,1)>=REF(LOW,2) AND REF(HIGH,JQG+1)<=REF(HIGH,2));
BKDQDYC:=(REFX(LOW,1)<=REFX(LOW,2) AND REFX(HIGH,1)>=REFX(HIGH,2)) OR (REFX(LOW,1)>=REFX(LOW,2) AND REFX(HIGH,JQG+1)<=REFX(HIGH,2));
JKDQDZCA:=(REF(LOW,1)<=REF(LOW,2) AND REF(HIGH,1)>=REF(HIGH,2)) OR (REF(LOW,1)>=REF(LOW,2) AND REF(HIGH,JQG+1)<=REF(HIGH,2));
//包含成立取最大值//
//按前面順序//
DZD:=MIN(REF(HIGH,JQD+1),REF(HIGH,JQD+2));
GZD:=MAX(REF(LOW,JQG+1),REF(LOW,JQG+2));
DQGYC:=MAX(REFX(LOW,1),REFX(LOW,2)
);//當(dāng)前是頂分型,取低點最大值//
DQGZC:=MAX(REF(LOW,1),REF(LOW,2));
DQDYC:=MIN(REFX(HIGH,1),REFX(HIGH,2)
);//當(dāng)前是底分型,取高點最小值//
DQDZC:=MIN(REF(HIGH,1),REF(HIGH,2));
//高低點包含關(guān)系//
BBDQBH:=LOW
//頂分型底分型包含判斷//
BDB:=(BD AND LOWIFELSE(JKDQDZCA,DQDZC,REF(HIGH,1)) AND REF(HIGH,JQG)>IFELSE(BKDQDYC,DQDYC,REFX(HIGH,1))
AND LOW=REF(HIGH,JQG+1)
AND REF(LOW,JQG)<=REF(LOW,JQG+1)),REF(LOW,JQG+2),REF(LOW,JQG+1))
AND LOW=REF(HIGH,JQG-1)
AND REF(LOW,JQG)<=REF(LOW,JQG-1),REF(LOW,JQG-2),REF(LOW,JQG-1))
AND REF(HIGH,JQG)>IFELSE(LOW<=REFX(LOW,1)
AND HIGH>=REFX(HIGH,1)
AND LOW<=REF(LOW,1)
AND HIGH>=REF(HIGH,1),REFX(HIGH,2),REFX(HIGH,1)))
OR (BARSSINCE(BD)=0 AND COUNT(BG
,BARPOS)=0) OR
(BARSSINCE(BD)=0 AND COUNT(BG
,BARPOS)=1 AND BARSLAST(BG)>=4 AND LOW
; //當(dāng)前底分型,最后一句包含缺口情況
AND LOW
BGB:=(BG
AND REF(LOW,JQD)REF(CLOSE,JQD+2)
AND HIGH>IFELSE(DDQQBBHH,DZD,REF(HIGH,JQD+1))
AND REF(LOW,JQD)IFELSE(REF(LOW,JQD)<=REF(LOW,JQD+1)
AND REF(HIGH,JQD)>REF(HIGH,JQD+1),REF(HIGH,JQD+2),REF(HIGH,JQD+1))
AND HIGH>IFELSE(REF(LOW,JQD)<=REF(LOW,JQD-1)
AND REF(HIGH,JQD)>REF(HIGH,JQD-1),REF(HIGH,JQD-2),REF(HIGH,JQD-1))
AND REF(LOW,JQD)=REFX(HIGH,1)
AND LOW<=REFX(LOW,1)
AND HIGH>=REF(HIGH,1)
AND LOW<=REF(LOW,1),REFX(LOW,2),REFX(LOW,1)))
OR (BARSSINCE(BG)=0 AND COUNT(BD
,BARPOS)=0) OR (BARSSINCE(BG)=0 AND COUNT(BD
,BARPOS)=1 AND BARSLAST(BD)>=4 AND HIGH>REF(LOW,BARSLAST(BD)) AND HIGH>REF(HIGH,BARSLAST(BD)-1) AND REF(LOW,1)>REF(LOW,BARSLAST(BD)) AND REFX(LOW,1)>REF(LOW,BARSLAST(BD)))
;//當(dāng)前頂分型,最后一句是包含缺口情況
AND HIGH>REF(HIGH,JQD)//
//DRAWTEXT(BDB,LOW*0.98,'低點')COL OR RED;//測試低點//
//DRAWTEXT(BGB,HIGH,'高點')COL OR GREEN;//測試高點//
//HIGH*1.05;//
//合并同向高低點//
JQD1:=BARSLAST(BDB);//距前低//
JQG1:=BARSLAST(BGB);//距前高//
//筆高前一根//
BBGQ:=(REFX(BGB,1)=1 AND BARSLAST(BDB)>=3
)
OR (REFX(BGB,1)=1 AND COUNT(BDB,BARPOS)=0 AND COUNT(BGB,BARPOS)=0);
//DRAWTEXT(BBGQ ,HIGH,'前')COL OR YELLOW;//測試低點//
BBGQ1:=(BBGQ AND COUNT(BBGQ,BARSLAST(BDB))=1)
OR ( BARSSINCE(BBGQ)=0);
//DRAWTEXT(BBGQ1 ,HIGH*1.05,'第一前')COL OR
CYAN;//測試低點//
//新筆高////合并高點,只合并到距離前低5根K線部分//
GG2:=(BGB AND BARSLAST(BDB)>3 AND HIGH>=HHV(HIGH,BARSLAST(BBGQ1)) AND COUNT(BDB,BARSLAST(BBGQ1))=0);
GG:=BACKSET(GG2,BARSLAST(BBGQ1));
//DRAWTEXT(GG,HIGH,'1')COL OR YELLOW;//測試低點//
//DRAWTEXT((GG AND REFX(GG,1)=0),HIGH*1.03,'二高');//
XZBG1:=BGB AND BARSLAST(BDB)<4
;//保留近高//
ZGD:=((GG AND REFX(GG,1)=0)
OR XZBG1)
OR (GG AND ISLASTBAR)
OR
(BARSSINCE(BGB)=0 AND COUNT(BDB,BARPOS)=0);//獲取特殊高序列//
//新筆低//
//筆低前一根//
BBDQ:=(REFX(BDB,1)=1 AND BARSLAST(BGB)>=3)
OR (REFX(BDB,1)=1 AND COUNT(BDB,BARPOS)=0 AND COUNT(BGB,BARPOS)=0);
BBDQ1:=(BBDQ AND COUNT(BBDQ,BARSLAST(BGB))=1)
OR (
BARSSINCE(BBDQ)=0);
//DRAWTEXT(BBDQ ,LOW*0.98,'前')COL OR
YELLOW;//測試低點//
//DRAWTEXT(BBDQ1,LOW*0.96,'第一前')COL OR
CYAN;//測試低點//
//新BD2//
DD2:=(BDB AND BARSLAST(BGB)>3 AND LOW<=LLV(LOW,BARSLAST(BBDQ1)) AND COUNT(BGB,BARSLAST(BBDQ1))=0);
DD:=BACKSET(DD2,BARSLAST(BBDQ1));
//DRAWTEXT(DD,HIGH,'1');
//DRAWTEXT((DD AND REFX(DD,1)=0),LOW*0.94,'第二低點');//
XZBD1:=BDB AND BARSLAST(BGB)<4;//保留近低//
ZDD:=((DD AND REFX(DD,1)=0) OR XZBD1)
OR (DD AND ISLASTBAR)
OR
(BARSSINCE(BDB)=0 AND COUNT(BGB,BARPOS)=0);//獲取特殊低序列//
//精選點//
//DRAWTEXT(ZGD,HIGH*1.03,'ZGD')COL OR WHITE
DRAWABOVE;
//DRAWTEXT(ZDD,LOW*0.97,'ZDD')COL OR YELLOW
DRAWABOVE;
//DRAWTEXT(BDB,LOW,'P低點')COL OR CYAN DRAWABOVE;
//DRAWTEXT(BGB,HIGH,'P高點')COL OR RED DRAWABOVE;
//定義特征高低點后的,頂分型和底分型//
FXD:=LOW<=REF(LOW,1) AND REFX(LOW,1)>=LOW AND REFX(LOW,2)>=LOW AND REFX(LOW,3)>=LOW
AND REFX(LOW,4)>=LOW
AND REFX(LOW,5)>=LOW
;
//DRAWTEXT(FXD,LOW,'FXD');
//找出特征低點//
TZD:=BACKSET(ZDD AND BARSLAST(ZGD)<4
,BARSLAST(ZGD));//特征低點向前賦值//
TZDD:=(TZD AND REFX(TZD,1)=0)
OR (TZD AND ISLASTBAR);//定位特征低點//
//DRAWTEXT(TZDD,HIGH,'特征低點');//
TZG:=BACKSET(ZGD AND BARSLAST(ZDD)<4
,BARSLAST(ZDD));
TZGG:=(TZG AND REFX(TZG,1)=0)
OR
(TZG AND ISLASTBAR);
ZQGD:=
BARSSINCE(ZGD)=0 AND COUNT(ZDD,BARPOS)=0;
JZD:=(TZDD
AND REF(TZGG,BARSLAST(ZGD))=0
AND REF(REF(TZDD,BARSLAST(ZDD)),1)=0)
OR
(TZDD AND REF(ZQGD,BARSLAST(ZGD)))
;//找出特征低點//
TZDQC:=BACKSET(JZD,BARSLAST(ZGD));//這地方等等再思考//
TZDDDDFZ:=(TZDQC AND REFX(TZDQC,1)=0)
OR
(TZDQC AND ISLASTBAR);
//DRAWTEXT(TZDDDDFZ,LOW*0.98,'去除低點')COL OR MAGENTA
;
//找出符合條件底分型//
JQD9:=BARSLAST(ZDD);//距前低//
JQG9:=BARSLAST(ZGD);//距前高//
//K線包含處理//
//前面頂部左側(cè)K線第1根是否跟前一根重合//
DQBHGG9:=(REF(LOW,JQG9+1)<=REF(LOW,JQG9+2) AND REF(HIGH,JQG9+1)>=REF(HIGH,JQG9+2)) OR (REF(LOW,JQG9+1)>=REF(LOW,JQG9+2) AND REF(HIGH,JQG9+1)<=REF(HIGH,JQG9+2));
//前面底部的左側(cè)第一根K線是否跟前一根重合//
DDQQBBHH9:=(REF(LOW,JQD9+1)<=REF(LOW,JQD9+2) AND REF(HIGH,JQD9+1)>=REF(HIGH,JQD9+2)) OR (REF(LOW,JQD9+1)>=REF(LOW,JQD9+2) AND REF(HIGH,JQD9+1)<=REF(HIGH,JQD9+2));
//當(dāng)前位置左右側(cè)跟前面高點點最高點是否包含判斷//
ADQGYCA9:=(REFX(LOW,1)<=REFX(LOW,2) AND REFX(HIGH,1)>=REFX(HIGH,2)) OR (REFX(LOW,1)>=REFX(LOW,2) AND REFX(HIGH,JQG9+1)<=REFX(HIGH,2));
KAKDZC9:=(REF(LOW,1)<=REF(LOW,2) AND REF(HIGH,1)>=REF(HIGH,2)) OR (REF(LOW,1)>=REF(LOW,2) AND REF(HIGH,JQG9+1)<=REF(HIGH,2));
BKDQDYC9:=(REFX(LOW,1)<=REFX(LOW,2) AND REFX(HIGH,1)>=REFX(HIGH,2)) OR (REFX(LOW,1)>=REFX(LOW,2) AND REFX(HIGH,JQG9+1)<=REFX(HIGH,2));
JKDQDZCA9:=(REF(LOW,1)<=REF(LOW,2) AND REF(HIGH,1)>=REF(HIGH,2)) OR (REF(LOW,1)>=REF(LOW,2) AND REF(HIGH,JQG9+1)<=REF(HIGH,2));
//包含成立取最大值//
//按前面順序//
DZD9:=MIN(REF(HIGH,JQD9+1),REF(HIGH,JQD9+2));
GZD9:=MAX(REF(LOW,JQG9+1),REF(LOW,JQG9+2));
DQGYC9:=MAX(REFX(LOW,1),REFX(LOW,2)
);//當(dāng)前是頂分型,取低點最大值//
DQGZC9:=MAX(REF(LOW,1),REF(LOW,2));
DQDYC9:=MIN(REFX(HIGH,1),REFX(HIGH,2)
);//當(dāng)前是底分型,取高點最小值//
DQDZC9:=MIN(REF(HIGH,1),REF(HIGH,2));
//高低點包含關(guān)系//
BBDQBH9:=LOW
//找出特征低點后符合條件的底分型//
FHFXD:= BARSLAST(ZDD)=4 AND
FXD AND COUNT(ZDD,BARSLAST(ZGD))=1 AND REF(TZDDDDFZ,BARSLAST(ZDD)) AND HIGH
//DRAWTEXT(FHFXD,LOW,'底分型')COL OR RED;
//頂分型底分型包含判斷//
BDB9:=(FHFXD AND LOWIFELSE(JKDQDZCA9,DQDZC9,REF(HIGH,1)) AND REF(HIGH,JQG9)>IFELSE(BKDQDYC9,DQDYC9,REFX(HIGH,1))
AND LOW=REF(HIGH,JQG9+1)
AND REF(LOW,JQG9)<=REF(LOW,JQG9+1)),REF(LOW,JQG9+2),REF(LOW,JQG9+1))
AND LOW=REF(HIGH,JQG9-1)
AND REF(LOW,JQG9)<=REF(LOW,JQG9-1),REF(LOW,JQG9-2),REF(LOW,JQG9-1))
AND REF(HIGH,JQG9)>IFELSE(LOW<=REFX(LOW,1)
AND HIGH>=REFX(HIGH,1)
AND LOW<=REF(LOW,1)
AND HIGH>=REF(HIGH,1),REFX(HIGH,2),REFX(HIGH,1))
); //當(dāng)前底分型,最后一句包含缺口情況
AND LOW
//DRAWTEXT(BDB9,LOW*0.98,'底分型')COL OR YELLOW;
//定位第一個底分型//
//定位底分型左邊一根//
DFXZC1:=REFX(BDB9,1)=1 ;
DFXZC:=DFXZC1 AND COUNT(DFXZC1,BARSLAST(ZGD))=1;
//DRAWTEXT(BARSNEXT(BDB9)=1,LOW,'前')COL OR RED;
//DRAWTEXT(DFXZC,HIGH,'第一前')COL OR GREEN;//
DWDFXZCFZ:=BACKSET(BDB9 AND LOW<=LLV(LOW,BARSLAST(DFXZC)) AND COUNT(ZGD,BARSLAST(DFXZC))=0,BARSLAST(DFXZC));
DWDYZC:=DWDFXZCFZ AND REFX(DWDFXZCFZ,1)=0;
//DRAWTEXT(DWDYZC,LOW*0.95,'Z底分型')COL OR CYAN;//
TZDQCHD1:=((ZDD AND TZDDDDFZ=0) OR DWDYZC)
OR
(DWDFXZCFZ AND ISLASTBAR)
OR
(BARSSINCE(ZDD)=0 AND COUNT(ZGD,BARPOS)=0)
;//特征低去除后低點,產(chǎn)生新低點序列記為TZDQCHD//
//DRAWTEXT(TZDQCHD1,LOW*0.95,'新低序列')COL OR RED;//
//合并低點//
DDQ:=(REFX(TZDQCHD1,1)=1 ) OR
(REFX(TZDQCHD1,1)=1 AND COUNT(ZGD,BARPOS)=0 AND COUNT(TZDQCHD1,BARPOS)=0);
//DRAWTEXT(DDQ,LOW,'前');
DDQ1:=(DDQ AND COUNT(DDQ,BARSLAST(ZGD))=1)
OR (BARSSINCE(DDQ)=0);
//DRAWTEXT(DDQ1,LOW*0.98,'第一前')COL OR CYAN;//
TZDCJDW:=BACKSET(TZDQCHD1 AND LOW<=LLV(LOW,BARSLAST(DDQ1)) AND COUNT(ZGD,BARSLAST(DDQ1))=0,BARSLAST(DDQ1));
//DRAWTEXT(TZDCJDW ,HIGH,'1')COL OR GREEN;//
TZDQCHD:=(TZDCJDW AND REFX(TZDCJDW,1)=0)
OR
(TZDCJDW AND ISLASTBAR);
//驗證//
//DRAWTEXT(TZDQCHD,LOW*0.98,'新低') ;
//合并高點//
GDQQ:=(REFX(ZGD,1)=1 )
OR (REFX(ZGD,1)=1 AND COUNT(ZGD,BARPOS)=0 AND COUNT(TZDQCHD,BARPOS)=0);//高點前一根//
GDQQ1:=(GDQQ AND COUNT(GDQQ,BARSLAST(TZDQCHD))=1)
OR (BARSSINCE(GDQQ)=0);
FZXGD:=BACKSET(ZGD AND HIGH>=HHV(HIGH,BARSLAST(GDQQ1)) AND COUNT(TZDQCHD,BARSLAST(GDQQ1))=0
,BARSLAST(GDQQ1)
);//賦值新高點,合并,修改過,添加COUNT(ZDD,BARSLAST(GDQQ1))=0//
//驗證//
//DRAWTEXT(FZXGD,HIGH,'1');
//DRAWTEXT(GDQQ,HIGH,'前')COL OR MAGENTA;
//DRAWTEXT(GDQQ1,HIGH*0.95,'第一前')COL OR CYAN;//
//合并低點后形成的新高點//
TZDQCHG:=((FZXGD AND REFX(FZXGD,1)=0))
OR
(FZXGD AND ISLASTBAR)
;
//DRAWTEXT(TZDQCHG,HIGH,'新高') ;
//找出特征高點//
TZD1:=BACKSET(TZDQCHD AND BARSLAST(TZDQCHG)<4
,BARSLAST(TZDQCHG));//標(biāo)記特征低點//
TZDD1:=(TZD1 AND REFX(TZD1,1)=0)
OR
(TZD1 AND ISLASTBAR);//區(qū)分特征低點序列//
TZG1:=BACKSET(TZDQCHG AND BARSLAST(TZDQCHD)<4
,BARSLAST(TZDQCHD));//標(biāo)記特征高點//
TZGG1:=(TZG1 AND REFX(TZG1,1)=0)
OR
(TZG1 AND ISLASTBAR);//區(qū)分特征高點序列//
ZQDD:=ZDD AND COUNT(ZGD,BARPOS)=0;//最前低點//
JZG1:=(TZGG1
AND REF(TZDD1,BARSLAST(TZDQCHD))=0
AND REF(REF(TZGG1,BARSLAST(TZDQCHG)),1)=0)
OR (TZGG1 AND REF(ZQDD,BARSLAST(TZDQCHD)));//找出特征高點//
TZGQC1:=BACKSET(JZG1,BARSLAST(TZDQCHD));//去除特征高//
TZGQCFZ:=(TZGQC1 AND REFX(TZGQC1,1)=0)
OR
(TZGQC1 AND ISLASTBAR);//標(biāo)記定位特征高//
//DRAWTEXT(TZGQCFZ,HIGH*1.05,'去除高點')COL OR
MAGENTA;
//定義頂分型//
FXG:= HIGH>=REF(HIGH,1) AND REFX(HIGH,1)<=HIGH;
//找出符合條件底分型//
JQD10:=BARSLAST(TZDQCHD);//距前低//
JQG10:=BARSLAST(TZDQCHG);//距前高//
//K線包含處理//
//前面頂部左側(cè)K線第1根是否跟前一根重合//
DQBHGG10:=(REF(LOW,JQG10+1)<=REF(LOW,JQG10+2) AND REF(HIGH,JQG10+1)>=REF(HIGH,JQG10+2)) OR (REF(LOW,JQG10+1)>=REF(LOW,JQG10+2) AND REF(HIGH,JQG10+1)<=REF(HIGH,JQG10+2));
//前面底部的左側(cè)第一根K線是否跟前一根重合//
DDQQBBHH10:=(REF(LOW,JQD10+1)<=REF(LOW,JQD10+2) AND REF(HIGH,JQD10+1)>=REF(HIGH,JQD10+2)) OR (REF(LOW,JQD10+1)>=REF(LOW,JQD10+2) AND REF(HIGH,JQD10+1)<=REF(HIGH,JQD10+2));
//當(dāng)前位置左右側(cè)跟前面高點點最高點是否包含判斷//
ADQGYCA10:=(REFX(LOW,1)<=REFX(LOW,2) AND REFX(HIGH,1)>=REFX(HIGH,2)) OR (REFX(LOW,1)>=REFX(LOW,2) AND REFX(HIGH,JQG10+1)<=REFX(HIGH,2));
KAKDZC10:=(REF(LOW,1)<=REF(LOW,2) AND REF(HIGH,1)>=REF(HIGH,2)) OR (REF(LOW,1)>=REF(LOW,2) AND REF(HIGH,JQG10+1)<=REF(HIGH,2));
BKDQDYC10:=(REFX(LOW,1)<=REFX(LOW,2) AND REFX(HIGH,1)>=REFX(HIGH,2)) OR (REFX(LOW,1)>=REFX(LOW,2) AND REFX(HIGH,JQG10+1)<=REFX(HIGH,2));
JKDQDZCA10:=(REF(LOW,1)<=REF(LOW,2) AND REF(HIGH,1)>=REF(HIGH,2)) OR (REF(LOW,1)>=REF(LOW,2) AND REF(HIGH,JQG10+1)<=REF(HIGH,2));
//包含成立取最大值//
//按前面順序//
DZD10:=MIN(REF(HIGH,JQD10+1),REF(HIGH,JQD10+2));
GZD10:=MAX(REF(LOW,JQG10+1),REF(LOW,JQG10+2));
DQGYC10:=MAX(REFX(LOW,1),REFX(LOW,2)
);//當(dāng)前是頂分型,取低點最大值//
DQGZC10:=MAX(REF(LOW,1),REF(LOW,2));
DQDYC10:=MIN(REFX(HIGH,1),REFX(HIGH,2)
);//當(dāng)前是底分型,取高點最小值//
DQDZC10:=MIN(REF(HIGH,1),REF(HIGH,2));
//高低點包含關(guān)系//
BBDQBH10:=LOW
//找出特征高點后符合條件的頂分型//
FHFXG:=
BARSLAST(TZDQCHD)>BARSLAST(TZDQCHG) AND BARSLAST(TZDQCHD)>=4 AND
FXG AND COUNT(TZDQCHG,BARSLAST(TZDQCHD))=1
AND REF(TZGQCFZ,BARSLAST(TZDQCHG)) AND HIGH>REF(HIGH,BARSLAST(TZDQCHD));
//DRAWTEXT(FHFXG,HIGH*1.03,'頂分型')COL OR YELLOW;
//頂分型底分型包含判斷//
BGB10:=(FHFXG AND HIGH>IFELSE(DDQQBBHH10,DZD10,REF(HIGH,JQD10+1)) AND REF(LOW,JQD10)REF(CLOSE,JQD10+2)
AND HIGH>IFELSE(REF(LOW,JQD10)<=REF(LOW,JQD10+1)
AND REF(HIGH,JQD10)>REF(HIGH,JQD10+1),REF(HIGH,JQD10+2),REF(HIGH,JQD10+1))
AND HIGH>IFELSE(REF(LOW,JQD10)<=REF(LOW,JQD10-1)
AND REF(HIGH,JQD10)>REF(HIGH,JQD10-1),REF(HIGH,JQD10-2),REF(HIGH,JQD10-1))
AND REF(LOW,JQD10)=REFX(HIGH,1)
AND LOW<=REFX(LOW,1)
AND HIGH>=REF(HIGH,1)
AND LOW<=REF(LOW,1),REFX(LOW,2),REFX(LOW,1)));//當(dāng)前頂分型,最后一句是包含缺口情況
AND HIGH>REF(HIGH,JQD)//
//DRAWTEXT(BGB10,HIGH,'頂分型')COL OR RED;//
//定位頂分型左邊一根//
GFXZC1:=REFX(BGB10,1)=1;
GFXZC:=GFXZC1 AND COUNT(GFXZC1,BARSLAST(TZDQCHG))=1;
//賦值第一個CFXZC//
//DRAWTEXT(BARSNEXT(BGB10)=1 ,LOW,'前')COL OR RED;
//DRAWTEXT(GFXZC,HIGH,'第一前')COL OR GREEN;//
DWGFXZCFZ:=BACKSET(BGB10 AND HIGH>=HHV(HIGH,BARSLAST(GFXZC)) AND COUNT(TZDQCHD,BARSLAST(GFXZC))=0,BARSLAST(GFXZC));
//DRAWTEXT(DWGFXZCFZ,HIGH,'1');//
DWDYGZC:=(DWGFXZCFZ AND REFX(DWGFXZCFZ,1)=0)
OR
(DWGFXZCFZ AND ISLASTBAR);
//DRAWTEXT(DWDYGZC,HIGH*1.03,'Z頂分型')COL OR CYAN;//
TZGQCHGG1:=((TZDQCHG AND TZGQCFZ=0)
OR DWDYGZC)
OR (BARSSINCE(ZGD)=0 AND COUNT(TZDQCHD,BARPOS)=0);//特征高去除后低點,產(chǎn)生新高點序列記為TZGQCHG1//;
//驗證//
//DRAWTEXT(TZDQCHG AND TZGQCFZ=0,HIGH,'高點')COL
OR MAGENTA;//
//合并高點//
ZZGQ:=REFX(TZGQCHGG1,1)=1;
ZZGQ1:=(ZZGQ AND COUNT(ZZGQ,BARSLAST(TZDQCHD))=1)
OR (BARSSINCE(ZZGQ)=0);
TZGDZZFZ:=BACKSET(TZGQCHGG1 AND HIGH>=HHV(HIGH,BARSLAST(ZZGQ1)) AND COUNT(TZDQCHD,BARSLAST(ZZGQ1))=0,BARSLAST(ZZGQ1));
//驗證//
//DRAWTEXT(ZZGQ,HIGH,'前')COL OR MAGENTA;
//DRAWTEXT(ZZGQ1,HIGH*0.95,'第一前')COL OR CYAN;//
TZGQCHG1:=(TZGDZZFZ AND REFX(TZGDZZFZ,1)=0)
OR
(TZGDZZFZ AND ISLASTBAR)
OR
(BARSSINCE(TZGQCHGG1)=0 AND COUNT(TZDQCHD,BARPOS)=0);
//最新高//
//DRAWTEXT(TZGQCHG1,HIGH*0.98,'新高')COL OR
MAGENTA;//
//合并低點//
ZZDDQ:=REFX(TZDQCHD,1)=1;//相對上一新高點,合并低點,定義新低點//
ZZDDQ1:=(ZZDDQ AND COUNT(ZZDDQ,BARSLAST(TZGQCHG1))=1)
OR (BARSSINCE(ZZDDQ)=0);
FZXDD1:=BACKSET(TZDQCHD AND LOW<=LLV(LOW,BARSLAST(ZZDDQ1)) AND
COUNT(TZGQCHG1,BARSLAST(ZZDDQ1))=0
,BARSLAST(ZZDDQ1));//賦值新高點,合并//
//驗證//
//DRAWTEXT(ZZDDQ,HIGH,'前')COL OR MAGENTA;
//DRAWTEXT(ZZDDQ1,HIGH*0.95,'第一前')COL OR CYAN;//
TZGQCHD1:=(FZXDD1 AND REFX(FZXDD1,1)=0)
OR
(FZXDD1 AND ISLASTBAR)
OR
(BARSSINCE(TZDQCHD)=0 AND COUNT(TZGQCHG1,BARPOS)=0);//合并低點后形成的新低點//
//再次去除特征高低點//
BBD:=TZGQCHD1;
BBG:=TZGQCHG1;
C1:=BBG OR BBD;
POLYLINE( C1,IFELSE(BBD,LOW,HIGH) , IFELSE(BBD,COLORRED,
COLORGREEN) ) ,POINTDOT;
|