以下兩段程式碼為何執行結果會不一樣?
B程式碼多一筆買進交易
A程式碼
if position=0 and filled=0 and condition90
then begin
if currentTime > TM and currentTime <=110000
and condition1 and (value31 > value31[1] or value7 > value7[1] )
and value7*1.0045 < getField("High","D")
then setposition(minList(position+1,1),GetField("收盤價","Tick"),label:="買1");//有庫存時,不進場加買,維持一張
if condition2 and GetField("收盤價","Tick") < GetField("收盤價","Tick")[1]
then setposition(maxlist(position-1,0),GetField("收盤價","Tick"),label:="賣1");//希望沒有庫存時,不進場放空,亦即減碼至空手
end;
B程式碼
// 買賣條件檢查
if position = 0 and filled = 0 and condition90 then begin
if currentTime > TM and currentTime <= 110000 then begin //多了這一段會有影響?
if condition1 and (value31 > value31[1] or value7 > value7[1]) and value7 * 1.0045 < getField("High", "D") then
setposition(minList(position + 1, 1), GetField("收盤價", "Tick"), label := "買1");
if condition2 and GetField("收盤價", "Tick") < GetField("收盤價", "Tick")[1] then
setposition(maxlist(position - 1, 0), GetField("收盤價", "Tick"), label := "賣1");
end;
end;
4 評論