Check if condition happened in previous values
1 view (last 30 days)
Show older comments
cctbbo = 100.*(Close + 2.*movstd(Close,[BBOlength 0]) - movavg(Close, 'simple', BBOMAlength ))./(4 .*movstd(Close,[BBOlength 0]));
BBobline = 80;
BBosline = 20;
sl1 = cctbbo < BBosline;
Basically I need to check if sl1 is true for any of the previous 20 values at any point in the vector Close. Pretty new to MatLab so I'd appreciate the help. Thanks!
0 Comments
Answers (1)
DGM
on 15 Feb 2022
Edited: DGM
on 15 Feb 2022
Consider the simplified example:
cctbbo = randi([10 99],1,40);
BBosline = 20;
sl1 = cctbbo < BBosline; % some logical vector
wsize = 5; % shorter window for demonstration
sl2 = imdilate(sl1,[zeros(1,wsize+1) ones(1,wsize)]); % offset moving maximum filter
[sl1; sl2] % compare input and output
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!