Half function idea

Had an idea for a function that would retrieve % return data from definable 6 month periods (H1 or H2 and year). See attached for an example on how a watch list could utilize the function.

Screenshot_20220419-032140_Drive

Thanks Jeff. You could adapt the formulas used to calculate the Quarterly performance seen here. For example, H1 2021 would be as follows:

//Get monthend; 
M1 = MONTHNUM() == 6 and YEARNUM() == 2021;
//Get previous monthend;
M2 = MONTHNUM() == 12 and YEARNUM() == 2020;
//Get closing values;
V1 = VALUEWHEN(M1);
V2 = VALUEWHEN(M2);
//Calculate % change;
((V1/V2)-1)

For H2 2021 change M1 to MONTHNUM() == 12 and YEARNUM() == 2021; and M2 to MONTHNUM() == 6 and YEARNUM() == 2021;

The Current Half would be M1=CLOSE(); and M2 = MONTHNUM() == 12 and YEARNUM() == 2021; before the end of June, and then M2 = MONTHNUM() == 6 and YEARNUM() == 2022; afterwards.

Here’s the SPDR ETFs (workbook attached):

HalfYearlyPerformance.owb (41.9 KB)

Hi Darren,

Thank you for the code, workbook, and reference to the quarterly article; all are useful. It would be neat if all of this could be wrapped into a function to make it even simpler. A function that would look something like “TimePeriod(select Quarter/Half/Etc, Q1/H1/etc)”. That would be quick and easy for watchlist construction and also useful in signal tester research when using these. I’m certainly ok using the code and readjusting it as needed, just my two cents for a new idea. It also could incorporate years - I would really like to have something that can isolate particular years for signal testing, such as using only mid-term election years or a custom list of years via a check-box selection or some other way to import and even save and title a list of years (ex: u.s. mid term year list) maybe via csv or cut and paste (currently I know how to manually add in or exclude certain years but having an easier way that saves time would be great).

Jeff