問題一:
這兩個腳本的差別只有第一行和第二十二行不同而已
第一個將close >= highest(high,10)寫在結尾的if判斷式中
第二個則是改成在第一行寫入if close<highest(high,10) then return;
目的都是想過濾出符合 今日收盤價>=過去十日中最大的最高價(high) 的標的
我以為這兩種寫法過濾出來的東西會是一樣的?
但在回測中跑出來的結果卻差異不小
是語法的使用上有什麼問題嗎?
//if close<highest(high,10)
//then return;
moneyflow(14,6,value1,value2);
input:day(2,"短期天數"),day2(15,"長期天數");
variable:tvp(0),mpc(0),osci(0),k(0);
mpc=(open+high+low+close)/4;
if volume <> 0
then
if mpc[1]<>0 then
tvp=tvp[1]+(mpc-mpc[1])/mpc[1]*volume
else
tvp=tvp[1];
if average(tvp,day2) <> 0
then
osci=1000*(average(tvp,day)-average(tvp,day2))/average(tvp,day2);
if value1 >=50
and osci >= 2
and close >= highest(high,10)
then ret=1;
if close<highest(high,10)
then return;
moneyflow(14,6,value1,value2);
input:day(2,"短期天數"),day2(15,"長期天數");
variable:tvp(0),mpc(0),osci(0),k(0);
mpc=(open+high+low+close)/4;
if volume <> 0
then
if mpc[1]<>0 then
tvp=tvp[1]+(mpc-mpc[1])/mpc[1]*volume
else
tvp=tvp[1];
if average(tvp,day2) <> 0
then
osci=1000*(average(tvp,day)-average(tvp,day2))/average(tvp,day2);
if value1 >=50
and osci >= 2
//and close >= highest(high,10)
then ret=1;
問題二:
在出場條件的腳本中我使用的語法是
close cross below nthhighest(1,close,60)*(100-ratio)*0.01
目標是當 今日收盤價低於 最近一次的最高收盤價X%就出場
但在回測結果中發現程式會使用該日的最高價(high)來計算比例而不是使用收盤價(close)?
類似的情形也出現在使用回測中的%數停損,如果沒有勾選逐筆洗價的話不是應該用當日收盤價來判斷是否滿足停損條件嗎?
1 評論