請問如何在XS語法中寫出漲停打開呢?
請問如何在XS語法中寫出漲停打開呢?
- 690
- 最後發表 森77 2023 八月 17
Hello 森77,
您可以判斷當天的最高價是否為漲停價,且當下的價格小於漲停價。
舉例來說:
condition1 = getfield("High", "D") = GetField("漲停價", "D") and close < GetField("漲停價", "D");
上方的語法回測出來是前一天漲停,並不是當天的漲停,不知是否是我中間有寫錯,請您幫我查核下
condition1 = getfield("High", "D") = GetField("漲停價", "D") and close < GetField("漲停價", "D");
if time >= 090000 and time <= 103000
and getField("收盤價","D")[1] > getField("收盤價","D")[2]*1.09 //昨天漲9%以上
and close Cross Under getField("收盤價","D")[1]*1.07 //今日向下跌破7%
編碼及截圖如下,請您查核
input: Length(9), RSVt(3), Kt(3), HighBound(70);
SetTotalBar(maxlist(Length,6) * 3 + 8);
SetInputName(1, "計算期數");
SetInputName(2, "RSVt權數");
SetInputName(3, "Kt權數");
setInputName(4, "高檔區");
variable: rsv(0), k(0), _d(0);
Stochastic(Length, RSVt, Kt, rsv, k, _d); //計算KD
input: Length1(6); SetInputName(1, "短期期數");
input: Length2(12); SetInputName(2, "長期期數");
input: HighBound1(80); SetInputName(3, "高檔區");
settotalbar(maxlist(Length1,Length2,6) * 8 + 8);
value1=RSI(close,Length1);
value2=RSI(close,Length2); //計算RSI
condition1 = getfield("High", "D") = GetField("漲停價", "D") and close < GetField("漲停價", "D");
if time >= 090000 and time <= 103000
and k > HighBound and _d > HighBound //KD值大於70
and value1 > HighBound1 and value2 > HighBound1 //RSI值大於80
and getField("收盤價","D")[1] > getField("收盤價","D")[2]*1.09 //昨天漲9%以上
and close Cross Under getField("收盤價","D")[1]*1.07 //今日向下跌破7%
and close[1] > 100 and close[1] < 300 //前一天股價在100元以上,300元以下
and getfield("成交金額(元)","D")[1] > 30000000//昨日成交金額3000萬以上
then ret=1;

Hello 森77,
您寫了 condition1 的條件,但卻沒有將條件拿來篩選,自然不會篩選出想要的商品。
請將 condition1 放入 if ... then ret = 1; 裡。
像是:
if time >= 090000 and time <= 103000
and k > HighBound and _d > HighBound //KD值大於70
and value1 > HighBound1 and value2 > HighBound1 //RSI值大於80
and getField("收盤價","D")[1] > getField("收盤價","D")[2]*1.09 //昨天漲9%以上
and close Cross Under getField("收盤價","D")[1]*1.07 //今日向下跌破7%
and close[1] > 100 and close[1] < 300 //前一天股價在100元以上,300元以下
and getfield("成交金額(元)","D")[1] > 30000000//昨日成交金額3000萬以上
and condition1 //當日漲停打開
then ret = 1;
5 評論