I’m trying to use ACCSINCESIGNAL but can’t get it to work, no doubt something simple but I can’t see it.

I want to count the number of bars where a MA has been down since the MA turned down.

Any assistance in spotting the obvious error will be greatly appreciated! :slight_smile:

10MA = MA(Day(), STYLE=Weighted, BARS=10, CALC=HLC) ;
10MATurn = 10MA TurnsDown ;
V1 = IF(10MA IsDown, 1, 0) ;
V2 = BARDATE(10MATurn) ;
DownCount = ACCSINCESIGNAL(V1, V2) ;
DownCount < 5

Hi Kim,

Try the TIMESINCESIGNAL() function instead. This will count days since it turned up (positive number) or since it turned down (negative).

//Define moving average
10MA = MA(STYLE=Weighted, BARS=10);
//Time since the 10MA turned up or down
//Is 10MA sloping Up?
Up1 = 10MA IsUp;
//Multiply T1 by -1 to get negative numbers
T2 = T1 * -1;
//If Up1 is true use positive number, else use negative
IF(Up1 == 1,T1,T2)

The blue Show Bars indicate when the 10WMA turns, so SAR:ASX turned up 42 days ago, whereas OML:ASX turned down 23 days ago:


For more TIMESINCESIGNAL examples see here:

Thanks Darren, but I haven’t explained my goal properly. I want to know how many of the bars since the signal were down rather than just how long ago it was.

For example, I’d like the script to tell me it turned 8 bars ago and since then have 5 or more bars been “IsDown”?

Is that possible?


Ah OK sorry. You don’t need to specify a date in the ACCSINCESIGNAL function - it implies the date when the turn is triggered. To count the number of down days since a turn:

10MA = MA(STYLE=Weighted, BARS=10) Turns;
C1 = CHANGE()<0;
//How many times has C1 occuured since 10MA occurred?

So taking the previous example, both SAR:ASX and OML:ASX have had 15 down days since the 10WMA turned (including signal day):


So simple yet exactly what I need - many thanks!!