K线包含关系 有未来函数,用于K线合并
看顶底分型很直观
走势K线的包含关系显示,可以从公式中看到,出现包含关系出现时,公式会把相互包含的第二根K线处理成包含处理后的K线区间;向上包含处理时,会把包含形成后的新K线显示为粉红色,向下包含处理时,会把包含形成后的新K线显示为绿色。
X_1:=HIGH =REF(HIGH,1) AND LOW =REF(LOW,1);
X_2:=LOW =REF(LOW,1) AND HIGH =REF(HIGH,1);
X_3:=IF(X_1,1,IF(X_2,(-1),0));
X_4:=IF(REF(HIGH,1) =REF(HIGH,2) AND REF(LOW,1) =REF(LOW,2),1,IF(REF(LOW,1) =REF(LOW,2) AND REF(HIGH,1) =REF(HIGH,2),(-1),0));
X_5:=IF(X_3=0 AND X_4=1,MAX(HIGH,REF(HIGH,1)),IF(X_3=0 AND X_4=(-1),MIN(HIGH,REF(HIGH,1)),HIGH));
X_6:=IF(X_3=0 AND X_4=1,MAX(LOW,REF(LOW,1)),IF(X_3=0 AND X_4=(-1),MIN(LOW,REF(LOW,1)),LOW));
X_7:=HIGH =REF(X_5,1) AND LOW =REF(X_6,1);
X_8:=LOW =REF(X_6,1) AND HIGH =REF(X_5,1);
X_9:=IF(X_7,1,IF(X_8,(-1),0));
X_10:=IF(REF(X_5,1) =REF(X_5,2) AND REF(X_6,1) =REF(X_6,2),1,IF(REF(X_6,1) =REF(X_6,2) AND REF(X_5,1) =REF(X_5,2),(-1),0));
X_11:=IF(X_9=0 AND X_10=1,MAX(HIGH,REF(X_5,1)),IF(X_9=0 AND X_10=(-1),MIN(HIGH,REF(X_5,1)),HIGH));
X_12:=IF(X_9=0 AND X_10=1,MAX(LOW,REF(X_6,1)),IF(X_9=0 AND X_10=(-1),MIN(LOW,REF(X_6,1)),LOW));
X_13:=HIGH =REF(X_11,1) AND LOW =REF(X_12,1);
X_14:=LOW =REF(X_12,1) AND HIGH =REF(X_11,1);
X_15:=IF(X_13,1,IF(X_14,(-1),0));
X_16:=IF(REF(X_11,1) =REF(X_11,2) AND REF(X_12,1) =REF(X_12,2),1,IF(REF(X_12,1) =REF(X_12,2) AND REF(X_11,1) =REF(X_11,2),(-1),0));
X_17:=IF(X_15=0 AND X_16=1,MAX(HIGH,REF(X_11,1)),IF(X_15=0 AND X_16=(-1),MIN(HIGH,REF(X_11,1)),HIGH));
X_18:=IF(X_15=0 AND X_16=1,MAX(LOW,REF(X_12,1)),IF(X_15=0 AND X_16=(-1),MIN(LOW,REF(X_12,1)),LOW));
X_19:=HIGH =REF(X_17,1) AND LOW =REF(X_18,1);
X_20:=LOW =REF(X_18,1) AND HIGH =REF(X_17,1);
X_21:=IF(X_19,1,IF(X_20,(-1),0));
X_22:=IF(REF(X_17,1) =REF(X_17,2) AND REF(X_18,1) =REF(X_18,2),1,IF(REF(X_18,1) =REF(X_18,2) AND REF(X_17,1) =REF(X_17,2),(-1),0));
X_23:=IF(X_21=0 AND X_22=1,MAX(HIGH,REF(X_17,1)),IF(X_21=0 AND X_22=(-1),MIN(HIGH,REF(X_17,1)),HIGH));
X_24:=IF(X_21=0 AND X_22=1,MAX(LOW,REF(X_18,1)),IF(X_21=0 AND X_22=(-1),MIN(LOW,REF(X_18,1)),LOW));
X_25:=HIGH =REF(X_23,1) AND LOW =REF(X_24,1);
X_26:=LOW =REF(X_24,1) AND HIGH =REF(X_23,1);
X_27:=IF(X_25,1,IF(X_26,(-1),0));
X_28:=IF(REF(X_23,1) =REF(X_23,2) AND REF(X_24,1) =REF(X_24,2),1,IF(REF(X_24,1) =REF(X_24,2) AND REF(X_23,1) =REF(X_23,2),(-1),0));
X_29:=IF(X_27=0 AND X_28=1,MAX(HIGH,REF(X_23,1)),IF(X_27=0 AND X_28=(-1),MIN(HIGH,REF(X_23,1)),HIGH));
X_30:=IF(X_27=0 AND X_28=1,MAX(LOW,REF(X_24,1)),IF(X_27=0 AND X_28=(-1),MIN(LOW,REF(X_24,1)),LOW));
X_31:=X_29;
X_32:=X_30;
方向:IF(X_31 =REF(X_31,1) AND X_32 =REF(X_32,1),1,IF(X_32 =REF(X_32,1) AND X_31 =REF(X_31,1),(-1),0)),NODRAW,COLORYELLOW;
X_33:=X_31 REFX(HIGH,1) AND X_32 REFX(LOW,1) OR (X_31 REFX(HIGH,1) AND X_32 REFX(LOW,1));
包含关系:X_27=0,NODRAW,COLORWHITE;
合并K线:包含关系 AND X_33!=1,NODRAW,COLORLICYAN;
STICKLINE(方向+1 AND X_33!=1,X_31,X_32,1.8,0),COLORMAGENTA;
STICKLINE(方向-1 AND X_33!=1,X_31,X_32,1.8,0),COLORBLUE;
STICKLINE(合并K线=1,X_31,X_32,0.08,0),COLORWHITE;
X_34:=BARSLAST(合并K线);
X_35:=VALUEWHEN(合并K线,X_31);
X_36:=VALUEWHEN(合并K线,X_32);
X_37:=COUNT(CLOSE X_35,X_34)=1;
GSZX:SMA(MAX(CLOSE-C,0),7,1)/SMA(ABS(CLOSE-C),7,1)*100,NODRAW;