FilledRecordCount 改價用法是否正確?

  •   149 
  • 最後發表   XQYi  2024 六月 05
XQYi 發文於   2024/06/04

 //FilledRecordCount 改價用法是否正確?

 

var: intrabarpersist FRC1(0) ,intrabarpersist SBT1(0)

if position=0 and filled=0 and condition1 then begin

setposition(1);

if position=1 and filled=0 then begin

SBT1=Getfield("時間","Tick");

FRC1=FilledRecordCount;

end;

end;

if position <> 0 and filled=0 and( Getfield("時間","Tick")>=timeadd(SBT1,"S",5)  or FRC1>FRC1+5)

then setposition(minList(position+1,1),addSpread(PT1,1),label:="買1-2B");//5秒後或成交經過5筆,如果買不到則調高追價

排序方式: 標準 | 最新
虎科大許教授 發文於   2024/06/04

(1)FRC1>FRC1+5這個條件永遠無法成立。

(2)你這裡有三個IF,第二個IF永遠進不去。

XQYi 發文於   2024/06/04

恩恩  修正如下第一個begin end 拿掉 、 FilledRecordCount - FRC1 >5)

var: intrabarpersist FRC1(0) ,intrabarpersist SBT1(0)

if position=0 and filled=0 and condition1 then 

setposition(1);

if position=1 and filled=0 then begin

SBT1=Getfield("時間","Tick");

FRC1=FilledRecordCount;

end;

 

if position <> 0 and filled=0 and( Getfield("時間","Tick")>=timeadd(SBT1,"S",5)  or FilledRecordCount - FRC1 >5)

then setposition(minList(position+1,1),addSpread(PT1,1),label:="買1-2B");//5秒後或成交經過5筆,如果買不到則調高追價

虎科大許教授 發文於   2024/06/04

position <> 0 and filled=0 時,FilledRecordCount - FRC1 >5 不可能成立。

XQYi 發文於   2024/06/04

FilledRecordCount - FRC1 >5 改為 FilledRecordCount >= FRC1 + 5

第二個 if 的 begin 寫在第一個IF內,發現回測結果成交商品數差異還蠻多的,為何?

 

var: intrabarpersist FRC1(0) ,intrabarpersist SBT1(0)

if position=0 and filled=0 and condition1 then begin

setposition(1);

if position=1 and filled=0 then 

SBT1=Getfield("時間","Tick");

FRC1=FilledRecordCount; //紀錄委託成功但未成交前的筆數

end;

 

if position <> 0 and filled=0

and( Getfield("時間","Tick")>=timeadd(SBT1,"S",5)  or FilledRecordCount >= FRC1 + 5)

then setposition(minList(position+1,1),addSpread(PT1,1),label:="買1-2B");//5秒後或成交經過5筆,如果買不到則調高追價

虎科大許教授 發文於   2024/06/05

(1)當次洗價的setposition(1)並不會讓position變成1。

if position=0 and filled=0 and condition1 then begin

setposition(1);

if

position=1 and filled=0 //這個條件永遠無法成立,因為只有position=0 and filled=0才能進到第一個IF裡面

then 

SBT1=Getfield("時間","Tick");

FRC1=FilledRecordCount; //紀錄委託成功但未成交前的筆數

end;

(2)FRC1等於FilledRecordCount,所以FilledRecordCount >= FRC1 + 5也永遠不會成立。

XQYi 發文於   2024/06/05

把begin 放在第二個if

if position=0 and filled=0 and condition1 then 

setposition(1);

if position=1 and filled=0 then begin

SBT1=Getfield("時間","Tick");

FRC1=FilledRecordCount; //紀錄委託成功但未成交前的筆數

end;

FilledRecordCount的用法 沒步!

那該如何修正才能利用除了時間差外,用成交多少次之後來調整價格?

虎科大許教授 發文於   2024/06/05

我會建議用一個變數在出場時記錄次數。

XQYi 發文於   2024/06/05

入場時已經用變數紀錄了=> intrabarpersist FRC1(0)

意思是出場要先預設 =>value1=FRC1+5

當 FRC1 >=value1 ? (好像沒差別)

太難理解了~

XQYi 發文於   2024/06/05

如果是這樣呢?

var: intrabarpersist FRC1(0), intrabarpersist FRC5(0), intrabarpersist SBT1(0);

 

// 記錄第一筆委託時的當下筆數

if position = 0 and filled = 0 and condition1 then begin

    setposition(1);

    SBT1 = Getfield("時間", "Tick");

    FRC1 = FilledRecordCount; // 紀錄第一筆委託時的當下筆數

end;

 

// 記錄第一筆委託後的第五筆成交

if FRC1 > 0 and FRC5 = 0 then begin

    if FilledRecordCount >= FRC1 + 5 then begin

        FRC5 = FilledRecordCount; // 紀錄第五筆成交筆數

    end;

end;

 

// 調整價格條件

if position <> 0 and filled = 0 and (Getfield("時間", "Tick") >= timeadd(SBT1, "S", 5) or (FRC1 > 0 and FilledRecordCount >= FRC1 + 5)) then begin

    setposition(minList(position + 1, 1), addSpread(PT1, 1), label:="買1-2B"); // 5秒後或成交經過5筆,如果買不到則調高追價

end;

 

虎科大許教授 發文於   2024/06/05

看起來你的成交經過5筆,似乎指的是經過5個Tick。若是這樣,就不能用FilledRecordCount。它代表你的策略成交的筆數。

顯示更多回應 發表回覆
Close