我這個策略只會 做多 可以請問大大 哪邊有問題嗎

  •   118 
  • 最後發表   aka916  2022 四月 27
aka916 發文於   2022/04/19

//宣告

var: openHigh(0), openLow(0) ,closeAvg(0);

//定義K棒率

if barfreq<>"Min" and barInterval<>5 then raiseRunTimeError("只支援5分K");

//換日初始

if Date<>Date[1] then begin

openHigh=0;

openLow=0;

closeAvg=0;

end;

//取值

if time=133000 then begin

openHigh=High[1];

openLow=Low[1];

closeAvg= (openHigh+ openLow)/2;

end;

//進場條件

//filters 濾網自加

if open > closeAvg then condition1 = true;

if open < closeAvg then condition2 = true;

//進場

if position=0 and condition1 then setposition(1);

if position=0 and condition2 then setposition(-1);

//出場條件

if position<>0 and condition3 then setposition(0);

 

XQ小幫手 發文於   2022/04/27

Hello aka916,

 

XQ Bar 的 time 回傳的是該根Bar開始的時間。

所以如果是股票商品且使用5分鐘頻率的話,最後一根Bar會是 132500。

如果您是交易期貨商品的話,if time = 133000 才有可能成立。

 

您在換日時將 closeAvg 歸0,這樣condition1就會是True,而condition2不可能達成。

因此只會多方進場。

發表回覆
Close