龙听期货论坛's Archiver

龙听 发表于 2019-1-3 14:24

{优化整合指标公式}【主图指标公式 公式、源码 演示图】[大智慧公式]

[code]
INPUT:K1(2011,1990,3000),K2(1,1,12),K3(1,1,31),DX(0,0,2),FA(0,0,5),P1(5,0,255),P2(10,0,255),P3(20,0,255),P4(0,0,255),P5(0,0,255);
AS:=(o+h+l+c)/4;
MMA5:EMA(AS,P1);
SYAA:EMA(AS,P2);
SYAB:EMA(AS,P3);{
SYAC:EMA(AS,P4);
SYAD:EMA(AS,P5);}

RQD:=(K1-1900)*10000+K2*100+K3;
DJ:REF(L,BARSLAST(DATE<=RQD )),LINETHICK0,COLOR55BB55;
上涨:=BARSSINCE(BACKSET(BARSTATUS=2,BARSLAST(L=DJ)+1));
STICKLINE(C>=O,C,O,8,0),COLOR0000FF,LAYER4;
STICKLINE(C>=O,H,L,0,0),COLOR0000FF,LAYER4;
STICKLINE(C<=O,C,O,8,0),COLORFFFF00,LAYER4;
STICKLINE(C<=O,H,L,0,0),COLORFFFF00,LAYER4;
DRAWTEXT(上涨=0 AND FA>=1,DJ,'1'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=1 AND FA>=1,DJ,'2'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=2 AND FA>=1,DJ,'3'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=3 AND FA>=1,DJ,'4'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=4 AND FA>=1,DJ,'5'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=5 AND FA>=1,DJ,'6'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=6 AND FA>=1,DJ,'7'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=7 AND FA>=1,DJ,'8'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=8 AND FA>=1,DJ,'9'),COLORFFFFFF,VALIGN1;
DRAWTEXT(上涨=9 AND FA>=1,DJ,'10'),COLORFFFFFF,VALIGN1;

