Guest User | Sign In

Knowledge Base

TimeSinceSignal Function

This function allows you to display the number of bars / days / weeks / months or years since a specified true condition has been met. For example this formula counts the number of trading days since the close was below the 200 day moving average:

//Define the true condition in variable V1
V1 = CLOSE() //Calculate time since V1 was true
In this example, Visa hasn't closed below its 200 day MA in 457 trading days:

Note: the Show View is using Dot as the Plot Style

To count days since a moving average crossover

This will calculate positive numbers since a 20EMA crossed above a 50SMA, and negative for a cross below:

// Calculate the MAs
20EMA = MA(BARS=20, STYLE=Exponential, CALC=Close);
50SMA = MA(BARS=50, CALC=Close);
// Calculate time since the MA cross
r1 = TIMESINCESIGNAL(20EMA crosses 50SMA);
// Is it a cross above?
r2 = 20EMA > 50SMA;
//Multiply by -1 to get negative numbers
r3 = r1 * -1;
//If cross is above use positive r1 value, otherwise use the negative r3 value
IF(r2 == 1,r1,r3)

To find a new high that occurred X days ago

This formula finds new 52 week highs that occurred 3 days ago:

V1 = HIGH() > HIGHESTHIGH(RANGE=Look Back Period, BACKTYPE=Weeks, BARS=52);

For new all-time highs that occurred within the last 5 days:


Please Wait!

Please wait... it will take a second!