Detect if a condition happened within last 5 bars

This is the place to discuss EdgeRater Chart Script

Moderator: Chris White

Post Reply
anon
Posts: 6
Joined: Tue Mar 29, 2011 3:25 pm

Detect if a condition happened within last 5 bars

Post by anon »

We are attempting to develop a script that basically
says : If there was a RSI(C,2) cross of 25 level within the last 5 bars,
continue to conditions 2.

I have been attempting this with the BACKSET
command which compiles but does generate
any signals and shows NaN in the event window.
backsetquestion.png
backsetquestion.png (105.9 KiB) Viewed 1985 times
Any suggestions?

Thanks
Chris White
Posts: 212
Joined: Mon Nov 29, 2010 9:21 pm

Re: Detect if a condition happened within last 5 bars

Post by Chris White »

You could use BARSSINCE. Here’s an example:

Code: Select all

rsicross: CROSS(RSI(C,2), 25);
bscross: BARSSINCE(rsicross);

cond1: bscross < 5;
barssinceexample.png
Post Reply