首先申明,这是画线公式,因此用到了向后引用的未来函数,但没有任何影响,因为这不是选股公式。
本公式用近似的办法基本可以准确辨认笔的上下分型顶点,对于查看走势和中枢有非常直观的辅助作用。
源码
DINGFEN := HIGH=HHV(HIGH, 6) AND HIGH=REFX(HHV(HIGH, 6), 5);
{AND HIGH = HHV(HIGH, 3) AND LOW = HHV(LOW, 3)
AND HIGH=REFX(HHV(HIGH, 3), 2) AND LOW=REFX(HHV(LOW, 3), 2);}
DIFEN := LOW = LLV(LOW, 6) AND LOW=REFX(LLV(LOW, 6), 5);
{AND HIGH = LLV(HIGH, 3) AND LOW = LLV(LOW, 3)
AND HIGH=REFX(LLV(HIGH, 3), 2) AND LOW=REFX(LLV(LOW, 3), 2);}
LASTDINGFEN := REF(BARSLAST(DINGFEN), 1);
LASTDIFEN := REF(BARSLAST(DIFEN), 1);
LASTDINGHIGH := REF(HIGH, LASTDINGFEN + 1);
LASTDILOW := REF(LOW, LASTDIFEN + 1);
{1=DING 2=DI}
LASTTYPE := IF(LASTDINGFEN < LASTDIFEN, 1, 2);
ZHUANGZHE1 := DINGFEN AND (LASTDIFEN >= 4 OR LASTDINGFEN > LASTDIFEN);
ZHUANGZHE2 := DIFEN AND BARSLAST(DINGFEN) >= 4;{ AND LASTDIFEN > LASTDINGFEN;}
ZHUANGZHE := ZHUANGZHE1 OR ZHUANGZHE2;{DINGFEN OR DIFEN;}
DD1 := IF(DINGFEN, HIGH, 0);
DD := IF(DIFEN, LOW, DD1);
DINGOK := DINGFEN AND ((LASTTYPE=1 AND HIGH > LASTDINGHIGH) OR LASTTYPE=2);
DIOK := DIFEN AND ((LASTTYPE=2 AND LOW < LASTDILOW) OR LASTTYPE=1);
PLOYLINE(ZHUANGZHE AND (DINGOK OR DIOK), DD);
{PLOYLINE(DINGOK, DD);};