下面這段自動交易,簡單的說就是想用,當下位階 時間 跟均價的關係去決定進場,
如果我用3分鐘的頻率可以回測,
但是用了一分鐘的頻率就沒有辦法,
想請教問題出在哪?

if Date<>CurrentDate then return;
input: up(4,"High");
input: down(-1,"Low");
input: i1(091130,"進1");
input: i2(091530,"進2");
input: r1(6,"風控"); //出場風控
//進場條件
if i1<=time and time<=i2 // i1<進場<i2
and (1+0.01*down)*closeD(1)<close[0] //當下價格在前天down%以上
and close[0]<(1+0.01*up)*closeD(1) //當下價格在前天up%以下
and C <= getfield("均價") //價格在均價下方
and (getfield("均價")-C)/C <= 0.01 //乖離1%
and position=0
then setposition(-1);
//進場條件
if
c>getfield("參考價", "D")*(1+0.01*r1) //用當天位階當風控
and Position <> 0
then setposition(0);
//出場條件


2 評論