This is just a "sample indicator" example code condition, but I would like to do the following. I am wanting it to execute only if the sample indicator is greater than > 1 BUT less < 2 IF the condition lasts for more than X seconds (say X is like 30 seconds as an example). How would I condition for the X seconds? I think the first two for greater than BUT less than is ok...just need to include the seconds component (or some equivalent that would work well) and have it reset each time the condition goes back below >1 or above <2 each time.
---
&& sample indicator[0] > 1
&& sample indicator[0] < 2
&& the two above sample indicator conditions last for greater than x seconds (say 30 seconds for this example).
I would want to be sure it resets the seconds counter each time the condition goes outside or below 1 and /or outside or above 2 so if it comes back down it the range the seconds counter would start over.
---
The idea is that I want to exit if the condition is sustain for some time, BUT if there is a move past or beyond these conditions in a fast moving market, I don't want it to execute a exit while in between these conditions (rather I want it to keep me in longer to benefit from the faster moving market). Then, I might have a different condition to get me out at a better level (separate condition from the above).
Do you have some thoughts on how I can achieve in the code and where to put it. I am sure some kind of seconds counter variable I would have to add too etc...
Comment