策略是希望 DIF由負轉正那根為關鍵K(黃色箭頭),之後股價收盤突破那根關鍵K的高點買進(黃色B)
但圖上K棒突破關鍵K高點時並沒有出現買進的黃色B,是不是哪裡寫錯了
input: FastLength(12), SlowLength(26), MACDLength(9);
variable:mkp(0),mkk(0),price(0),difValue(0), macdValue(0), oscValue(0);
SetInputName(1, "DIF短期期數");
SetInputName(2, "DIF長期期數");
SetInputName(3, "MACD期數");
price = WeightedClose();
difValue = XAverage(price, FastLength) - XAverage(price, SlowLength);
macdValue = XAverage(difValue, MACDLength) ;
oscValue = difValue - macdValue ;
if CurrentBar <= SlowLength then
begin
difValue = 0;
macdValue = 0;
oscValue = 0;
end;
value1 = barslast(difValue>0 and V>1000);
condition1 = difValue>0 and V>1000;
if mkk=0 and condition1=true then
begin
mkk=1;
plot50(C,"關鍵K");
end;
condition4=C>C[value1];
if condition4 and condition4[1] = False and mkp=0 and mkk=1 then
begin
mkp=1;
plot51(c,"進");
end;
if mkp=1 and C<L[value1] then
begin
mkp=0;
mkk=0;
plot52(C,"出");
end;

3 評論