以下是通达信实用小公式——仓位管控源码
{仓位管控}
M10:MA(C,10),COLORGREEN;
M30:MA(C,30),COLORYELLOW;
X:=CURRBARSCOUNT=1;
X1:DRAWTEXT(C>M10 AND C>M30 AND M10>M30 AND X,M30*0.98,'仓位:80%'),COLORWHITE;
X2:DRAWTEXT(C<M10 AND C>M30 AND M10>M30 AND X,M30*0.98,'仓位:50%'),COLORWHITE;
X3:DRAWTEXT(C<M10 AND C<M30 AND M10>M30 AND X,M30*0.98,'仓位:20%'),COLORWHITE;
X4:DRAWTEXT(C>M10 AND C>M30 AND M10<M30 AND X,M10*0.98,'仓位:50%'),COLORWHITE;
X5:DRAWTEXT(C>M10 AND C<M30 AND M10<M30 AND X,M10*0.98,'仓位:20%'),COLORWHITE;
X6:DRAWTEXT(C<M10 AND C<M30 AND M10<M30 AND X,M10*0.98,'仓位:空仓'),COLORWHITE;
XA:DRAWTEXT_FIX(1,0,0.88,0,'1、实际仓位高于80%、说明头脑发热;'),COLORWHITE,LINETHICK1;
XB:DRAWTEXT_FIX(1,0,1,0,'2、活下来最重要、能吃到鱼身已很好了;'),COLORYELLOW,LINETHICK1;
ZT:=C>=ZTPRICE(REF(CLOSE#DAY,1),0.1);
DT:=C<=DTPRICE(REF(CLOSE#DAY,1),0.1);
BA:STICKLINE(ZT,(H+L)/2,CLOSE,0,0),COLORYELLOW;
BC:STICKLINE(DT,(H+L)/2,CLOSE,0,0),COLORBLUE;
DA:=YEAR AND MONTH AND DAY;
AXA:=STRCAT(CON2STR(YEAR,0),'年');
AAB:=STRCAT(CON2STR(MONTH,0),'月');
AA33:=STRCAT(CON2STR(DAY,0),'日');
AA4:=STRCAT('【',IF(WEEKDAY=1,'一',IF(WEEKDAY=2,'二',IF(WEEKDAY=3,'三',IF(WEEKDAY=4,
'四',IF(WEEKDAY=5,'五',IF(WEEKDAY=6,'六','日')))))));
AA1:=STRCAT(STRCAT(STRCAT(AXA,AAB),STRCAT(AA33,AA4)),'】');
S1:DRAWTEXT_FIX(DA,0.7,1,0,AA1),COLORFFAAFF;