Page 1 of 1

Limit event to first ocurrence

Posted: Thu Sep 28, 2017 4:20 pm
by dan2fl
Hi
There are a number of system scans in Edgerater that refer to an existing condition, rather than a crossover.

One example is High Close which generates an event if the close price is higher than every prior close price over the last N bars.

The problem I am having is to code this so that only the first instance is recorded, not every consecutive high close. If we set N equal to 5 and the close price keeps going up, there would also be an event for the 6th, 7th 8th etc for as long as the trend keeps going up.

I have not been able to come up with a solution although something similar is done with the SIM_2_20EMA upside breakout. I have not been able to transfer that concept to the High Close Scan.

Help would be appreciated.
Dan

Re: Limit event to first ocurrence

Posted: Fri Sep 29, 2017 9:21 am
by Chris White
Hi Dan,

One way of achieving this is to generate an event whenever the HighClose signal goes from 0 to 1. You can use the CROSS function for that to detect a cross of the 0.5 value.

Here's a complete solution:

Code: Select all

HC: (HHV(C, N) == C);
Event: CROSS(HC, 0.5);
Chris.

Re: Limit event to first ocurrence

Posted: Fri Sep 29, 2017 12:50 pm
by dan2fl
Hi Chris,
Thanks for responding so quickly and for an elegant but simple solution,
Dan