股友量 发表于 2021-12-27 17:07

指标编写问答35学习的宝藏

176.问:
      怎样把飞狐指标叠加.如macd和kdj
   答(懒汉):
      k:"kdj.k",COLORWHITE;
      d:"kdj.d",COLORYELLOW;
      j:"kdj.j",COLORGREEN;
   {以上为a指标,显示数值和画线.其数值和副图右侧的坐标对应}

      diff:"macd.diff",LINETHICK0,COLORCYAN;
      dea:"macd.dea",LINETHICK0,COLORRED;
      macd:"macd.macd",LINETHICK0,COLORMAGENTA;
   {以上为b指标,只显示数值,不画线.其数值和副图右侧的坐标不对应}

   {以下规定叠加区域-这里是显示区域}
       p:=SYSPARAM(3)-SYSPARAM(2);
       q:=SYSPARAM(3);
   {以下计算叠加比和平移量}
       ha:=hhv(max(max(k,ad),j),p);//显示区域内a指标最大值
       La:=LLv(min(min(k,d),j),p);//显示区域内a指标最小值
       hb:=hhv(max(max(diff,dea),macd),p);//显示区域内b指标最大值
       Lb:=LLv(min(min(diff,dea),macd),p);//显示区域内b指标最小值
       b:=(ha-La)/(hb-Lb);//叠加比
       y:=(ha+La-(hb+Lb)*b)/2;//平移量
   {以下画b指标的叠加线}
       PARTLINE(1,diff*b+y),COLORCYAN;//画b1线
       PARTLINE(1,dea*b+y),COLORRED;//画b2线
       STICKLINE(b3<0,macd*b+y,y,0.1,0),COLORBLUE;//画b3的下竖线
       STICKLINE(b3>0,macd*b+y,y,0.1,0),COLORMAGENTA;//画b3的上竖线

QUOTE:
177.问:
       以大盘MACD为背景条件的公式怎样写
   答(kjyhao):
      这是以大盘MACD为背景的主图
       aa:=INDEXC;
       DIFF:=EMA(AA,12) - EMA(AA,26);
       DEA :=EMA(DIFF,9);
       MACD:=2*(DIFF-DEA);
       xma1:=MACD;xma2:=0;
       xtj1:=CROSS(xma1,xma2) or xma1>xma2;
       xtj2:=CROSS(xma2,xma1) or xma1<xma2;
       FILLRGN(xtj1,SYSPARAM(5),SYSPARAM(4)),ColorDB3FCA;
       FILLRGN(xtj2,SYSPARAM(5),SYSPARAM(4)),Color528608;
       ktj:=(CLOSE>OPEN or CLOSE=OPEN and CLOSE>REF(CLOSE,1));
       STICKLINE(ktj,HIGH,LOW,0.1,1),colorred;
       STICKLINE(ktj,CLOSE,OPEN,7,1),colorred;
       STICKLINE(NOT(ktj),HIGH,LOW,0.1,0),colorcyan;
       STICKLINE(NOT(ktj),CLOSE,OPEN,7,0),colorcyan;
       ma5:MA(CLOSE,5);
       ma10:MA(CLOSE,10);
       ma20:MA(CLOSE,20);
       ma30:MA(CLOSE,30);
       aa:=sumbars(vol,capital);
       平均成本:sum(v*c,aa)/sum(v,aa),linethick1;   



178.问:
      能显示MACD,KDJ,RSI周线,月线金叉的指标(源码),最好可选股的
    答(yyzzqq):
      MACD周线金叉 cross( "macd.macd#week",0);
         月线金叉 cross( "macd.macd#month",0);
      KDJ周线金叉 cross( "kd.k#week","kd.d#week");
         月线金叉 cross( "kd.k#month","kd.d#month");
      RSI周线金叉 cross( "RSI.RSI1#week","RSI.RSI2#week");
         月线金叉 cross("RSI.RSI1#month","RSI.RSI2#month");



