Check if condition happened in previous values
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
DGM
el 15 de Feb. de 2022
Editada: DGM
el 15 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!