[TS懶人包] [保險服務]

2009年3月17日 星期二

程式交易俱樂部 - 314 網聚簡報

其實那天在座太多前輩了…叫一個經驗不足的小朋友上台實在是覺得不太好意思。不過還是把當天的東西放上來讓大家參考一下囉…



程式碼的部份:


Parameters : HighLowTerm(14), kLength(3), dLength(3), OverSold(20), OverBought(80)
Parameter: Lookback(20), mult(2)
Variables: alpha(0), mt(0), ut(0), dt(0), mt2(0), ut2(0), dt2(0), but(0), blt(0)
Vars:upLine(0), downLine(0)
Vars:KDred(0), KDblue(0)

Value11 = FastD( High, Low, Close, HighLowTerm)
KDRed = Round(Value11,2)
KDBlue = Round(MA(Value11, dLength),2)

alpha = 2 / (Lookback + 1)
mt = alpha * Close + (1 - alpha) * mt
ut = alpha * mt + (1 - alpha) * ut
dt = ((2 - alpha) * mt - ut) / (1 - alpha) //center
mt2 = alpha * Abs(Close - dt) + (1 - alpha) * mt2
ut2 = alpha * mt2 + (1 - alpha) * ut2
dt2 = ((2 - alpha) * mt2 - ut2) / (1 - alpha)
but = dt + mult * dt2 //upper
blt = dt - mult * dt2 //lower

if currentcontracts <= 0 and KDRed > KDBlue and close > but then
buy ("b1") next bar at market
end if

if currentcontracts >= 0 and KDRed < KDBlue and close < blt then
sell ("s1") next bar at market
end if
/*
if currentcontracts <= 0 and KDRed > KDBlue then
buy ("b2") next bar at blt limit
end if

if currentcontracts >= 0 and KDRed < KDBlue then
sell ("s2") next bar at but limit
end if
*/
if currentcontracts > 0 and KDRed cross under KDBlue then
exitlong next bar at market
end if

if currentcontracts < 0 and KDRed cross over KDBlue then
exitshort next bar at market
end if


沒有留言:

張貼留言

請留下您的大名…匿名者恕不回應…

Related Posts Plugin for WordPress, Blogger...