This has been driving me nuts for a short while...
[and i am a professional programmer of more common languages like Java]
Its really a general question about how to only detect a condition, like crossover within the last few minutes, and ignore crossovers that occurred earlier in the time period.
To make this clear... lets say your looking at a 1 min chart, and its the afternoon..
and your running a plot like this
def ema1 = ExpAverage(close, 8);
def ema2 = ExpAverage(close, 88);
def emaCrossingAbove = ema1[1] < ema2[1] and ema1 > ema2;
plot aaa = ema1;
plot bbb = ema2;
plot scan = emaCrossingAbove;
scan.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
And it works ok... it detects the crossover above, and indicates with an arrow
and you can use it in a scan (of course)
however, and here is the real dig... you dont care if there were three crossovers in the morning
you only want to know if one has occurred within the past 5 minutes (or some period of time) from current moment
similarly... you have two averages.
def ema1 = ExpAverage(close, 8);
def ema2 = ExpAverage(close, 88);
and you want to indicate with an arrow if their distance apart is a certain amount
call it an almost cross over...
and of course, like above, you dont care if they almost crossed over (to the dark side?) earlier in time
These two things been driving me nuts to implement..
as the 2nd one can help detect a widening average, or converging average..
however the question of event in time or past x time, can help a whole lot in a lot of ways...
any takers?