期貨市場裡幾乎有7成以上的盤都是盤整形式, 或成箱型模式或是收斂模式,所以幾乎盤整時都趨向收手不進場,就算進場後也容易被迫停損,所以此時就使用盤整模式的程式下去操作也未嘗不可.
以下是盤整模式的程式碼,大家可以參考看看,然而這比較適合盤整階段,如果遇到了順勢盤,或開放型態的盤時,就容易虧損,所以必須再配合其它的策略操作 .在這只提供參考,不負任何盈虧的責任喔!
Parameter: Price(close)
var : CDPA(0),AH(0),NH(0),NL(0),AL(0),DS(0),DB(0)
以下是盤整模式的程式碼,大家可以參考看看,然而這比較適合盤整階段,如果遇到了順勢盤,或開放型態的盤時,就容易虧損,所以必須再配合其它的策略操作 .在這只提供參考,不負任何盈虧的責任喔!
Parameter: Price(close)
var : CDPA(0),AH(0),NH(0),NL(0),AL(0),DS(0),DB(0)
IF DATE[1] <> DATE THEN
DS=0
DB =0
VALUE1= HIGHEST(CLOSE,59)
VALUE2=LOWEST(CLOSE,59)
IF TIME=85000 THEN
VALUE3=CLOSE[1]
END IF
CDPA=(VALUE1+VALUE2+(VALUE3*2))/4
AH=CDPA+(VALUE1-VALUE2)
NH=CDPA*2-VALUE2
NL=CDPA*2-VALUE1
AL=CDPA-(VALUE1-VALUE2)
END IF
IF TIME >=85000 AND TIME <132000 THEN
CONDITION1 =TRUE
ELSE
CONDITION1 =FALSE
END IF
IF CONDITION1 AND DS=0 AND CLOSE>=NH THEN
SELL("NH") NEXT BAR ON MARKET
DS + =1
END IF
SELL("NH") NEXT BAR ON MARKET
DS + =1
END IF
IF CONDITION1 AND DB = 0 AND CLOSE <=NL THEN
BUY("NL") NEXT BAR ON MARKET
DB + =1
END IF
BUY("NL") NEXT BAR ON MARKET
DB + =1
END IF
IF CONDITION1 AND CLOSE > AH THEN
BUY("+AH") NEXT BAR ON MARKET
BUY("+AH") NEXT BAR ON MARKET
END IF
IF CONDITION1 AND CLOSE <AL THEN
SELL("+AL") NEXT BAR ON MARKET
SELL("+AL") NEXT BAR ON MARKET
END IF
IF CurrentContracts <=-1 AND CLOSE > AH THEN
ExitSHORT from entry("NH") NEXT BAR ON MARKET
END IF
IF CurrentContracts=-2 AND CLOSE > NL THEN
ExitSHORT ("ALL_NL") NEXT BAR ON MARKET
END IF
IF CURRENTCONTRACTS >=1 AND CLOSE <AL THEN
ExitLong from entry("NL") NEXT BAR ON MARKET
END IF
IF CURRENTCONTRACTS =2 AND CLOSE <NH THEN
ExitLong("ALL_AH") NEXT BAR ON MARKET
END IF
IF TIME=133000 THEN
EXITSHORT("TO") THIS BAR ON CLOSE
EXITLONG("BTO")THIS BAR ON CLOSE
END IF
ExitSHORT ("ALL_NL") NEXT BAR ON MARKET
END IF
IF CURRENTCONTRACTS >=1 AND CLOSE <AL THEN
ExitLong from entry("NL") NEXT BAR ON MARKET
END IF
IF CURRENTCONTRACTS =2 AND CLOSE <NH THEN
ExitLong("ALL_AH") NEXT BAR ON MARKET
END IF
IF TIME=133000 THEN
EXITSHORT("TO") THIS BAR ON CLOSE
EXITLONG("BTO")THIS BAR ON CLOSE
END IF
老師你好~我使用HTS4000~程式碼裡有Date[1]<>Date[0],要用在夜盤跨日好像不能用~要改成什麼語法~懇請告知~謝謝!!
回覆刪除