How to call a timer-based ETF from a *stock* ranking system or a *stock* Portfolio?

Hi all,

I would like to ask for thoughts / feedback from the community on how to implement the idea below. I think I found a way but I wonder if there might be something simpler that I am not seeing. Thank you in advance…

I am testing the idea of using the relative perf of ETFs vs one another to inform me on the current market regime. For example value (IWD) vs growth (IWF) etc.
Then I would dynamically switch on/off nodes in a ranking system and / or switch on / off buy and sell rules in a stock portfolio (please note → not an ETF portfolio)
I am aware that there are other ways to test value vs growth w/o using ETFs but I specifically want to use ETFs and not just those two!

I have the ranking that measures the relative perf → call it “RankETF”. It is also easy to do a screen that only select the top ETF, or is only invested if the top ETF is IWD using the ranking system “RankETF”.

Weaving that into a stock port seems more complicated → I cannot call screen() from a port. Nor can I use portfolio(id) for an stock port to check for the presence of an ETF in an ETF port. I have not yet tried to weave this into a ranking.

My proposed solution (not tested yet):

  1. Create an ETF Universe that will articulate the ranking “RankETF” using a bunch of setvar(@MyRank,forder(,)) or setvar(@Rk,frank(,)) as rules

  2. Assuming I want to know if value is doing great → make this Universe output either nothing or IWD if it is the top ETF for the ranking “RankETF” using the rule → ticker(“IWD”) & @MyRank =1. Note that I use Forder for @MyRank

  3. Create a custom series that counts the # of positions in my ETF universe (0 or 1). If there is one position, it has to be IWD meaning that value is doing well.
    [NB: I remember I had trouble in the past using univcnt() with a zero-sized universe. I did report it on the forum at the time but do not remember if it has been fixed]

  4. then call my custom series in the ranking or stock portfolio as needed to switch on/off nodes and / or buy or sell rules.

Thoughts appreciated.
Thank you in advance

Jerome

Update:

  • the above does not work at step 3 as a custom series cannot use ETF universes!
  • Also Univcnt(“true”) returns an error if the size of the Universe is 0 but a solution is simply to return the top ETF at stage 2 so the size is always one.

I think the way to do this is as follows.

Set up an ETF screen with your RankETF and the ticker (“IWD”) = 1.

Backtest it. Every week the screen will either buy IWD or not.

Download the results of the backtest (the lower results with number of positions and dates).

Take only the columns of dates and positions, save that as a CSV file, and create a data series with that using the new tool we’re introducing today.

Use GetSeries in your new buy rules.

Will that work?

Yuval’s proposal is fine but it won’t work for a live strategy . You’d have to calculate the value every day.

How complicated is this ranking system? If it’s just a few nodes, like the 1 mo return and 6 mo return, the logic you want could easily be written with custom formulas that return true/false depending if IWD is better than IWF and add them up

We can probably leverage what we already have for the Portfolio functions to check for a particular ticker. Might be a very simple thing. I’ll check.

Also not sure why you mention aggregate (custom) series and universes since neither can access the ranking.

THanks

Marco, ETFs and stocks don’t mix.
I have a formula called $portsum. It checks a number of ETF ports whether they hold SPY at a particular time and returns 1 if true. $portsum just adds the numbers, which can range from 1 to 7. So $portsum returns just a number.

However, $portsum is not recognized by stock models, only ETF models can currently use this formula. So it’s probably not a simple thing to make this work for stock ports as well.

Jerome - You can actually call up ETFs in a stock system using GetSeries. Your problem has a very simple solution for the case of 2 ETFs. For example, you could have a conditional ranking node as follows:

SMA(50,0,GetSeries(“IWD”))/SMA(200,0,GetSeries(“IWD”)) > SMA(50,0,GetSeries(“IWF”))/SMA(200,0,GetSeries(“IWF”))

I have been doing this for quite some time with no problems. If you want to employ more than 2 ETFs, well that would take a bit of thought. You would have to explain exactly what you want in detail to see whether it can be implemented.

