In order to close a long order I want that:
1) First and foremost a long order must be open
2) RSI Crossed above 70
3) RSI Crossed below 70
4) RSI Crossed above 70.
For 2) to happen, 1) must have happened first;
for 3) to happen, 2) must have happened before;
for 4) to happen, 3) must have happened before;
Only when the 4 conditions happen the action of closing the order is triggered.
I've tried to create a logic using bool variables for each step that I activate / deactivate but it doesn't seem to work like I was expecting.
Is there any more elegant way of doing this?
SideNote: This is a simplified silly example and not an actually strategy that I tested; All i want is understand the logic of how would be an elegant and effective way of programming it.
Thanks in advance for all your help,
Comment