腳本B何處有誤,希望盤中、回測都適用,但都沒交易出現?
腳本A,有買賣都交易委託成交的資料
input:X1(0.5,"%停利"),X2(1,"%停損");
value1=getField("均價");
value2=(close+open)/2;
//value3=average(value2,5);
if position=0 and filled=0 and trueAll(close > close[1],2) and close > value1 then setposition(position-1,close,label:="賣1");
if position<>0 and filled<>0 then begin
value4=100 * (Close - FilledAvgPrice) / FilledAvgPrice;
if value4 <=-X1 then setposition(0,close,label:="賣出有跌停利");
if value4 >=x2 then setposition(0,close,label:="賣出有漲停損");
end;
腳本B沒有資料,
因(value1也試過用getField("均價"))、value4=q_last也試過用close。結果都只有買進沒賣出!}
input:X1(0.5,">買進有漲%停利"),X2(1,"<買進有跌%停損"),X3(0.5,"<賣出有跌%停利"),X4(1,">賣出有漲%停損");
value1=q_AvgPrice;
//value3=average(value2,5);
value4=q_last-value1 ;
switch (value4 )
begin
case 1:
if value4 > 0 then begin
if position=0 and filled=0 and trueAll(close > close[1],2) and close > value1 then setposition(position+1,close,label:="買1");
if position<>0 and filled<>0 then begin
value5=100 * (Close - FilledAvgPrice) / FilledAvgPrice;
if value5 >=X1 then setposition(0,close,label:=">買進有漲停利");
if value5 <=-x2 then setposition(0,close,label:="<買進有跌停損");
end;
end;
case 2:
if value4 < 0 then begin
if position=0 and filled=0 and trueAll(close < close[1],2) and close < value1 then setposition(position-1,close,label:="賣1");
if position<>0 and filled<>0 then begin
value6=100 * (Close - FilledAvgPrice) / FilledAvgPrice;
if value6 <=-X3 then setposition(0,close,label:="<賣出有跌停利");
if value6 >=x4 then setposition(0,close,label:=">賣出有漲停損");
end;
end;
end;
1 評論