由好心的讀者Eagle幫大家測試PJK Volume策略於台指期,測試內容僅供大家參考,目的在於程式碼教學,請勿用於實單交易。

http://wenschair.blogspot.tw/

 


 
 







 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

測試 2000 日 手續費 1200,僅提供日K回測供參考。
 
inputs: Period(20),ttype(1),maxdn(0),maxdvg(0),npsd(0.5),ddays(3), stoploss(50),takeprofit(100);
vars: px(0),vx(0),kvol(0),map(0),mav(0),sdiff(0),madays(0),ma(0),dvg(0),
nd(0),madiff(0),avgv(0),sdv(0),tentry(0),avg2(0),type(0),sc(0),avghl(0),signhl(0);
 
 
{Exit type = 1, On-Balance Volume
           = 2, Chiaken Volume Accumulator
   = 3, Negative Volume Index
   = 4, Positive Volume Index
   = 5  Price and Volume Trend
   = 6  Volume Oscillator (npsd used for exit level
   = 7  Volume rate of Change
   = 8  Low Volume Exit
for Entry filter use negative type}
 
{test exit}
type = ttype ;
if type < 0 then Begin
tentry = 1;
    type = @absvalue(ttype);
end;
 
{Price index}
map = @Average(Close,period) ;
if ddays < 1 then nd = 1 else nd = ddays ;
if map[nd] = 0 then px = 0 else px = (map - map[nd])*100/map[nd];
 
{On Balance Volume}
if type = 1 then Begin
if Close > Close[1] then Kvol = Kvol + Volume
else if Close < Close[1] then Kvol = Kvol - Volume;
end;
 
{Chaikin Volume Accumulator}
if type = 2  then Kvol = Kvol + (((Close - Low)/(High - Low)) - 0.5)*2*Volume ;
 
{Negative Volume Index}
if type = 3 then Begin
if Volume < Volume[1] then Kvol = Kvol[1] - (Close - Close[1])*Kvol/Close[1]
else if Kvol = 0 then Kvol = Volume 
else Kvol = Kvol[1] ;
end;
 
{Positive Volume Index}
if type = 4 then Begin
if Volume > Volume[1] then Kvol = Kvol[1] + (Close - Close[1])*Kvol[1]/Close[1]
else if Kvol = 0 then Kvol = Volume 
else Kvol = Kvol[1] ;
end;
 
{Price and Volume Trend}
if type = 5 then Kvol = Kvol + Volume*(Close - Close[1])/Close[1] ;
 
{Volume Oscillator}
if type  = 6  then Kvol = (@Average(Volume,ddays) - @Average(Volume,Period))*100/@Average(Volume,ddays);
 
{Volume rate of change}
if type = 7 then Begin
if Kvol = 0 then Kvol = Volume ;
if Volume[Period] = 0 then Kvol = Kvol[1] 
else Kvol = (Volume - Volume[Period])*100/Volume[Period] ;
end;
 
{Moving average of Price}
madays = 2*period ;
ma = @Average(Close,madays) ;
madif
arrow
arrow
    全站熱搜

    wenschair 發表在 痞客邦 留言(0) 人氣()