從源碼中提取選股公式
口訣:從后往前找,刪除沒用條,去掉修飾符,個別加等號。
例一:找出買點
VAR1:=(((HHV(HIGH,36) - CLOSE) / (HHV(HIGH,36) - LLV(LOW,36))) * 100);
VAR2:=SMA(VAR1,5,1);
VAR3:=SMA(VAR2,8,1);
H1:EMA(CLOSE,8),LINETHICK1;
H2:EMA(H1,20),LINETHICK1;
VAR4:=(CROSS(VAR2,VAR3) AND (VAR3 < 20));
VAR5:=((CLOSE > (LLV(CLOSE,60) + (0.3 * LLV(CLOSE,60)))) AND VAR4);
VAR6:=IF((CLOSE > 1000),VAR4,VAR5);
M1:EMA(CLOSE,60);
M2:EMA(CLOSE,89);
M3:EMA(CLOSE,233),LINETHICK1;
M4:EMA(CLOSE,583),LINETHICK1;
STICKLINE((H1 > H2),H1,H2,1,0.8);
STICKLINE((H1 < H2),H1,H2,1,0.8);
DRAWTEXT((CROSS(H1,H2) AND (CLOSE < EMA(CLOSE,60))),(LOW * 0.92),'買');
DRAWTEXT(VAR6,(HIGH * 1.08),'賣');
分解說明:
VAR1:=(((HHV(HIGH,36) - CLOSE) / (HHV(HIGH,36) - LLV(LOW,36))) * 100);
VAR2:=SMA(VAR1,5,1);
VAR3:=SMA(VAR2,8,1);
H1:EMA(CLOSE,8),LINETHICK1;
H2:EMA(H1,20),LINETHICK1;
VAR4:=(CROSS(VAR2,VAR3) AND (VAR3 < 20));
VAR5:=((CLOSE > (LLV(CLOSE,60) + (0.3 * LLV(CLOSE,60)))) AND VAR4);
VAR6:=IF((CLOSE > 1000),VAR4,VAR5);
M1:EMA(CLOSE,60);
M2:EMA(CLOSE,89);
M3:EMA(CLOSE,233),LINETHICK1;
M4:EMA(CLOSE,583),LINETHICK1;
STICKLINE((H1 > H2),H1,H2,1,0.8);
STICKLINE((H1 < H2),H1,H2,1,0.8);
第一步{從后往前找}找到下面這行“買”的輸出語句。然后看這條語句的基本條件。
DRAWTEXT((CROSS(H1,H2) AND (CLOSE < EMA(CLOSE,60))),(LOW * 0.92),'買');
查看結(jié)果:輸出文字 交叉 條件,條件 直 接 輸 出 語 句 輸出位置 文字
DRAWTEXT(VAR6,(HIGH * 1.08),'賣');
知道“基本條件”為 H1,H2,那么與此沒有任何關(guān)系的語句從后往前刪除。刪的辦法有兩種:一是直接刪掉;二是先用{}括上,待沒問題時再一次性刪除。加藍色的為找到的不輸出語句。
第二步{刪除沒用條}后,剩下的有用語句:
H1:EMA(CLOSE,8),LINETHICK1;。铀{的為修飾類函數(shù),原則一律刪除。}
H2:EMA(H1,20),LINETHICK1;
DRAWTEXT((CROSS(H1,H2) AND (CLOSE < EMA(CLOSE,60))),(LOW * 0.92),'買');
第三步{去掉修飾符} 分別去掉:指標(biāo)線粗細、顯示文字、文字位置函數(shù)和文字
H1:EMA(CLOSE,8);
H2:EMA(H1,20);
CROSS(H1,H2) AND CLOSE < EMA(CLOSE,60);
第四步{個別加等號} 條件選股只能輸出一條語句,上面這三行為全部輸出,所以,作為“條件”的前兩行還必須在冒號后面加上等號,表達不輸出。結(jié)果:
H1:=EMA(CLOSE,8);
H2:=EMA(H1,20);
CROSS(H1,H2) AND CLOSE < EMA(CLOSE,60);
例二、找出笑臉和買入信號
以本人發(fā)過的《跟莊建倉》為例。
A01:=DYNAINFO(7);
A03:=BARSCOUNT(CLOSE);
A04:=(SMA((CLOSE / HHV(HIGH,120)),3,1) * 100);
A05:=IF((A03 > 20),A04,0);
A06:=IF((LOW > A01),0,IF((HIGH < A01),1,(((A01 - LOW) + 0.009) / ((HIGH - LOW) + 0.009))));
A07:=DMA(A06,(VOL / CAPITAL)) * 60;
A09:=IF((((A07 > 0) AND (A07 > REF(A07,1))) AND (A05 <= 88)),A07,0);
Var1:=3*SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1)-2*SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1);
Var2:=EMA(Var1,8);
Var3:=3*SMA((C-LLV(L,55))/(HHV(H,55)-LLV(L,55))*100,5,1)-2*SMA(SMA((C-LLV(L,55))/(HHV(H,55)-LLV(L,55))*100,5,1),3,1);
趨勢:=EMA(Var3,3)-10;
FILLRGN(趨勢>80,趨勢,80);
DRAWICON(CROSS(趨勢,0),0,1);
FILLRGN((A09 > 0 AND (趨勢<20 OR 趨勢>REF(趨勢,1)AND 趨勢<50)),0,A09),colorFFFF00;
機構(gòu)建倉區(qū):0,LINETHICK0,colorFFFF00;
Var4:=(趨勢-REF(趨勢,1))/REF(趨勢,1)*100;
STICKLINE(趨勢<=13,0,20,5,0),colorcc9900;
DRAWTEXT(FILTER(趨勢<=13,15),30,'準備現(xiàn)金'),colorcc9900;
STICKLINE(趨勢<=13 AND Var4>13,0,50,5,0),color0099ff;
Var5:=FILTER((趨勢<=13 AND Var4>13),10);
DRAWTEXT(Var5,60,'買入'),color0099ff;
STICKLINE(趨勢>=90 AND Var4,0,30,5,0),colorgray;
Var6:=FILTER(趨勢>=90,10);
DRAWTEXT(Var6,40,'清倉'),colorgray;
Var7:=LLV(LOW,30);
Var8:=HHV(HIGH,30);
Var9:=EMA((CLOSE-Var7)/(Var8-Var7)*4,4)*25;
STICKLINE(Var9>90,100,105,10,2),COLORRED;
STICKLINE(CROSS(Var4,-40),10,55,6,0),COLORRED;
Var10:=(Var9-LLV(Var9,4))/(HHV(Var9,4)-LLV(Var9,4))*100;
DRAWTEXT(IF(CROSS(Var9,Var10) AND Var9>87,95,0),88,'險'),Color00FF00,ALIGN1;
DRAWICON(CROSS(90,Var9),95,9);
Var11:=SMA(ABS(L-REF(L,1)),3,1)/SMA(MAX(L-REF(L,1),0),3,1)*100;
Var12:=HHV(Var11,30)*8;
火焰山:EMA(IF(LOW<=Var7 AND 趨勢<40,(Var11+Var12),0),3)/618,COLORRED,linethick2;
STICKLINE(火焰山>0,0 ,火焰山*1.2,8,0 ),COLORRED;
Var13:=(MA(C,1)+MA(C,3)+MA(C,5)+MA(C,7)+MA(C,9))/5;
Var14:=(MA(C,2)+MA(C,4)+MA(C,6)+MA(C,8)+MA(C,10))/5;
趨勢線: 趨勢,colorff0000;
Var16:=MAX(EMA(Var13,2)-EMA(Var14,5),0)*200;
Var17:=EMA(Var16,5);
波浪峰:Var17,stick,colorff00ff;
STICKLINE(Var17<REF(Var17,1),0,Var17,1,0),color00ff00;
Var18:=MA(趨勢線,8);
if(CROSS(Var2,Var18) AND Var2<15,50,0),COLORRED;
DRAWTEXT(CROSS(趨勢線,Var2)AND 趨勢線>REF(趨勢線,1)AND 趨勢線<50,50,'追漲'),COLORFF0000;
(責(zé)任編輯:張曉軒)