SteveA

Thank you Yuval, Walter, Georg, SteveA and Marco for your responses.

Let me briefly answer in turn and then provide more details in the next post.

@Yuval - I think this will work but… I had thought of it and kept it as my fallback option if nothing better could be found for the reason that Marco mentioned (very cumbersome in Live trading)

@Marco:

  • Just a few nodes. It would probably work although ranking all available ETFs and then forcing the ones I am interested in on top works better. I think it is because the ranking is more stable over time and less susceptible to whipsaws than pure binary combinations. Please see the public ranking provided below
  • Portfolio() → I will take any improvement / additional features. Speaking of improvements, Univcnt() should return 0 for a zero-sized universe. Not an error msg
  • Why custom series? Why Universe? I was trying to find a way around the silos that are ETF systems on one hand and stock systems on the other hand. And I wanted to use the custom series as a bridge between the two. I.e. a stock portfolio would call a custom series, itself leveraging an ETF Universe that would have rules replicating the ranking (see public universe provided below). Unfortunately, this fails as I did not know that we could not create custom series from ETF Universes. NB: would this be hard to implement?

@SteveA: it could be if I can use FRank rather than SMA. I did not try yet. SMA would allow to do sth but likely not as useful. See next post.

Thank you,

Jerome

More details…

Background:
I started from my frustration that value works on the long run but has long periods of underperformance (late 90’s, or since early 2017) along with “market exuberance, risk-on, etc”. Well articulated by Marc in a recent post even though it was about yield (https://www.portfolio123.com/mvnforum/viewthread_thread,12014#70391).
So I was wondering if I could adjust my systems and reduce the importance I place on value when it is not in favor e.g. when Mr Market is overly optimistic (for example in the ranking system or directly in the portfolio via buy / sell rules).

This idea can be generalized beyond value vs growth in order to adapt an investment strategy to the "current theme(s) / style(s) / Caps / factor(s) / etc " that works at a given point in time.

Approach:
There are so many ETFs nowadays that one could use a set of ETFs to cover all angles {theme / style / Caps / factor / etc} and describes what works at the moment (make sure to read the prospectus for stock selection and weighting). At the simplest level, think IWD vs IWF i.e. value vs growth → what works at the moment?

Assumption: ETFs representing styles, Caps, factors, etc that have done well in the recent past will continue to do so in the next few weeks or months.

Example ranking systemhttps://www.portfolio123.com/app/ranking-system/360617
Key is to force the top x ETFs I am interested in on top. In this case, IWF, IWD are placed 1 and 2 but relative to their respective recent perf last 3-month and 6 month
Note that by starting from the universe “All ETFs”, you get more stability and less whipsaws.

Attached example screen that goes with the ranking → https://www.portfolio123.com/app/screen/summary/235743
As set with rule #2, it is only invested if IWF is #1 in the prior ranking. In cash otherwise.
Other combinations possible e.g. switch to either IWF or IWD depending on which one is #1 (use rule #3).
Note that by starting from the universe “All ETFs”, you get more stability and less whipsaws.

This is where I got stuck →

  • how do I call this result from a stock ranking system to dynamically adjust nodes depending on what has worked in the recent past?
  • how do I call this result from a stock portfolio to dynamically trigger buy / sell rules depending on what has worked in the recent past?

I tried creating a ETF Universe which spits out which of the two ETFs (IWD vs IWF) has best performed recently (it replicates the ranking internally).
https://www.portfolio123.com/app/universe/summary/235746
Note that this can be easily extended to spit out the top x out of y ETFs, with y ETFs covering all styles, factors, themes etc.

Then I wanted to call a custom series that starts from this universe with only one line Univsubset(“IWD”) & univcnt(“true”).
It would return 0 or 1 with 1 indicating that IWD = value is doing well.

I could have then done from my stock ranking or my stock portfolio eval(custom series = 1, value is in favor, value is not in favor)
Problem → one cannot create custom series starting from ETF universes!
I did not know that…

Thank you,

Jerome