179.问:
   怎么指示今天的收盘价是在几日收盘价中的最高?
   比如说,我在K线图中看出今天收盘价是15日内收盘价的最高,这个15日用公式怎么求出来?
   答(馨芸):
      试试
       hac:=0;
       att1:=hac;
       att2:=hac;
       attc:=hac;
       fc:=c*1;
       attc:=fc;
       att1:=1;
       for i=datacount-1 downto datacount-200 do
       begin
            iffc<attc and att2=0 then att1:=att1+1;
            iffc>attc then att2:=1;;
      end;
       n:att1;   
   答(懒汉):
       也可这样
       cc:=if(barscount(c)=1,999999,c);
       sumbars(ref(cc,1)-cc,0)-1;



180.问:
      请优化 飞狐的·实战看盘
       Var1:=MA(100*(CLOSE-LLV(CLOSE,34))/(HHV(HIGH,34)-LLV(LOW,34)),5)-20;
       Var2:=2*ABS(Var1);
       Var3:=100-(100-3*SMA((CLOSE-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1)+2*SMA(SMA((CLOSE-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1),15,1));
       Var4:=100-(100-3*SMA((OPEN-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1)+2*SMA(SMA((OPEN-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1),15,1));
       Var5:=(HIGH+LOW+CLOSE)/3;
       Var6:=(Var5-MA(Var5,10))/(0.015*AVEDEV(Var5,10));
       Var7:=(Var5-MA(Var5,30))/(0.015*AVEDEV(Var5,30));
       Var8:=IF(Var6>=150 AND Var6<200 AND Var7>=150 AND Var7<200,10,0);
       Var9:=IF(Var6<=-150 AND Var6>-200 AND Var7<=-150 AND Var7>-200,-10,Var8);
       VarA:=(CLOSE-MA(CLOSE,13))/MA(CLOSE,13)*100;
       VarB:=100-ABS(VarA);
       VarC:=3*SMA((INDEXC-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,55))*100,20,1)-2
      *SMA(SMA((INDEXC-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,55))*100,20,1),15,1);
       VarD:=3*SMA((INDEXO-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,55))
      *100,20,1)-2*SMA(SMA((INDEXO-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,5
       5))*100,20,1),15,1);
       VarE:=REF(LOW,1)*0.9;
       VarF:=LOW*0.9;
       Var10:=(VarF*VOL+VarE*(CAPITAL-VOL))/CAPITAL;
       Var11:=EMA(Var10,30);
       Var12:=Var11-CLOSE;
       Var13:=REF(CLOSE,1);
       Var14:=SMA(MAX(CLOSE-Var13,0),7,1)/SMA(ABS(CLOSE-Var13),7,1)*100;
       Var15:=SMA(MAX(CLOSE-Var13,0),13,1)/SMA(ABS(CLOSE-Var13),13,1)*100;
       Var16:=BARSCOUNT(CLOSE);
       Var17:=SMA(MAX(CLOSE-REF(CLOSE,1),0),6,1)/SMA(ABS(CLOSE-REF(CLOSE,1)),6,1)*100;
       Var18:=((-100)*(HHV(HIGH,60)-CLOSE)/(HHV(HIGH,60)-LLV(LOW,60))+50)*2;
       Var19:=(CLOSE-LLV(LOW,15))/(HHV(HIGH,15)-LLV(LOW,15))*100;
       Var1A:=(SMA(Var19,4,1)-50)*2;
       Var1B:=SMA(Var1A,3,1);
       Var1C:=(INDEXC-LLV(INDEXL,14))/(HHV(INDEXH,14)-LLV(INDEXL,14))*100;
       Var1D:=SMA(Var1C,4,1);
       Var1E:=SMA(Var1D,3,1);
       Var1F:=(HHV(HIGH,30)-CLOSE)/CLOSE*100;
       Var20:=IF(Var17<=25 AND Var18<-95 AND Var1F>20 AND Var1B<-30 AND Var1E<30
         AND Var12>=-0.25 AND Var14<22 AND Var15<28 AND Var16>50,80,0);
       大趋势: Var3,colorblack;
       顶线: IF(VarB<90,VarB,100);
       多方: IF(Var1>0,Var1,0), LINESTICK;
       空方: -IF(Var1<0,Var2,0), LINESTICK;
       抄底: Var20,colorred,linethick2;
       预警系统: (IF((Var7>=200 AND Var6>=150) OR CROSS(65,多方),15,IF(Var7<=-200
         AND Var6<=-150,-15,Var9))+65),COLORCYAN,;
       STICKLINE(Var3<=REF(Var4,1),Var3,Var4,8,0),colorwhite;
       STICKLINE(Var3>REF(Var4,1),Var3,Var4,8,0),colorred;
       t1:=CLOSE>MA(CLOSE,20) AND MA(CLOSE,20)>=REF(MA(CLOSE,20),1);
       t2:=CLOSE<MA(CLOSE,20) AND MA(CLOSE,20)<REF(MA(CLOSE,20),1);
       t3:=多方>60 AND 预警系统>65 AND 顶线=100;
       t4:=多方>48 AND 预警系统>65 AND 顶线<100;
       t5:=空方<-38 AND 预警系统<65;
       t6:=抄底>50 AND 顶线<90;
       t7:=Var3>REF(Var4,1) AND VOL>REF(VOL,1) AND CLOSE>REF(CLOSE,1);
       t8:=Var3<=REF(Var4,1) AND CLOSE<REF(CLOSE,1) AND 预警系统=65 AND 抄底=0
      AND 空方>=REF(空方,1) AND VarC<REF(VarD,1);
       DRAWTEXT(t1 and count(t1,30)=1,10,\'上升通道!\'),COLOR00FFFF;//这行不能引入
       B2:=DRAWTEXT(t2 and count(t2,30)=1,55,\'下降通道!\'),COLOR00FFFF;//这行不能引入
       B3:=DRAWTEXT(t3 and count(t3,30)=1,55,\'上涨过急!\'),COLOR00FFFF;//这行不能引入
       B4:=DRAWTEXT(t4 and count(t4,30)=1,75,\'庄家出货!\'),COLOR00FFFF;//这行不能引入
       B5:=DRAWTEXT(t5 and count(t5,30)=1,50,\'有小反弹!\'),COLOR00FFFF;//这行不能引入
       B6:=DRAWTEXT(t6 and count(t6,30)=1,30,\'抢反弹!\'),COLOR00FFFF;//这行不能引入
       B7:=DRAWTEXT(t7 and count(t7,30)=1,-10,\'资金进场!\'),COLOR00FFFF;//这行不能引入
       DRAWTEXT(t8 and count(t8,30)=1,90,\'见顶回落!\'),COLOR00FFFF;//这行不能引入
   答(asghk):
       “实战看盘”指标!
       Var1:=MA(100*(CLOSE-LLV(CLOSE,34))/(HHV(HIGH,34)-LLV(LOW,34)),5)-20;
       Var2:=2*ABS(Var1);
       Var3:=100-(100-3*SMA((CLOSE-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1)+2*SMA(SMA((CLOSE-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1),15,1));
       Var4:=100-(100-3*SMA((OPEN-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1)+2*SMA(SMA((OPEN-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))
      *100,20,1),15,1));
       Var5:=(HIGH+LOW+CLOSE)/3;
       Var6:=(Var5-MA(Var5,10))/(0.015*AVEDEV(Var5,10));
       Var7:=(Var5-MA(Var5,30))/(0.015*AVEDEV(Var5,30));
       Var8:=IF(Var6>=150 AND Var6<200 AND Var7>=150 AND Var7<200,10,0);
       Var9:=IF(Var6<=-150 AND Var6>-200 AND Var7<=-150 AND Var7>-200,-10,Var8);
       VarA:=(CLOSE-MA(CLOSE,13))/MA(CLOSE,13)*100;
       VarB:=100-ABS(VarA);
       VarC:=3*SMA((INDEXC-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,55))*100,20,1)-2
      *SMA(SMA((INDEXC-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,55))*100,20,1),15,1);
       VarD:=3*SMA((INDEXO-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,55))
      *100,20,1)-2*SMA(SMA((INDEXO-LLV(INDEXL,55))/(HHV(INDEXH,55)-LLV(INDEXL,5
      5)) *100,20,1),15,1);
       VarE:=REF(LOW,1)*0.9;
       VarF:=LOW*0.9;
       Var10:=(VarF*VOL+VarE*(CAPITAL-VOL))/CAPITAL;
       Var11:=EMA(Var10,30);
       Var12:=Var11-CLOSE;
       Var13:=REF(CLOSE,1);
       Var14:=SMA(MAX(CLOSE-Var13,0),7,1)/SMA(ABS(CLOSE-Var13),7,1)*100;
       Var15:=SMA(MAX(CLOSE-Var13,0),13,1)/SMA(ABS(CLOSE-Var13),13,1)*100;
       Var16:=BARSCOUNT(CLOSE);
       Var17:=SMA(MAX(CLOSE-REF(CLOSE,1),0),6,1)/SMA(ABS(CLOSE-REF(CLOSE,1)),6,1)*100;
       Var18:=((-100)*(HHV(HIGH,60)-CLOSE)/(HHV(HIGH,60)-LLV(LOW,60))+50)*2;
       Var19:=(CLOSE-LLV(LOW,15))/(HHV(HIGH,15)-LLV(LOW,15))*100;
       Var1A:=(SMA(Var19,4,1)-50)*2;
       Var1B:=SMA(Var1A,3,1);
       Var1C:=(INDEXC-LLV(INDEXL,14))/(HHV(INDEXH,14)-LLV(INDEXL,14))*100;
       Var1D:=SMA(Var1C,4,1);
       Var1E:=SMA(Var1D,3,1);
       Var1F:=(HHV(HIGH,30)-CLOSE)/CLOSE*100;
       Var20:=IF(Var17<=25 AND Var18<-95 AND Var1F>20 AND Var1B<-30 AND Var1E<30
      AND Var12>=-0.25 AND Var14<22 AND Var15<28 AND Var16>50,80,0);
       大趋势: Var3,colorblack;
       顶线: IF(VarB<90,VarB,100);
       多方: IF(Var1>0,Var1,0), LINESTICK;
       空方: -IF(Var1<0,Var2,0), LINESTICK;
       抄底: Var20,colorred,linethick2;
       预警系统: (IF((Var7>=200 AND Var6>=150) OR CROSS(65,多方),15,IF(Var7<=-200
      AND Var6<=-150,-15,Var9))+65),COLORCYAN;
       STICKLINE(Var3<=REF(Var4,1),Var3,Var4,8,0),colorwhite;
       STICKLINE(Var3>REF(Var4,1),Var3,Var4,8,0),colorred;
       t1:=CLOSE>MA(CLOSE,20) AND MA(CLOSE,20)>=REF(MA(CLOSE,20),1);
       t2:=CLOSE<MA(CLOSE,20) AND MA(CLOSE,20)<REF(MA(CLOSE,20),1);
       t3:=多方>60 AND 预警系统>65 AND 顶线=100;
       t4:=多方>48 AND 预警系统>65 AND 顶线<100;
       t5:=空方<-38 AND 预警系统<65;
       t6:=抄底>50 AND 顶线<90;
       t7:=Var3>REF(Var4,1) AND VOL>REF(VOL,1) AND CLOSE>REF(CLOSE,1);
       t8:=Var3<=REF(Var4,1) AND CLOSE<REF(CLOSE,1) AND 预警系统=65 AND 抄底=0
      AND 空方>=REF(空方,1) AND VarC<REF(VarD,1);
       DRAWTEXT(t1 and count(t1,30)=1,10,'上升'),COLOR00FFFF;
       B2:DRAWTEXT(t2 and count(t2,30)=1,55,'下降!'),COLOR00FFFF;
       B3:DRAWTEXT(t3 and count(t3,30)=1,55,'上涨过急!'),COLOR00FFFF;
       B4:DRAWTEXT(t4 and count(t4,30)=1,75,'出货!'),COLOR00FFFF;
       B5:DRAWTEXT(t5 and count(t5,30)=1,50,'反弹!'),COLOR00FFFF;
       B6:DRAWTEXT(t6 and count(t6,30)=1,30,'抢反弹!'),COLOR00FFFF;
       B7:DRAWTEXT(t7 and count(t7,30)=1,-10,'资金进场!'),COLOR00FFFF;
       DRAWTEXT(t8 and count(t8,30)=1,90,'见顶回落!'),COLOR00FFFF;

页: [1]
查看完整版本: 指标编写问答35学习的宝藏