I've been trying all the technical indicators and supposed "edges" I can find information about. So far I've been deeply unimpressed -- some work some of the time with some stocks, but none really reliably enough to beat market consistently. I saw a couple old posts on the forum asking about how to identify "support" and "resistance" levels (established and retested lows and highs), but haven't seen any Q algos that imploy this common technical indicator -- perhaps because it's a bit nuanced and there's a bit of art to interpreting it.
With penny stocks though, they often display very rigid conformity to this pattern, and so it's not too difficult to code for. So I decided to code up an algo to see if there was anything behind this concept. My algo uses a short window (90 minutes). It checks if a support level has been retested twice and a resistance level retested at least once in order to determine if the stock is oscillating within a predictable range. If so it buys it at the low end of the range and sells it at the high. Ideally it'll do this multiple times a day in order to extract significant alpha from a stock that doesn't have much or any upwards movement to it.
I've tested the script with a number of different penny stocks, and at least with the ones I threw in there it was very, very consistent. Different thresholds, window lengths, levels, support/resistance requirements, and the like have some effects on the results but in general the concept is proving all-around solid for these certain kinds of penny stocks.
Since the algo only goes long for short amounts of time, a lot of the time it's just sitting on cash, so I played around with adding more penny stocks to the loop (add them to the context.penny_stocks array and reduce the overall weight if needed to keep leverage in check). With 20 in there the returns even out quite a bit while averaging around 0.5 leverage -- 0.46 alpha, 3.03sharpe, 5.28 sortino, but a bit of drawdawn during Jan '16 ...that could be improved.
- Due to low liquidity, this algo is likely only profitable via Robinhood (no commission fee) and low investment amounts. Multiple people live-trading the algo would be competing over the same limited gains. (That's why I didn't post it with my full array of penny stocks.)
- It might be that the penny stocks I chose for my tests (from my Robinhood watch list) introduce look-ahead bias.
- The algo uses a fairly dumb method of determining support and resistance. It might not be so accurate at all.
- The law of diminishing returns -- due to the aforementioned liquidity issue, as the algo racks up gains and reinvests them those trades put increasing liquidity pressure on the stock.
Some possible improvements:
- Weighting the order amounts appropriately by liquidity capacity of stock could improve returns+stats significantly.
- Supposedly it's a fairly reliable bullish indicator when a stock breaks through a strongly established resistance level. Since the algo is already tracking how often resistance has been retested, it wouldn't take much to make it go long in these cases.
- Employ pipeline to vet more suitable stocks. Due to the low liquidity of typical of penny stocks there's only a tiny bit of alpha to be extracted per stock. So the only way to get more profits out of this is to trade more tickers. I still haven't learned pipeline properly. I'm not sure what the screen criteria might be or how to program it. You don't want something that's making big moves up or down, but rather something that oscillates a couple % as often as possible. Perhaps stocktwits sentiment data could be used to find stocks generating a lot of retail interest and filter out duds that technically otherwise look nice. Who wants to take a stab at this?
- It might be possible to adapt the algo to larger window lengths for the slower moving Q500US universe of stocks, making it possible to exploit for bigger profits, and thus Q Open. Though, typically those types of stocks don't have as solidly defined support and resistance levels -- more of an art to interpret them. Not sure how to do that in Python.
Support/resistance is the most reliable technical indicator I've found, though there is definitely room for improvement.
Throw your comments/criticisms this way! Please feel free to adapt it, improve it, contribute to it, and post your work here.
PS -- If you live trade this algo, I'd love to know, and send me an update on how it works out for you! Cheers!
|Returns||1 Month||3 Month||6 Month||12 Month|
|Alpha||1 Month||3 Month||6 Month||12 Month|
|Beta||1 Month||3 Month||6 Month||12 Month|
|Sharpe||1 Month||3 Month||6 Month||12 Month|
|Sortino||1 Month||3 Month||6 Month||12 Month|
|Volatility||1 Month||3 Month||6 Month||12 Month|
|Max Drawdown||1 Month||3 Month||6 Month||12 Month|