calculate boolinger bandwidth using matlab function
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
hi..I had a problem relating to the calculation of the boolinger band Using the matlab function (bollinger) is the result equal to the calculation of the standard deviation of its n-period mean? Unfortunately I can't do this test because I need the stdev2 function which is a paid package
2 件のコメント
Walter Roberson
2023 年 11 月 5 日
Which software package is stdev2 part of? It does not appear to be a Mathworks function
shamal
2023 年 11 月 5 日

採用された回答
Star Strider
2023 年 11 月 5 日
編集済み: Star Strider
2023 年 11 月 5 日
The std2 function takes the standard deviation of all the elements in an array (it only has one argument, that being the entire array). You might be able to create your own version of it with:
std2 = @(A) std(A,[],'all');
This has been possible since R2018b.
EDIT —
Since the bollinger function has to have access to std2, use:
function sda = std2(A)
sda = std(A,[],'all');
end
instead, and store it as std2.m on your MATLAB search path where bollinger can find it.
.
10 件のコメント
are you sure that boolinger function use std2 ?
inside boolinger function i see: (bollinger.m)
mstd = movstd(data,[windowSize-1 0],'Endpoints','fill');
but movstd is a simple deviation standard and isn't st2dev function
Star Strider
2023 年 11 月 5 日
The posted error message specifically mentions std2, so I went with that.
I looked up the documentation for std2 and having read it, suggested that the function I wrote should work in place of the one supplied by the Image Processing Toolbox. (I did not look at the std2 code, since from the description in the documentation, that likely wasn’t necessary.) The movstd function is a completely different function (introduced in R2016a), and should be available as part of core MATLAB.
I do not have the Financial Toolbox, so I do not have access to the bollinger function. I could probably have examined its code here, however I did not because that did not appear to be necessary. The error message was clear enough.
shamal
2023 年 11 月 5 日
oky thank
Star Strider
2023 年 11 月 5 日
As always, my pleasure!
shamal
2023 年 11 月 6 日
>> size(E)
ans =
5813 73
sda = std(E,[],'all');
sda =
84168.3021297152
shouldn't the output be a vector?
No. Not with the std2 function. It takes a matrix argument and produces a scalar result.
Example —
E = randn(5813, 73)
E = 5813×73
1.5077 -0.9145 -1.1057 -0.3433 -0.8191 0.7460 0.9449 0.8598 0.3192 0.4612 0.6724 0.6857 -0.0722 1.1562 1.3449 0.0524 0.2939 -0.3781 0.3619 0.5144 0.7103 0.4361 0.6212 -0.2383 0.2125 0.0268 0.3041 1.2633 -0.6146 -1.9296
0.0015 1.5397 0.0938 0.7793 -0.5706 0.6652 0.8560 -0.2855 1.0994 0.3573 0.3857 -0.0690 0.7162 -0.4808 -0.2574 -0.4902 -1.3169 -0.0567 -1.0819 0.6091 -1.7502 -0.8938 -0.0428 -0.1194 0.2951 -1.7957 -0.9584 -0.0162 0.7460 -1.5189
-2.6172 1.0006 -0.3795 0.9147 -1.6972 0.2567 -0.7890 -0.8722 1.1650 2.0989 -1.6144 -1.5146 -0.1391 0.6513 1.7799 0.1028 0.8718 1.0539 0.2129 -0.5966 0.6389 -0.4809 0.9848 -1.0333 -0.1266 -0.1731 -0.4795 -0.8862 0.1397 -0.1902
1.4182 -1.4442 -0.2632 -0.6309 -1.3285 -1.9806 0.0763 0.1604 2.0767 -0.6979 -0.2367 0.4687 -0.8977 0.8387 -0.3688 -2.6979 -0.4539 0.2989 1.9363 -0.5324 0.3281 -0.5110 0.8988 -1.4265 -0.2908 -1.3650 -1.5045 -0.4714 1.3286 -0.5790
1.3047 -0.3634 1.2386 0.6037 -0.5899 1.1245 -1.5164 -2.2307 -1.0607 1.3256 -0.7856 1.9319 1.6657 1.2297 0.9731 -1.0064 -1.1154 -0.3417 1.1952 1.6293 0.5381 -1.0330 1.1182 -0.4067 0.4222 -0.6496 0.9570 -0.1091 -1.0348 -0.7641
-1.4889 0.2707 -0.4839 -1.7514 0.3234 -0.9896 -0.8111 -0.1538 0.6750 -1.4051 -0.7947 -0.0390 -0.2732 0.4048 0.8133 -0.3537 -0.6343 0.6782 -0.9888 -2.1070 -0.8874 -0.1774 0.0964 -0.8686 1.0842 -0.2021 -1.3805 -0.3820 0.0217 0.0558
-0.2186 -0.3304 -1.1681 0.3248 -0.2878 -1.3593 -1.6160 0.4446 -1.1997 -0.4352 -0.3225 -0.9366 -0.5282 0.3265 -2.3220 0.5818 -0.6964 0.2913 -2.7354 -0.1288 0.0610 0.8999 -0.7022 0.7972 -0.1036 -0.2533 -0.7012 0.6534 -0.6135 0.8737
-0.6828 -1.0519 -0.9408 -0.3900 -0.4249 0.3932 -0.6701 -2.1901 0.1883 -1.1954 -0.1798 -0.0270 0.8769 0.5431 -0.1371 -0.4006 -0.3366 0.2179 -0.5972 -0.3660 0.0252 0.9927 -0.4500 -1.0863 1.8969 0.9731 -1.1513 0.1561 1.1947 0.3611
-1.7794 -0.8214 -0.1460 -0.4889 0.3644 2.5722 -0.1202 0.2579 -0.3386 0.4294 -0.0785 -0.8026 0.8540 -0.4725 -1.0556 0.1746 2.1488 3.0950 0.1131 0.3510 -0.0631 -0.1779 0.3887 -0.3832 -0.5195 -0.7192 -0.9414 -0.2946 -0.7950 -0.1262
-0.4106 0.3576 0.1582 -0.1615 0.8556 -1.0670 -0.5686 -0.8650 0.5871 0.1831 -0.9320 -0.5790 1.5331 0.4915 0.5194 0.0244 -0.1471 1.9888 1.5080 1.5883 1.4539 -1.3793 1.0272 -0.7908 -0.1711 0.8800 -1.4684 -1.6496 -0.1028 0.0683
format long
sda = std2(E) % Use Image Processing Toolbox 'std2'
sda =
1.002149086905880
sda = std(E,[],'all') % Use Synthetic 'std2'
sda =
1.002149086905880
The std function will produce a vector for a matrix argument, its dimensions (row, column, page) depending on its dimension argument.
.
shamal
2023 年 11 月 6 日
the original boolinger is :
[~,upper,~] = bollinger(E,'WindowSize',Preset.Dev_periods,'Type',0,'NumStd',Preset.Dev_devNumUp);
>> size(upper)
ans =
5813 73
but if i use you function (std(E,[],'all') i can't get it
How do you suggest I proceed to obtain the same result by not using the boolinger function?
Star Strider
2023 年 11 月 6 日
I am not certain at this point.
I am also not certain what the entire original error message was, since it mentions:
Error in untitled2 (line30)
dev = std2(ma(:,1));
However if the error was in the bollinger function, I would have expected a different error message, specifically pointing to it. (Taking the standard deviation of a vector that ‘ma(:,1)’ appears to be does not require std2. The std function would be sufficient.)
So I am not certain what the problem is.
.
shamal
2023 年 11 月 6 日

the original...std2 requires image processing toolbox
Star Strider
2023 年 11 月 6 日
function sda = std2(A)
sda = std(A,[],'all');
end
as std2.m on your MATLAB search path so that all calls to it can find it.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Uniform Distribution (Continuous) についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
