# Signal Testing example

For clients with access to the quantitative Signal Testing module, you can run tests on technical and calendar events using scripting.

Here’s an example on 1st quarter performance in the \$SPX which we tweeted here: https://twitter.com/Optuma/status/1642534097020162048?s=20

It’s based on the same concept as this January Barometer article but instead we look at performance after the first quarter rather than the first month.

To calculate the performance for the rest of the year when the first quarter has been positive, run this on a monthly timeframe with the Periods Before set to 3 (ie January - March) and the Periods After to 9 (April - December):

```//Get quarterly data;
Q1 = MONTH(PERIODAMOUNT=3);
//Signal when month turns to April and Q1 close is higher;
V1=MONTHNUM() ChangeTo 4 and Q1[1] IsUp;
//offset by 1 to get the March closing value;
V1[-1]```

2023 was the 47th time this occurred in the \$SPX, and the results show that out of the previous 46 events the year closed higher 87% of the time, with an average return of +9.5%. On the results chart the period of -3 to 0 is January to March, and 0 to 9 is April to December:

To change the test for when the first quarter is negative change Q1[1] to IsDown (and for all years delete the Q1 condition)

`V1=MONTHNUM() ChangeTo 4 and Q1[1] IsUp;`

Can you please provide Guidance on Signal Test Script I can use to test what occurs after a negative return from Sept 1st - Sept 20th. Id like to be able to modify the script for future time frames… I came up with this nonsense that clearly isn’t right after finding a previous forum post

```//Get September 1 - 20 data;
Sept20 = MONTH(PERIODAMOUNT=9) and DAY(Periodamount = 20);

//Signal when turns to September 21 and Septemebr 1 - 20 close is negative;
V1=MONTH(PERIODAMOUNT=9) and DAY(PERIODAMOUNT=20) ChangeTo MONTH(PERIODAMOUNT=9) and DAY(PERIODAMOUNT=21) and Sept20 IsDown;

V1```

Hi Christopher,

You could use MONTHNUM()==9 and DAYNUM()==20 but it gets tricky when the 20th falls on a weekend…

I can’t think of an easy way, but here’s a Seasonality chart of the average September for SPX, showing the dropoff at the end of the month:

ok thanks, i have looked into that style that you showed me and that is great for wheat it is … im interested in stats on this type of stuff, probabilities, ROR over period of time after like the signal tester gives… so if im hearing you correctly it is a day ending on the weekend issue… could this be solved if i used say an end of week # like the 3rd (ending) week of september or week 38 of the year. Is there a script for something like that to plug into the Signal tester?

Here’s a solution: we can use DAYNUM() CrossesAbove 19 so it will take the next trading day if the 20th is a weekend:

```//Set signal day and month;
V1=DAYNUM() CrossesAbove 19 and MONTHNUM() == 9;
//Get daily MTD% value;
M1=100*(CLOSE()/(MONTH()[1]))-100;
//If MTD% value < 0 when V1 occurs, take signal;
V1 and VALUEWHEN(M1, V1)<0```

The Signal Test is set to 13 periods (trading days) before the signal (ie Sept 1st - 20th) and 9 days after to the end of the month. Of the 34 years that the SPX was negative Sept 1st - 20th (avg loss -3.32%) the index went on to lose another 0.42% for the rest of the month, with a Probability of Gain of 45%:

For the 40 times when the SPX is positive for Sept 1st - 20th (change the last line to >0) the results are very similar, with the avg gain from Sept 1st of 2.5%

Great thanks!!! I really appreciate the time you took to work this out for me. I should be able to take this frame work and use it for other time frames. Thanks again.