小幫手 您好
若頻率設5分鐘,想找出開盤第1根為黑K,但後來上漲又拉回回測MA20的股票,請問以下程式碼是否OK?
謝謝! (特別是對於頻率為5分鐘,開盤第1根第2根 或最新1根的函數寫法,不知是否正確?)
Value11 = GetField("close", "D")[1]; //昨天收盤價
Value12=q_EstimatedTotalVolume; //GetField("估計量")
Value13= Average(close,20); //若頻率為5分鐘,則指5分鐘線圖的ma20
if currentdate <> date then return;
if time = 091000 then
begin
value1 = getfield("open","5")[2];//第一根5分K開盤價
value2 = getfield("high","5")[2];
value3 = getfield("low","5")[2];
value4 = getfield("close","5")[2];
end;
condition1= value1 > value4; //第一根為黑k
condition2= getfield("open","5")[1] <getfield("close","5")[1] ; //第二根為紅k
condition3= getfield("open","5")[0] <getfield("close","5")[0] ; //第三根為紅k
condition4= getfield("close","5")[0]> getfield("high","5")[1] ; //第三根收盤高過第二根高
condition5= getfield("close","5")[0]> getfield("high","5")[2] ; //第三根收盤高過第一根高
condition6= CloseD(0) >= Value11*1.02; //盤中最新收盤價已漲2%
condition7= CloseD(1)<= Value13 and CloseD(1)>= Value13*0.99 ; //上一根k的收盤價小於=5分鐘線圖的ma20,但收盤價距ma20最多1%
condition8= CloseD(0)>openD(0) ; //最新1根為紅K
condition9= CloseD(0)>HIGHD(1) ; //最新1根K收盤價比上一根k的高點還高
condition10=Value12>GetField("Volume", "D")[1] ;//估計量大於昨量
if condition1
and (condition2 OR condition3 ) //第二或三根為紅k
and condition4
and condition5
and condition6
and condition7
and condition8
and condition9
then ret=1;
4 評論