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

2010年3月10日 星期三

K 線根數的記錄 (MACD 背離) II

經過了上一篇的講解…我想要另外寫出多方背離應該只是再把程式碼 copy 一下改一些地方就行了。主要想說的…我想還是這寫程式的過程,從想法 - 到邏輯 - 到程式碼。這中間的過程並不是這麼的容易,想法可以很天馬行空的說…我要作波浪的第三波!

這個想法一定可行…不過重點就在於你怎麼定義所謂的"波浪的第三波",這個東西。

今天甲說了:我要作 MACD 背離!

當然可以…接下來我就要請你定義出:什麼叫 MACD 背離。

甲又說了:(指著圖上)就這個價格比那個價格高,這個 MACD 值比那個 MACD 值低啊…應該很簡單吧?

然後我心理就會想:又來一個應該很簡單了。

扯遠了…還是先把上次的程式完成吧:

array: highPoint[2](0), highMACD[2](0), highK[2](0);
array: lowPoint[2](0), lowMACD[2](0), lowK[2](0);


Value1 = MACD(close, 12, 26);
Value2 = XAverage(MACD(close, 12, 26), 9);

if Value1 cross under Value2 then begin
highPoint[0] = highPoint[1];
highMACD[0] = highMACD[1];
highK[0] = highK[1];

for Value3 = 0 to 10 begin
if high[Value3] = highest(high, 10) then begin
highPoint[1] = high[Value3];
highMACD[1] = Value1[Value3];
highK[1] = barnumber[Value3];
end;
end;

if highPoint[1] > highPoint[0] and highMACD[1] < highMACD[0] and highK[1] > highK[0] + 20 then begin
sell next bar at market;
end;
end;

if Value1 cross over Value2 then begin
lowPoint[0] = lowPoint[1];
lowMACD[0] = lowMACD[1];
lowK[0] = lowK[1];

for Value4 = 0 to 10 begin
if low[Value4] = lowest(low, 10) then begin
lowPoint[1] = low[Value4];
lowMACD[1] = Value1[Value4];
lowK[1] = barnumber[Value4];
end;
end;

if lowPoint[1] < lowPoint[0] and lowMACD[1] > lowMACD[0] and lowK[1] > lowK[0] + 20 then begin
buy next bar at market;
end;
end;


setexitonclose;


那接下來這邊是不是還可以變型?我想還是可以有非常多的想法再加進去的…比如說,我不要作當沖了,我要進場一直放到另一個交叉才出場、比如說我希望兩個死亡交叉中間還要再加一個穿越 0 軸的條件、比如說我希望第一個交叉是在 30 以上或 70 以下…

太多了…想到什麼就寫什麼吧。記得在圖上對照訊號是否正確囉。

沒有留言:

張貼留言

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

Related Posts Plugin for WordPress, Blogger...