
進場腳本:
input: averageVolume(1000);
variable:rsv_d(0), KK(0), dd(0);
stochastic(40,3,3, rsv_d, KK, dd);
value1 = average(close,60);
value2 = LinearRegSlope(value1,60);
Value3 = q_Last;//成交價
value4 = average(GetField("Volume", "D")[1], 5);//"5日均量"
condition1 = KK < 40 and KK[1] >=40 and KK[2] >=40 and KK[3] >=40;
condition1 = close < value1;
condition2 = close[1] >= 20 and value4 >= averageVolume;
condition3 = close < close[1];
condition4 = value2 > 0;
condition5 = value2 < value2[1] ;
condition6 = close cross above average(close,20);
condition7 = KK cross above 20;
//進場
variable:byin(false),byprice(0);
if byin=false and condition1 and condition2 and condition3 and condition4 and condition5
then
begin
byin=true;
ret=1;
byprice=close;
end;
{//出場
if byin=true and condition6 or condition7;
begin
byin=false;
ret=1;
end;
//尾盤出場
if byin=true and time > 132400 and volume > 0 then
begin
byin=false;
ret=1;
end;}
print(time,rsv_d, KK, dd,byin,byprice,condition1,condition2,condition3,condition4,condition5);
出場腳本:
input: averageVolume(1000);
variable:rsv_d(0), KK(0), dd(0); //宣告3個參數
stochastic(40,3,3, rsv_d, KK, dd); //XQ內建寫好的KD函?==>呼叫他
value1 = average(close,60);
value2 = LinearRegSlope(value1,60);
Value3 = q_Last;//成交價
value4 = average(GetField("Volume", "D")[1], 5);//"5日均量"
condition1 = KK < 40 and KK[1] >=40 and KK[2] >=40 and KK[3] >=40;
condition1 = close < value1;
condition2 = close[1] >= 20 and value4 >= averageVolume;
condition3 = close < close[1];
condition4 = value2 > 0;
condition5 = value2 < value2[1] ;
condition6 = close cross above average(close,20);
condition7 = KK cross above 20;
//進場
variable:byin(false),byprice(0);
if byin=false and condition1 and condition2 and condition3 and condition4 and condition5
then
begin
byin=true;
byprice=close;
end;
//出場
if byin=true and condition6 or condition7 then
begin
byin=false;
ret=1;
end;
//尾盤出場
if byin=true and time > 132400 and volume > 0 then
begin
byin=false;
ret=1;
end;
print(time,rsv_d, KK, dd,byin,byprice,condition1,condition2,condition3,condition4,condition5);
煩請解答!
2 評論