close
http://www.yctseng.net/2011/11/blog-post_5852.html
2011年11月28日
帶成交量的均線於 16:45
因為朋友提問,要計算每一根K棒裡面把成交量的作為價格權重的均線,雖然印象中我以前有分享過,不過...連我自己都找不到,乾脆就寫一個放上來。
先做成函數,未來取用都方便。
函數的程式碼(MultiCharts)內容:
做成指標:
指標的程式碼(MultiCharts)內容:
HTS版的函數程式碼:
先做成函數,未來取用都方便。

函數的程式碼(MultiCharts)內容:
input:Price(Numeric),length(Numeric);
Var:step(0),AllPV(1),AllVol(1),BarVol(1);
AllPV=0;
AllVol=0;
BarVol=Ticks;
for step=0 to length begin
AllPV = Price[step]*BarVol[step] + AllPV;
AllVol = Ticks[step] + AllVol;
end;
if BarNumber > length then
_MAwithVol=AllPV/AllVol;
做成指標:

指標的程式碼(MultiCharts)內容:
input:length(10);
Value1= _MAwithVol(C,length);
plot1(Value1,"VolMA");
HTS版的函數程式碼:
Param:Price(Numeric),length(Numeric);
Var:i(0),AllPV(1),AllVol(1);
AllPV=0;
AllVol=0;
for i=0 to length
AllPV = Price[i]*V[i] + AllPV;
AllVol = V[i] + AllVol;
end for
if BarNumber > length then
_MAwithVol=AllPV/AllVol;
end if
全站熱搜