阳涨幅:=3.5;
阳倍量:=1.9;
单阳收:=C;
单阳开:=O;
单阳:=单阳收>=REF(C,1)*(1+阳涨幅/100)AND VOL>REF(VOL,1)*阳倍量;
DRAWTEXT(BARSTATUS=0 AND 单阳,L,'阳'),COLOR00FFFF,VALIGN1;
高不破价:=REF(C,BARSLAST(单阳));
低不破价:=REF(L,BARSLAST(单阳));
单阳不破:=BARSTATUS=0 AND BARSLAST(单阳)<11 AND (LLV(L,BARSLAST(单阳))>低不破价 OR LLV(L,BARSLAST(单阳))=低不破价);
STICKLINE(单阳不破,低不破价-低不破价*0.0005,低不破价,11,0),COLORGREEN;
STICKLINE(单阳不破,高不破价,高不破价,11,0),COLORRED;
STICKLINE(单阳,单阳开,单阳收,6,0),COLORYELLOW;
QKB:=IF(C>O,O,C);
QKAB:=IF(C>O,O+(C-O)*0.75,O+(C-O)*0.75);
STICKLINE(BARSTATUS=0 AND 单阳,QKB,QKAB,6,0),COLORFF2693;
实体幅度2:=REF((O+(C-O)*0.667),BARSLAST(单阳));{//当日实体幅度的2/3}
实体幅度1:=REF((O+(C-O)*0.333),BARSLAST(单阳));{//当日实体幅度的1/3}
幅度的1二:=REF((L+(H-L)/2),BARSLAST(单阳));{//当日幅度的1/2}
STICKLINE(单阳不破,幅度的1二,幅度的1二,8,1),COLOR209FFF,DOTLINE;
STICKLINE(单阳不破,实体幅度2,实体幅度2,11,1),COLORFFFF00,DOTLINE;
STICKLINE(单阳不破,实体幅度1,实体幅度1,11,1),COLORFFFF00,DOTLINE;
DRAWTEXT(BARSLAST(单阳)=1 AND 单阳不破,低不破价,'1'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=2 AND 单阳不破,低不破价,'2'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=3 AND 单阳不破,低不破价,'3'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=4 AND 单阳不破,低不破价,'4'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=5 AND 单阳不破,低不破价,'5'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=6 AND 单阳不破,低不破价,'6'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=7 AND 单阳不破,低不破价,'7'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=8 AND 单阳不破,低不破价,'8'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=9 AND 单阳不破,低不破价,'9'),COLORGREEN;
DRAWTEXT(BARSLAST(单阳)=10 AND 单阳不破,低不破价,'10'),COLORGREEN;
{一阳穿三线}
MA2:=EMA(C,2);
MA5:=EMA(C,5);
MA13:=EMA(C,13);
MA34:=EMA(C,34);
MA55:=EMA(C,55);
YCX:=MA5>=REF(MA5,1);
H1:=MAX(MAX(MA5,MA13),MA34);
L1:=MIN(MIN(MA5,MA13),MA34);
QK:=IF(C>O,O,C);
QKA:=IF(C>O,O+(C-O)*0.35,O+(C-O)*0.25);
一阳穿三线:= H1<C AND O<L1 AND YCX AND MA2>REF(MA2,1);
STICKLINE(一阳穿三线,QK,QKA,6,0),COLORYELLOW;
STICKLINE(C=C AND fa>=1,O+((C-O)*0.667),(O+(C-O)*0.667),4,0),COLORFF0000,LINETHICK1;{//当日实体幅度的2/3}
STICKLINE(C=C AND fa>=1,O+((C-O)*0.333),(O+(C-O)*0.333),4,0),COLORFF0000,LINETHICK1;{//当日实体幅度的1/3}
STICKLINE(C=C AND fa>=1,O+((C-O)/2),(O+(C-O)/2),5,0),COLOR00FFFF,LINETHICK1;{//当日实体幅度的1/2}
STICKLINE(C=C AND fa>=1,L+((H-L)/2),(L+(H-L)/2),6,0),COLOR208FFF,LINETHICK1;{//当日幅度的1/2}
STICKLINE(C=C AND fa>=1,IF(C>O,H-((H-C)/2),H-((H-O)/2)),IF(C>O,H-((H-C)/2),H-((H-O)/2)),1.3,0),COLORYELLOW,LINETHICK1;{//当日上影线幅度的1/2}
STICKLINE(C=C AND fa>=1,IF(C<O,L+((C-L)/2),L+((O-L)/2)),IF(C<O,L+((C-L)/2),L+((O-L)/2)),1.3,0),COLORYELLOW,LINETHICK1;{//当日下影线幅度的1/2};
AJ:=AMOUNT/(VOL*100);
DRAWTEXT(C=C AND fa=3,AJ,'←'),COLORFF5f00;
z3:=C=HHV(C,6);
Z9:=C=LLV(C,6);
Z4:=BARSLAST(Z3);
Z5:=BARSLAST(Z9);
STICKLINE(C>0 AND fa=2,REF(C,Z4)*1.005,REF(C,Z4)*1.005,7,0),COLORFFFF00,DOTLINE;
STICKLINE(C>0 AND fa=2,REF(C,Z5)*0.995,REF(C,Z5)*0.995,7,0),COLORFF00FF,DOTLINE;
LC := REF(CLOSE,1);
RSI1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;
DRAWICON(RSI1>76,H,12),VALIGN1,ALIGN1;
DRAWICON(RSI1>80,H,13),VALIGN0,ALIGN1;
BL:=EMA(AS,17);
BLS:=BL+2.58*STDP(C,20);
BL2:=BL+1.96*STDP(C,20);
DRAWICON(CROSS(H,BLS),H,8),VALIGN1,ALIGN1;
DRAWICON(CROSS(H,BL2),H,6),VALIGN2,ALIGN1;
Q1:=DJ * 1.03;
Q2:=DJ * 1.05;
Q3:=DJ * 1.08;
Q4:=DJ * 1.13;
Q5:=DJ * 1.18;
Q6:=DJ * 1.25;
Q7:=DJ * 1.33;
I1:=0;
flag1:=0;
while I1<BARSLAST(DISPSTATUS=1)-BARSLAST(DISPSTATUS=2)
DO
IF REF(Q1,I1)<REF(Q1,I1+1) AND REF(Q1,I1+1)>Q1
THEN BEGIN FLAG1:=1;
S1:=I1;
I1:=BARSLAST(DISPSTATUS=1);
END
ELSE I1:=I1+1;
STICKLINE(FLAG1 AND DX>=1,REF(Q1,S1),DJ,(s1+1)*20,0),Color551155,ALIGN1,LAYER5;
STICKLINE(FLAG1 AND DX>=1,REF(Q1,S1),Q2,(s1+1)*20,0),Color444444,ALIGN1,LAYER5;
STICKLINE(FLAG1 AND DX>=1,REF(Q2,S1),Q3,(s1+1)*20,0),Color666666,ALIGN1,LAYER5;
STICKLINE(FLAG1 AND DX>=1,REF(Q3,S1),Q4,(s1+1)*20,0),Color777777,ALIGN1,LAYER5;
STICKLINE(FLAG1 AND DX>=1,REF(Q4,S1),Q5,(s1+1)*20,0),Color665506,ALIGN1,LAYER5;
STICKLINE(FLAG1 AND DX>=2,REF(Q5,S1),Q6,(s1+1)*20,0),Color777000,ALIGN1,LAYER5;
DRAWTEXT(上涨=0 AND DX>=1,DJ*1.003,''+''+NUMTOSTRN(DJ,2)),COLORYELLOW,align2;
DRAWTEXT(上涨=0 AND DX>=1,Q1,'3%'+'-'+NUMTOSTRN(Q1,2)),COLORYELLOW,align2;
DRAWTEXT(上涨=0 AND DX>=1,Q2,'5%'+'-'+NUMTOSTRN(Q2,2)),COLORYELLOW,align2;
DRAWTEXT(上涨=0 AND DX>=1,Q3,'8%'+'-'+NUMTOSTRN(Q3,2)),COLORYELLOW,align2;
DRAWTEXT(上涨=0 AND DX>=1,Q4,'13%'+'-'+NUMTOSTRN(Q4,2)),COLORYELLOW,align2;
DRAWTEXT(上涨=0 AND DX>=1,Q5,'18%'+'-'+NUMTOSTRN(Q5,2)),COLORYELLOW,align2;
DRAWTEXT(上涨=0 AND DX>=2,Q6,'25%'+'-'+NUMTOSTRN(Q6,2)),COLORYELLOW,align2;
{添加参数精灵
{--------显示年月日低点日期--------}
调整年 Param#1 显示年度
调整月 Param#2 显示月份
调整日 Param#3 显示日期
--------参数=1显示低点水平线------
参数=2--4 Param#4 显示涨幅幅度线
参数=0--2 Param#5 显示K线幅度线
--------显示均价线--------
P1计算 Param#6 任意均价线;
P2计算 Param#7 任意均价线;
P3计算 Param#8 任意均价线;
P4计算 Param#9 任意均价线;
P5计算 Param#10 任意均价线;
[/code]

龙听 发表于 2019-1-3 14:24

[attach]6227[/attach]

页: [1]