以下是我請朋友幫我寫的
但是他沒訂購策略模組
所以他用盤後選股可以跑
我用盤中警示的方式編譯 就發現有些語法無法使用
像Outputname和Outputfield
請問 是否能幫忙看一下該怎麼修正
謝謝
--------------------------------------------------
//1、今天的即時行情 >= 10 20 60sma
input:Leng1(10),Leng2(20),Leng3(60);
variable: ma1(0), ma2(0), ma3(0);
SetInputName(1,"短均線");
SetInputName(2,"中均線");
SetInputName(3,"長均線");
settotalbar(3);
ma1 = average(close, Leng1);
ma2 = average(close, Leng2);
ma3 = average(close, Leng3);
condition1 = close >= ma1;
condition2 = ma1 >= ma2;
condition3 = ma2 >= ma3;
SetOutputName1("短均線");
OutputField1(ma1);
SetOutputName2("中均線");
OutputField2(ma2);
SetOutputName3("長均線");
OutputField3(ma3);
//2.昨天的收盤價 或" 前天的收盤價 小於或等於 月線
condition4 = close[1] <= ma2[1];
condition5 = close[2] <= ma2[2];
condition6 = condition4 or condition5;
//3、MACD指標(12,26,9),今天盤中的DIF >=昨天的DIF and DIF>=0
value1 = MACD(WeightedClose,12,26,9,value2,value3,value4); //計算MACD
//plot1(value2, "DIF");
//plot2(value3, "MACD");
//plot3(value4, "OSC");
condition7 = value2 >= value2[1];
condition8 = value2 >= 0;
condition9 = condition7 and condition8;
//4、股價>=10元
condition10 = close >= 10;
//5.10日平均成交量>=1000張
condition11 = average(volume[1],10) >= 1000;
//6.今日的盤中KD指標(9,3,3) K>=D
input: Length(9), RSVt(3), Kt(3);
variable: rsv(0), k(0), _d(0);
SetTotalBar(maxlist(Length,6) * 3+8);
SetInputName(1, "天數");
SetInputName(2, "RSVt權數");
SetInputName(3, "Kt權數");
if currentbar <> gettotalbar then return;
Stochastic(Length, RSVt, Kt, rsv, k, _d);
condition12 = k >= _d;
//7.今日的60ma>=昨日的60ma
condition13 = ma2 > ma2[1];
//選股條件:
if
condition1 and condition2 and condition3 //1、站在三條均線之上
and condition6 //條件2
and condition9 //條件3
and condition10 //條件4
and condition11 //條件5
and condition12 //條件6
and condition13 //條件7
then
ret = 1;

5 評論