Index | Recent Threads | Who's Online | Search

New Thread
This topic has been viewed 373 times and has 7 replies
scrichley
QQQ mean reversion coding question

Hey there. Looking to replicate a QQQ trading system from @QuantpT on Twitter. Basically the rules are...

Buy if QQQ

SMA(50) > SMA(125) &
ROC(5) < 0 for each of the last 5 days &
ROC(5) close < ROC(5) yesterday's close

Sell if RSI(2) > 70

I'm getting a worse result than the author who runs the system on Amibroker and I wonder if my code is correct for summing the number of consecutive days with the ROC(5) < 0. His system may be selling the close with RSI(2) > 70 which I don't think I can replicate here?

LoopSum("ROC(5,0) < 0", 5) = 5

Attachment Screenshot_20211128-195508_Chrome.jpg (290599 bytes) (Download count: 99)


Attachment Screenshot_20211128-082607_Twitter.jpg (176902 bytes) (Download count: 109)


Nov 28, 2021 7:05:01 PM       
yuvaltaylor
Re: QQQ mean reversion coding question

Hey there. Looking to replicate a QQQ trading system from @QuantpT on Twitter. Basically the rules are...

Buy if QQQ

SMA(50) > SMA(125) &
ROC(5) < 0 for each of the last 5 days &
ROC(5) close < ROC(5) yesterday's close

Sell if RSI(2) > 70

I'm getting a worse result than the author who runs the system on Amibroker and I wonder if my code is correct for summing the number of consecutive days with the ROC(5) < 0. His system may be selling the close with RSI(2) > 70 which I don't think I can replicate here?

LoopSum("ROC(5,0) < 0", 5) = 5


Buy rules:
SMA(50) > SMA(125)
LoopMin("ROC(5,Ctr)",5) < 0
ROC(5) < ROC(5,1)

Sell rule:
RSI(2) > 70

Results are pretty nice overall - https://www.portfolio123.com/port_summary.jsp?portid=1664925 - but not in the last ten years.

Yuval Taylor
Product Manager, Portfolio123
invest(igations)
Any opinions or recommendations in this message are not opinions or recommendations of Portfolio123 Securities LLC.

Nov 29, 2021 10:05:26 AM       
Edit 1 times, last edit by yuvaltaylor at Nov 29, 2021 10:07:37 AM
WalterW
Re: QQQ mean reversion coding question

It seems to me that;
LoopMin("ROC(5,Ctr)",5) < 0

should be
LoopSum("ROC(5,Ctr)<0",5)=5


No?

Nov 29, 2021 2:21:11 PM       
yuvaltaylor
Re: QQQ mean reversion coding question

It seems to me that;
LoopMin("ROC(5,Ctr)",5) < 0

should be
LoopSum("ROC(5,Ctr)<0",5)=5


No?

Yes, you're right. Either that or LoopMax("ROC(5,Ctr)",5) < 0. Sorry about the error, and thanks for the catch!

Yuval Taylor
Product Manager, Portfolio123
invest(igations)
Any opinions or recommendations in this message are not opinions or recommendations of Portfolio123 Securities LLC.

Nov 29, 2021 9:47:33 PM       
geov
Re: QQQ mean reversion coding question

Results with TLT when model is not in QQQ are good. Annualized return= 17% from 2000 to 2021. Max D/D= -23%

Ideal Number of Positions = 2
Reconstitution & Rebalancing Frequency = Daily
Position Weight Formula : 9.99*ticker("QQQ")+0.01*ticker("TLT")

Buy:
ticker("QQQ") & SMA(50)>SMA(125) & LoopSum("ROC(5,Ctr)<0",5)=5 & ROC(5)<ROC(5,1) | ticker("TLT")

Sell: ticker("QQQ") & rsi(2) > 70

Attachment QQQ mean reversion with TLT.png (163585 bytes) (Download count: 72)


Dec 1, 2021 10:36:43 AM       
scrichley
Re: QQQ mean reversion coding question

Thank you all for your help. My next question was going to be how to buy IEF when not in QQQ. Georg is in my head!

Dec 3, 2021 9:43:14 AM       
geov
Re: QQQ mean reversion coding question

Shawn, you need to use the Position Weight Formula :
99.99*ticker("QQQ") + 0.01*ticker("IEF")

Ideal Number of Positions=2

IEF is never sold. So when model is not in QQQ it is in 100% IEF.

Dec 3, 2021 11:27:30 AM       
Edit 1 times, last edit by geov at Dec 3, 2021 12:04:35 PM
scrichley
Re: QQQ mean reversion coding question

Roger that. TY. I only have the simulation level sub, so it won't let me use position weighting, but I appreciate the result with TLT. My image was that the low exposure to equities would give a decent result if we allocate to treasuries when out of the market... I don't suppose there is a way to run this without the simulation level subscription?

I'd like to run it with a basket of bonds when not in QQQ using trend following to pick duration.

Dec 3, 2021 3:28:29 PM