SIGNALAFTER() Function
The SIGNALAFTER()
function looks for a signal to occur but only after a previous signal has been met first.
SIGNALAFTER(Signal1, Signal2)
For example, to show when the 20 period moving average turns down after a new 6 month high you would use the following:
S1 = HIGH() > HIGHESTHIGH(BACKTYPE=Months, BARS=6, INCBAR=False);
S2 = MA(BARS=20, CALC=Close) TurnsDown;
SIGNALAFTER(S1,S2)
Shown here with the green Show Bar arrows:
The Signal Number property will show the number of second signals after the first. In the above example the following will show where the 20MA turns down a second time after a new 6 month high:
SIGNALAFTER(S1,S2, NUMBER=2)
Another example showing where 3 consecutive up days (using the DU() function) are immediately followed by 3 consecutive down days:
S1 = DU() == 3;
S1A = TIMESINCESIGNAL(S1) S2 = DD() == 3;
S1A == 1 and SIGNALAFTER(S1, S2)
Including the Same Bar
If you want to include when the signals appear on the same day then you can select the Same Bar option:
Example
The Blue show view has been setup to include instances where the 2 criteria occur on the same bar, the Black show view excludes these instances.