小幫手安安

  •   152 
  • 最後發表   小陽  2022 十一月 09
小陽 發文於   2022/11/03

我想要寫一個1K圖,收盤價漲超過2% ret,漲超過4%ret,我只能condition1 = close  cross above GetField("收盤價", "D")[1] * 1.02,,condition2 = close  cross above GetField("收盤價", "D")[1] * 1.04,,6%再跳出,只能這樣分開condition分開跳出嗎?

另外我希望condition1最多只會ret三次,然後condition2成立後,codition1不再跳出,condition2也只ret三次,condition3成立後,condition2不再跳出這樣......

排序方式: 標準 | 最新
XQ小幫手 發文於   2022/11/08

Hello 小陽,

 

您可以寫一個漲超過 X% 的腳本,並限制其最多只能警示 Y 次,這樣只要多設幾個策略就可以了。

舉例來說,腳本可以這樣寫:

input: _priceChange(2, "漲幅%"), _times(3, "警示次數");

var: intrabarpersist count(0);

 

condition1 = close cross over GetField("收盤價", "D")[1] * (1 + 0.01 * _priceChange);

condition2 = count < _times;

condition3 = getinfo("isrealtime") = 1;

 

if condition1 and condition2 and condition3 then begin

    ret = 1;

    _times += 1;

    end;

 

這樣只要多設幾個策略,每個分別設置不同的參數即可。

但是如果您要設定超過4%警示後就不要在警示超過2%的話,那麼就必須要寫在同一個腳本中用變數控制。

心想事成 發文於   2022/11/09

if condition1 and condition2 and condition3 then begin

    ret = 1;

    _times += 1;

    end;

這邊計數怪怪的,應該是用count變數記錄吧。

  • 按讚來自於
  • xqwly30113
XQ小幫手 發文於   2022/11/09

Hello 心想事成,

 

感謝訂正,應該是 count += 1 才對。

 

發表回覆
Close