QLD Long Trading System

Hello, trying to code in one more trading idea from @QuantpTrader on Twitter. In layman’s terms the buy rules are…

  1. Ticker(“QLD”)
  2. The high yesterday was greater than the high 5 days ago
  3. The indicator “InterInd” is at the lowest low value of the last 15 days ← I can’t figure this part out :frowning:

InterInd = Close(0) - Close(8)

I think we are looking for an oversold condition over the last 15 days that is starting to break out in the short term.

Anybody able to help with the code on how to require that the custom indicator @InterInd is at it’s lowest level in 15days? I’ve attached my attempted loopsum. If I get it working, I’ll share the equity curve.


buy rules attempt QLD.jpg


Ok, slept on this and added the code in this way using 8 day rate of change counter. I THINK this meets the intent, so anyway here are the updated buy rules and equity curve. It’s in the market less than 20% of the time, so filling the remainder with other trades or bonds would provide a very nice equity curve.



What is the sell rule?

It’s listed in the screengrab up top. I read it as Close(0) is greater than the Hi(3) from 3 days ago.

The formula for the indicator (Close(0) - Close(8)) to be at, or below the lowest low of the indicator over the last 15 days is:
(Close(0)-Close(8)) <= LoopMIN(“(Close(CTR)-Close(CTR+8))”,15,1,1)

But this is not a good timer at all.

Georg - I don’t think the formula should have 15,1,1 at the end, but instead should be simply 15,0.

The difference between Georg’s and Shawn’s formulas is when the minimum of ROC(8,0) and the minimum of Close(0)-Close(8) are different. For example, if a stock drops from $3.00 to $1.95 on one day and from $1.95 to $0.95 the next, the first will be lower on the close(0)-close(8) measure and the second will be lower on the ROC measure.

Georg - when you say “this is not a good timer at all,” are you including the other rule, Hi(1) > hi(5)?

LoopMin(“formula”,iterations[,start,increment,noNAs,break])
iterations =15
start=1 (not 0, because the last 15 days does not include the current day))
increment=1

So my formula is correct.
(Close(0)-Close(8)) <= LoopMIN(“(Close(CTR)-Close(CTR+8))”,15,1,1)

It is the same as:
(Close(0)-Close(8)) <= min(Close(1)-Close(9),Close(2)-Close(10),Close(3)-Close(11),Close(4)-Close(12),Close(5)-Close(13),Close(6)-Close(14),Close(7)-Close(15),Close(8)-Close(16),Close(9)-Close(17),Close(10)-Close(18),Close(11)-Close(19),Close(12)-Close(20),Close(13)-Close(21),Close(14)-Close(22),Close(15)-Close(23))

With added buy rule: Hi(1) > hi(5) and sell rule: close(0) < hi(3) it is still a completely useless indicator.

A market timer should not be specifically designed for the 2x leveraged QQQ, but it should work with any long ETF.