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!