# Knowledge Base

### Accumulation Since Signal Function - ACCSINCESIGNAL()

### Overview

**ACCSINCESIGNAL(Source, Signal)**

This function takes two scripts, the first script is the value which is accumulated and the second script is a Boolean value that signals a reset of the accumulation.

This example counts the number of positive days since the first trading day of 2019 using the BARDATE() function:

**//Is it a positive day?**

V1 = CHANGE()>0;

//Count how many times V1 was true since Jan 2nd 2019;

ACCSINCESIGNAL(V1, BARDATE()==43467)

V1 = CHANGE()>0;

//Count how many times V1 was true since Jan 2nd 2019;

ACCSINCESIGNAL(V1, BARDATE()==43467)

To calculate the % of positive days in 2019:

//Is it a positive day?

V1 = CHANGE()>0;

//All days will have a price > 0, so this will count the trading days;

V2 = CLOSE()>0;

//Count how many times V1 was true since Jan 2nd 2019;

V3=ACCSINCESIGNAL(V1, BARDATE()==43467);

//Count how many trading days since Jan 2nd 2019;

V4=ACCSINCESIGNAL(V2, BARDATE()==43467);

//Calculate the %

V3 / V4

//Is it a positive day?

V1 = CHANGE()>0;

//All days will have a price > 0, so this will count the trading days;

V2 = CLOSE()>0;

//Count how many times V1 was true since Jan 2nd 2019;

V3=ACCSINCESIGNAL(V1, BARDATE()==43467);

//Count how many trading days since Jan 2nd 2019;

V4=ACCSINCESIGNAL(V2, BARDATE()==43467);

//Calculate the %

V3 / V4

MFG has had 95 positive days at time of publishing, or 66.4% of the total number of trading days:

Another example:

**R1 = RSI() > 75;**

R2 = RSI() < 72;

c1 = SWITCH(R1, R2);

c1_on = c1 and (OFFSET(c1, OFFSET=1) <= 0);

ACCSINCESIGNAL(RSI() , c1_on)

R2 = RSI() < 72;

c1 = SWITCH(R1, R2);

c1_on = c1 and (OFFSET(c1, OFFSET=1) <= 0);

ACCSINCESIGNAL(RSI() , c1_on)

This example script would accumulate the RSI values when the c1_on signal changes to a value of 1.