Why is this not buying between 11th and the 4th month?
(((Month > 4) AND (Month < 11)) and Ticker(“XLP XLV XLU”)) or (((Month > 11) AND (Month < 4)) and Ticker(“XLY XLI XLB XLK”))
Why is this not buying between 11th and the 4th month?
(((Month > 4) AND (Month < 11)) and Ticker(“XLP XLV XLU”)) or (((Month > 11) AND (Month < 4)) and Ticker(“XLY XLI XLB XLK”))
What number is greater than 11 and less than 4? I think what you want is Month > 11 or Month < 4, right?
Yes, you’re right. This part, “(((Month > 11) AND (Month < 4)) and Ticker(“XLY XLI XLB XLK”))”, don’t buy any ETF
I have some more complicated date criteria and I break the criteria down into individual selection criteria. So, just for the sake of showing another method to get to your end results:
showVar(@1, 0)
showVar(@1, @1 + (Ticker(“XLP XLV XLU”) AND InSet(Month,5,6,7,8,9,10)))
showVar(@1, @1 + (Ticker(“XLY XLI XLB XLK”) AND InSet(Month,1,2,3,12)))
@1 > 0
Edit: Note that you could change this to a stock screen by using the GICS() function in place of the Ticker() function. For example, one rule I had in such a screen:
showVar(@1, @1 + 10 ^ 6 * (GICS(STAPLE) AND InSet(Month,3,4,5,10,11,12)))
The “10^6” portion means this was the 6th criteria. That means my variable @1 will be a series of zeroes and ones, with at least one value of one and I can quickly see on the list of variables for the screen which of the various criteria it qualified for.
Thank you for your input, rharmelink. What I’m really aiming for here is a backtest in which I only pick up shares from specific sectors at certain times of the year.
So, from November to April, I will only have shares from the sectors XLY XLI XLB XLK, and from May to October, I will only have shares from the sectors: XLP, XLV, XLU
However, I’ve seen that I’m still a little of a newbie to be able to write the entire code. So, when I learn, I usually go through as many of the publicly available simulations as I can, and if I don’t find anything there, I knot a bunch myself, and then I ask here, on the forum.