通达信从5—250均线中找出某日收盘价乖离率最小的均线公式
CX:=C;
AA1:=MA(C,5);
AA2:=MA(C,10);
AA3:=MA(C,20);
AA4:=MA(C,30);
AA5:=MA(C,60);
AA6:=MA(C,120);
AA7:=MA(C,250);
BB1:=ABS(CX-AA1);
BB2:=ABS(CX-AA2);
BB3:=ABS(CX-AA3);
BB4:=ABS(CX-AA4);
BB5:=ABS(CX-AA5);
BB6:=ABS(CX-AA6);
BB7:=ABS(CX-AA7);
AAA:=MIN(MIN(MIN(MIN(MIN(MIN(BB1,BB2),BB3),BB4),BB5),BB6),BB7);
BBB:=IF(AAA=BB1,AA1,IF(AAA=BB2,AA2,IF(AAA=BB3,AA3,IF(AAA=BB4,AA4,
IF(AAA=BB5,AA5,IF(AAA=BB6,AA6,IF(AAA=BB7,AA7,CX)))))));
CCC:=IF(AAA=BB1,1,IF(AAA=BB2,2,IF(AAA=BB3,3,IF(AAA=BB4,4,
IF(AAA=BB5,5,IF(AAA=BB6,6,7))))));
EEE:=IF(CCC=1,'5天平均线',IF(CCC=2,'10天平均线',IF(CCC=3,'20天平均线',
IF(CCC=4,'30天平均线',IF(CCC=5,'60天平均线',IF(CCC=6,'120天平均线',IF(CCC=7,'250天平均线','')))))));
DRAWTEXT_FIX(ISLASTBAR,0,0,0,STRCAT(STRCAT(STRCAT('最后交易日最近线是:',EEE),'='),CON2STR(BBB,2)));
最近线:BBB,COLORYELLOW,NODRAW;