jpb![]() Veteran ![]() ![]() ![]() Posts: 168 Joined: 5/11/2005 Location: Brown Deer, WI ![]() | I'm not sure I'm following what you are trying to do with your exit logic. Looking at your screenshot of IBM, you have a long signal in early January 2019. The bars are above your 21 day SMA until sometime in March. At that point, it looks like the RSI-C short signal is older than 5 days ago and is generated by the RSI-C crossing over the 80 threshold from above. That's an event, but I don't think it means that you are still in a short - does it? I guess I'm missing the conditions that fire the long and place you in the trade. You might consider something like this: If C < SMA(21) AND ((HHV(RSI-C(5, 30, 80),5) > 80) AND RSI-C(5, 30, 80) < 80) Then ... initiate your exit. Essentially, use the Highest High Value function looking back over the last 5 periods using the RSI function for the data and check the HHV value to see if it was above 80 at any point. If it was, then you know there is a potential to have the short signal triggered. Then you check the current value of the RSI function to see if it is less than 80 to say that it would have been triggered. Maybe this isn't what your looking for, but perhaps it will trigger some more thoughts. I'd suggest breaking the IF statement apart so it isn't doing all the calculation in it -- I'm shooting from the hip on if that's the logic you are looking for. There might be holes in it for what you want to accomplish. |