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;
机构建仓区:0,LINETHICK0,colorFFFF00;
Var4:=(趋势-REF(趋势,1))/REF(趋势,1)*100; STICKLINE(趋势<=13,0,20,5,0),colorcc9900;
DRAWTEXT(FILTER(趋势<=13,15),30,'准备现金'),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 <40,(Var11+Var12),0),3)/618,COLORRED,linethick2;
AND
趋
势险
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(Var17if(CROSS(Var2,Var18) AND Var2<15,50,0),COLORRED;
DRAWTEXT(CROSS(趋势线,Var2)AND 趋势线>REF(趋势线,1)AND 趋势线<50,50,'追涨'),COLORFF0000;
分析:这个公式输出语句非常多,但多数都是用于趋势判断的。所以不用管它。仍按我们既定的思路进行。
第一步{从后往前找},先删除发出信号关键语句之后的(红色为输出语句,它以下的语句已经删去,蓝色为等待下步删除的) 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;
机构建仓区:0,LINETHICK0,colorFFFF00; Var4:=(趋势-REF(趋势,1))/REF(趋势,1)*100; STICKLINE(趋势<=13,0,20,5,0),colorcc9900;
DRAWTEXT(FILTER(趋势<=13,15),30,'准备现金'),colorcc9900; STICKLINE(趋势<=13 AND Var4>13,0,50,5,0),color0099ff; Var5:=FILTER((趋势<=13 AND Var4>13),10);
DRAWTEXT(Var5,60,'买入'),color0099ff;
第二步{删除没用条}后
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;
DRAWICON(CROSS(趋势,0),0,1);
Var4:=(趋势-REF(趋势,1))/REF(趋势,1)*100; Var5:=FILTER((趋势<=13 AND Var4>13),10); DRAWTEXT(Var5,60,'买入'),color0099ff;
第三步{去掉修饰符后}: 趋势:=EMA(Var3,3)-10; CROSS(趋势,0);
Var4:=(趋势-REF(趋势,1))/REF(趋势,1)*100; Var5:=FILTER((趋势<=13 AND Var4>13),10);
Var5;
第四步{个别加等号}本公式中的“条件”语句都是不输出的,所以此项省略,但因是要笑脸和买入两个信号,所以还必须把它们连结起来:
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;
Var4:=(趋势-REF(趋势,1))/REF(趋势,1)*100; Var5:=FILTER((趋势<=13 AND Var4>13),10); CROSS(趋势,0)or Var5;
第九讲 函数的综合运用
第一部分:引用已有公式中的数据 基本引用例一
\ diff\ \
基本格式: 指标名称 语句名称 (注意:必须用双引号引上) 加入参数例二
\ k\ (9,3,3) ;
基本格式:指标名称 语句名称 参数 (指标名称和语句名称之间用隔点.隔开) 加入参数例三
周m:\ diff #WEEK\
引用周线:指标名称 语句名称 周函数 (注意:周函数前加#字号) 月K:\
引用月线同上,只是换成月函数。 -
应用实例:主图 顶底背离
A1:=BARSLAST(ref(cross(\
B1:=ref(c,A1+1)>c and ref(\and cross(\
MACD底背离:STICKLINE(FILTER(B1>0,5),0,0.75,3,0),COLOR00FF00; DRAWTEXT(FILTER(B1>0,5),0.57,'MACD底背离'),COLOR00FF00; A2:=BARSLAST(ref(cross(\B2:=ref(c,A2+1)>c
and
ref(\
and
cross(\
KDJ底背离:STICKLINE(FILTER(B2>0,5),0,1,3,0),COLORYELLOW; DRAWTEXT(FILTER(B2>0,5),0.80,'KDJ底背离'),COLORYELLOW; A3:=BARSLAST(ref(cross(\
B3:=ref(c,A3+1)>c and ref(\and cross(\
RSI底背离:STICKLINE(FILTER(B3>0,5),0,0.5,3,0),COLORFFCC66; DRAWTEXT(FILTER(B3>0,5),0.25,'RSI底背离'),COLORFFCC66; DRAWTEXT(FILTER(D1>0,5),1.47,'MACD顶背离'),COLOR0066FF; C2:=BARSLAST(ref(cross(\
D2:=ref(c,C2+1)\KDJ顶背离:STICKLINE(FILTER(D2>0,5),2,1,3,0),COLORRED; DRAWTEXT(FILTER(D2>0,5),1.2,'KDJ顶背离'),COLORRED;
C3:=BARSLAST(ref(cross(\D3:=ref(c,C3+1)\
cross(\
RSI顶背离:STICKLINE(FILTER(D3>0,5),2,1.5,3,0),COLORFF00FF; DRAWTEXT(FILTER(D3>0,5),1.75,'RSI顶背离'),COLORFF00FF;
第二部分 逐步增加函数 以均线为例,主图: 基本句型 MA5:MA(C,5); MA10:MA(C,10); MA30:MA(C,30);
MA60:MA(C,60);
增加颜色(注:在没有颜色输出符号时,系统会自动加上颜色) MA5:MA(C,5),COLORBLUE; MA10:MA(C,10),COLORF00FF0;
and