calculate boolinger bandwidth using matlab function
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
Which software package is stdev2 part of? It does not appear to be a Mathworks function
채택된 답변
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
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.
oky thank
As always, my pleasure!
>> 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.
.
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?
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.
.

the original...std2 requires image processing toolbox
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)

