Limit event to first ocurrence

A forum for all EdgeRater users

Moderator: Chris White

Post Reply
dan2fl
Posts: 7
Joined: Thu Oct 02, 2014 1:00 pm

Limit event to first ocurrence

Post 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
Chris White
Posts: 200
Joined: Mon Nov 29, 2010 9:21 pm

Re: Limit event to first ocurrence

Post 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.
dan2fl
Posts: 7
Joined: Thu Oct 02, 2014 1:00 pm

Re: Limit event to first ocurrence

Post by dan2fl »

Hi Chris,
Thanks for responding so quickly and for an elegant but simple solution,
Dan
Post Reply