如何寫XS語法抓寶塔線由綠翻紅第一根呢?
如何寫XS語法抓寶塔線由綠翻紅第一根呢?
- 4.1K
- 最後發表 a2224 2021 七月 28
謝謝,但我把語法改為選股就沒有抓出由綠翻紅第一根,請幫助賜教。
input: Length(4);
variable: _Index(0), LV(0);
LV = Low[1];
for _Index = 2 to Length
begin
if LV >= Low[_Index] then LV = Low[_Index];
end;
if Close <= LV then ret=1;
a2224 您好
您的語法似乎是我之前的原始語法,這語法與XQ內建的寶塔線定義有些不一樣哦
我幫您修正了一下,請再測試看看
語法如下
input: Length(4);
variable: _Index(0), HV(0), LV(0);
settotalbar(200);
HV = Close[1];
LV = Close[1];
for _Index = 2 to Length + 1
begin
if HV <= Close[_Index] then HV = Close[_Index];
if LV >= Close[_Index] then LV = Close[_Index];
end;
if Close[1] < LV[1] and Close > HV then ret=1;
謝謝帥哥元的分享,給你一個讚
非常感謝
請問 我複製貼上帥哥元的語法,然後編譯,確出現下面的文字
在「指標」腳本中無法使用「ret」。
請問是哪裡出錯了
謝謝 回答
Hi SUE SUE:
在 http://xshelp.xq.com.tw/index.aspx?HelpName=Ret&group=DECLARATION 有相關說明唷!
指標腳本不能使用Ret ,Ret 僅能使用在警示腳本與選股腳本,以上提供給您參考,謝謝。
SUE SUE 您好
因a2224大大於10/4留言所提的是選股無法篩選出來,所以之前的語法是運用在選股或是警示上面的
若要改為指標,請將 ret 改為 plot 哦
幫您重新調整了一下語法,適用紅翻綠 或 綠翻紅
語法如下
input: Length(4);
variable: _Index(0), HV(0), LV(0);
SetInputName(1, "寶塔天數");
HV = Close[1];
LV = Close[1];
for _Index = 2 to Length + 1
begin
if HV <= Close[_Index] then HV = Close[_Index];
if LV >= Close[_Index] then LV = Close[_Index];
end;
if Close > HV then Value1 = 1
else if Close < LV then Value1 = -1;
if Value1 = 1 and Value1[1] = -1 then plot1(Close, "綠轉紅");
if Value1 = -1 and Value1[1] = 1 then plot2(Close, "紅轉綠");
其中,使用Value1來記錄寶塔線是紅柱體還是綠柱體,1為紅柱,2為綠柱
所以 Value1 = 1 代表寶塔線目前是紅色的
而 Value1 = -1 代表寶塔線目前是綠色的
Value1[1] 指的是前一根寶塔的顏色,=1為紅色,=-1為綠色
謝謝XQ小幫手
謝謝帥哥元的回答,你的回答解決了我的問題,非常感謝您!!
請問我目前已得知帥哥元 的寶塔線翻紅程式碼是根據XS系統當初的設定(收盤價大於前三天"收盤價") 以下
input: Length(4); //設置4個天期
variable: _Index(0), HV(0), LV(0); //設置3個變數
settotalbar(200);
HV = Close[1];
LV = Close[1];
for _Index = 2 to Length + 1
begin
if HV <= Close[_Index] then HV = Close[_Index];
if LV >= Close[_Index] then LV = Close[_Index];
end;
if Close[1] < LV[1] and Close > HV then ret=1;
想要的是選股條件是 {{{{ {"當收盤價"大於前三天的最高價}}}}}
以選股方式 而不是指標
那麼我該怎麼改呢, 實在不太會,目前已知條件
1.需要前一天是翻黑或續黑才有機會翻紅(不能原本就翻紅或續紅),前一天收盤價要不高於前四天內最高價?
2.挑出前三天的最高價
3.收盤價大於前三天最高價
應該是這樣...八,怎麼寫都跑不出來
希望有大大可以幫忙>_<
非常感謝
17 評論