creating a signal without an IF statement
1 次查看(过去 30 天)
显示 更早的评论
Hi again everyone
quick question, using the below code, I want the signal to become 1 when certain criteria are met, I want it to stay as a 1 until another set of criteria are met.
I do not want it to revert back to a zero simply because the first set of criteria no longer exist.
How can I tweak my code to accomplish this or must I use the IF function?
signal = zeros(size(eurUSDClose));
signal(fastMA>slowMA & rsi10mins < 65) = 1;
signal(fastMA<slowMA & rsi10mins > 35) = -1;
Thanks for your help and any tips :)
0 个评论
回答(1 个)
David Hill
2020-6-18
signal(find(fastMA>slowMA & rsi10mins < 65,1):find(fastMA<slowMA & rsi10mins > 35,1)-1) = 1;
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!