想請問為何我的code 不能用日頻率做回測?
我有限制BarFreq, BarInterval 都是日線級別
但實際看進出點位, 卻還是會有當日進出的現象
謝謝
input: pma1(5,"price average 1"), pma2(10, "price average 2"), pma3(20, "price average 3"), pma4(60, "price average 4"),
vma1(6, "vol average 1 "), vma2(12, "vol average 2") ;
settotalbar(pma4+30);
// Arrays:Price[100](0);
// Arrays:For_volume[100](0);
variable: price1(0), price2(0), price3(0), price4(0); // variable initialized
Value1 = GetField("Close", "D");
Value2 = GetField("Volume", "D");
// 先判斷目前是分鐘線
If BarFreq = "D" Then
Begin
If BarInterval = 1 Then
Begin
// 資料為30分鐘線
if
// Hour(Time) > 12 and
Value1[0] > Value1[pma1] and
Value1[0] > Value1[pma2] and
Value1[0] > Value1[pma3] and
Value1[0] > Value1[pma4] and
Value2[0] > Value1[vma1] and
Value2[0] > Value1[vma2]
then
Begin
setposition(1);
price1 = lowD(0);
print ("Buy in on", NumToStr(Date, 0), "low price= ", price1, "vol", Value2[0]);
End;
if
close Cross Below price1 and
close Cross Below Average(Close, pma1)
then setposition(0);
End;
End;
1 評論