標準偏差と歪度と尖度の記述
あ~結構疲れるね (>_<)
とりえあえず、扱った分析手法のソースを公開
ただ、正しいかどうかの保証は致しませんw
一応はMulticharts標準装備の関数で数値が一致したけど
Excelとは一致せず ・°・(ノД`)・°・
最初に計算し始めた位置の関係か、使った定義の関係か・・
これらの数値を具体的にどう使用するかはまだ未定
【標準偏差とボリンジャーのソース】
MAtimeが観測日数設定
LastPriceが当日どの値段を採用するかの設定(通常はclose)
Sigmaは標準偏差の倍率ね~
LastPriceの設定で、当日のみ始値を採用とする標準偏差の
計算ができまする~。実務的な処理ね♪
Inputs:MAtime(20),LastPrice(close),Sigma(2);
Vars:count1(0),count2(0),MAsum(0),MA(0),
Avedissum1(0),dev(0),
nBollinUp(0),nBollinDown(0);
Array:Avedis1[500](0);
{MA Setting1}
MAsum=0;
For count1=1 to MAtime-1 begin
MAsum=close[count1]+MAsum;
End;
If currentbar>MAtime+1 then MA=(MAsum+LastPrice)/MAtime Else MA=0;;
{Deviation}
Avedissum1=0;
For count2=1 To MAtime-1 begin
Avedis1[count2]=Square(close[count2]-MA);
Avedissum1=Avedissum1+Avedis1[count2];
End;
Avedissum1=square(LastPrice-MA)+Avedissum1;
If currentbar>MAtime+1 then dev=Squareroot(Avedissum1/MAtime) Else dev=0;
nBollinUp=MA+dev*Sigma;
nBollinDown=MA-dev*Sigma;
Plot1(nBollinUp);
PLot2(nBollinDown);
Plot3(MA);
【歪度のソース】
MAtimeは観測日数設定
LastPriceが当日どの値段を採用するかの設定(通常はclose)
チャート表示のSはMulticharts搭載の歪度計算ね~(一応一致した)
Inputs:MAtime(20),LastPrice(close);
Vars:MAsum(0),MA(0),
count1(0),count2(0),count3(0),
Avedissum1(0),Avedissum2(0),dev(0),
Skwepoint(0),
s(0);
Array:Avedis1[500](0),Avedis2[500](0);
{MA Setting1}
MAsum=0;
For count1=1 to MAtime-1 begin
MAsum=close[count1]+MAsum;
End;
If currentbar>MAtime+1 then
MA=(MAsum+LastPrice)/MAtime Else MA=0;
{M Setting}
Avedissum1=0;
For count2=1 To MAtime-1 begin
Avedis1[count2]=power(close[count2]-MA,3);
Avedissum1=Avedissum1+Avedis1[count2];
End;
Avedissum1=power(LastPrice-MA,3)+Avedissum1;
{Deviation Setting}
Avedissum2=0;
For count3=1 To MAtime-1 begin
Avedis2[count3]=square(close[count3]-MA);
Avedissum2=Avedissum2+Avedis2[count3];
End;
Avedissum2=square(LastPrice-MA)+Avedissum2;
If currentbar>MAtime+1 then
dev=Squareroot(Avedissum2/(MAtime-1)) Else dev=0;
{Skew Setting}
If currentbar>MAtime+1 then
Skwepoint=(MAtime*Avedissum1)/((MAtime-1)*(MAtime-2)*power(dev,3)) Else Skwepoint=0;
s=skew(close,MAtime);
{Plot Setting}
Plot1(Skwepoint);
plot2(s);
【尖度のソース】
MAtimeは観測日数設定
LastPriceが当日どの値段を採用するかの設定(通常はclose)
尖度はMultichartsでも搭載してなかった~。多分歪度の公式
の仕様に沿っているから間違いは無いと思われ。
計算式は長いから区切ったべ!
Inputs:MAtime(20),LastPrice(close);
Vars:MAsum(0),MA(0),
count1(0),count2(0),count3(0),
Avedissum1(0),Avedissum2(0),dev(0),
Kurtpoint(0);
Array:Avedis1[500](0),Avedis2[500](0);
{MA Setting1}
MAsum=0;
For count1=1 to MAtime-1 begin
MAsum=close[count1]+MAsum;
End;
If currentbar>MAtime+1 then
MA=(MAsum+LastPrice)/MAtime Else MA=0;
{M Setting}
Avedissum1=0;
For count2=1 To MAtime-1 begin
Avedis1[count2]=power(close[count2]-MA,4);
Avedissum1=Avedissum1+Avedis1[count2];
End;
Avedissum1=power(LastPrice-MA,4)+Avedissum1;
{Deviation Setting}
Avedissum2=0;
For count3=1 To MAtime-1 begin
Avedis2[count3]=square(close[count3]-MA);
Avedissum2=Avedissum2+Avedis2[count3];
End;
Avedissum2=square(LastPrice-MA)+Avedissum2;
If currentbar>MAtime+1 then
dev=Squareroot(Avedissum2/(MAtime-1)) Else dev=0;
{Skew Setting}
If currentbar>MAtime+1 then
Kurtpoint=(1/MAtime)*
(Avedissum1/power(dev,4))*(MAtime*MAtime*(MAtime+1))/
((MAtime-1)*(MAtime-2)*(MAtime-3))-
3*(((MAtime-1)*(MAtime-1))/((MAtime-2)*(MAtime-3)))
Else Kurtpoint=0;
{Plot Setting}
Plot1(Kurtpoint);