This algorithm is slightly modified compared to the update 3 post. Since the beta version of the TWS API contains better filters, I’m now using those instead of basic volume/market cap filters. I’ll try to upload them to YouTube, but if it’s anything like last time it’s just boring trades that get stopped out.
Three trades today. Two wins and one break even trade. There may have been trades prior to these but this is when I got the scans and algo setup correctly.
Forgot to add this Greek shipping stock to the ignore list.
Break even. Spreads were really bad on this one. Almost hit the target before getting stopped out.
No trades. Yesterday was crazy and now Friday is pretty boring. I had some issues with my TWS layout around 11:30 so it was not watching for about 30 minutes.
Basically nothing moving today. Market is pretty dead. Could be the upcoming election or the tarrifs.
It tried to take $GALT but it wouldn’t have gotten filled at 5.78, so I moved the order up. Tiny move to 5.89 then it started to dump. I’m not counting this one because the spreads would have made it cancel the order.
No trades. Hopefully something happens tomorrow after the election results are in.
There were a few things moving finally but nothing crazy. $SEND made a huge move on earnings but I looked at the daily and didn’t see big volume while it was flagging. I backtested it and it won but no trades because the market cap is 1.6B (scan limit is 750M). No trades.
I was messing with the scans for a few hours so it made a bad trade on $SGMS which is not a low market cap. I then got the scans dialed in better and it traded $LCI for a win. I should probably start the test over with the new filters. I think IB removed the “shares outstanding” scan because it’s not there anymore in the parameters. I wish they had a float filter because that would narrow it down significantly.
This one actually hit the non-weak market target, but I moved it down not expecting it to run that much.
No trades. Very boring day. It wasn’t even watching any stocks until 10:00 AM because everything sold off.
Weak again. I really needed to dip buy $AMD at $19.00 so I logged into my live account and put some orders out. Algo was watching like 8 stocks by 10:30 so I doubt there was anything happening today.
It’s just getting boring now so I’m running it on my live account but as read-only so it logs the trades but won’t be able to place them. I need to be able to make trades if I see something good instead of just paper trading it. I sold my small $AMD position today since it got a $1 run and I didn’t want to bag hold if it dumped. I have an order to rebuy at $19 again.
Tried to take a trade on $SWCH but no fill. Order was canceled.
Finally a trade and it somewhat worked. Unfortunately, it was $NBEV so it usually stuffs. Small move up to $4.50 then it dumped and got out break even. I’m adding a whole/half dollar top check because things like that happen often. Any human watching it could determine there was going to be resistance there or by looking at the level 2. I saw a higher number of sellers, then a bunch of sellers came in a penny below once it tapped it.
No trades. A few small caps were strong today unlike the previous few days.
I took a look at $ABIL since it had a perfect 5m flag and the algo didn’t take it. The high of that flag went up more than 1% so it didn’t trade it. Percentages tend to mess with the strategy on lower priced stocks. I added an ATR check just like I did on the “big move” candle. That may increase the number of trades but lately there hasn’t been much going on.
I’ll probably start the test over once I’m satisfied with it. I’d like to get it to a point where I can trust it to make good decisions if I need to step away for a couple minutes.
Good setup and I was asleep for this one. It would have been cool to see what happened if it traded something after hours since it was a half day.
I just noticed there was a perfect 5m setup earlier but it did not close high enough so it didn’t meet the requirements. I backtested a few stocks after changing it and didn’t really change much so hopefully going forward it has more trades. I don’t know if that’ll be good or bad.
Insane move on $ANY today with lots of other stocks getting halted. I scalped it earlier then the algo took it a little later and I was not expecting it to work. Stop loss ended up being perfect.
No trades. Pretty boring.
Market bounced really strong today. This is the first flag I’ve seen it take near market close. I have it set to exit the position when it’s after 15:50.
Traded $ALQA for a loss. It should not have traded this one because it dipped too low off the high. I already have code to check for that but it’s percentage based which ends up not working for all price ranges. I changed this to an ATR check as well.
If those two bottom candles before the entry held a little higher like $3.45 or $3.50 instead of $3.30 it would have been a more valid setup with a higher likelihood of working. Instead, it held lower, so the first candle to make a new high works better as a short unless it has insane volume to carry it.
I scalped the crap out of $ADIL earlier so that’s why there’s a lot of trades. This setup is not exactly ideal but it did get a bounce into $5.00 before dumping.
These trades seem a little weird to me. On both of them it got filled really low instead of near the high. Could just be the spreads and when it polls the candle data.
Last trade was on $NTEC. I can’t retrieve the chart in IB, but it was a $1 gain since it chopped around after the flag. Got out because of an exit indicator.
First large cap trade. It shouldn’t have even traded it but due to a scan “bug” it ended up watching it. Setup was perfect so it did work but the entry was too high.
Update: It got in too high because of that ATR check I previously added (dumping too far off the highs). It wasn’t the check itself but because it was checking the wrong index in the ATR array. In fact, it was doing that for every single indicator like EMAs. Luckily, the indicator values would not change too much from each candle so each previous trade would work the same way. Glad I found that bug.
Realtime chart data in IB was broken today. After receiving the initial chart data it would no longer update the candles correctly. The bid/ask would not match up with the candle. They did send out a bulletin saying to use directed charts which does work but I can’t find a way to auto select “ARCA”. Anyway, I don’t think this would affect the algorithm since it requests the chart snapshot and not tick updates.
No trades. Market had a nice crash midday.
Stock market is closed.
No trades. Since the market was really wild today I decided to backtest $TQQQ and it ended up taking a perfect flag and it got the full move out of it. I’m adding that to the list to see how it does each day. Could be interesting.
Perfect timing. I added $SQQQ as well and it ended up trading it shortly after $TQQQ had a bear flag. First trade that it was able to ride the 9 EMA up.
(this video managed to get more views than usual due to people learning about inverse ETFs when the market was dumping)
About an hour later it traded $MNTA. It ran enough to put the stop near the whole number, but that unfortunately caused it to get stopped out. I don’t really want to change the stops so I think I need better price targets or the ability to detect exponential moves.
Lastly, $DOMO near the close. Out for basically break even. The algo automatically sells when it’s after 15:50.
I did record this one, but I’m not going to upload it because the stock did nothing then it exits at 15:50.
Lots of volatility in the overall market with not many stocks up. This setup is not exactly ideal since it had that huge wick and it does not have much volume. Algo sold earlier than the stop because it topped at the half dollar. I think that was right move because it tapped the stop then bounced to the entry afterwards.
Later it took $INNT but did not get filled so I manually put the orders in. I backtested it had an entry of 2.99 with an exit at 3.02 which is basically what my manual trades reflect.
Two trades back to back. $SPY was kind of all over the place in the first few minutes so I expected $TWTR to just roll over with it.
I thought there was a daily flag setup on this one but I guess not. Basically caught the exact top. Amazing.
This setup ended up being perfect but the timing was off. On the 1m there is a perfect ascending triangle that exploded when it finally broke out. You could say that it’s still too extended based on the distance from the 9 EMA, but how many good trades would it remove from the list?
This is the 3rd or 4th time it has traded $NBEV and it rarely ever works. I’m adding it to the ignore list.
Not an ideal setup. It’s traded a few of these previously because I decided to change the
high check from
close - open to
high - open to see what it would trade. I’m not sure if that change works better or if I should just check to make sure it’s not buying over the high.
Not an easy day. Most traders I follow on Twitter are struggling today or red. I decided to sleep.
My algo was watching only 32 stocks today. Usually by end of day it’s at least 50 on a bad day or 80+ on a day where the market is up/moving.
It traded $HUYA again but three times today. First one had a little move then a loss. Second one got the full move for a win. Third another loss. Still positive on this name believe it or not. For this stock it seems like moving stops up really causes a problem. After each entry it ends up being choppy without breaking out quickly.
The last trade it took on this one (top right) is another “not ideal” setup. The stock is not what I’d consider “up” at that point to take a flag trade. The previous two were even though only one really worked.
If you go back to $DOMO, that one is technically OK (I mean look at the candle tops, too perfect) but it was just too close to the close for it to make a move.
Next was $SQQQ for a loss. Got a little move then it crashed. I don’t have enough data to know how accurate it is on the overall market so this could just be one of the times it did not work.
The past few days have been pretty boring. Another $HUYA trade and another one for the overall market.
This one shouldn’t have actually been traded because it didn’t get a fill then it tried to re-enter a few minutes later on the next candle. The setup was decent but it just dumped then decided to try buying again.
Setup seems OK but the market has been too choppy lately.
I’m thinking about going live on Monday depending on how the market looks. This algo is to the point where it’s able to identify bull flags very well and most of the time when it gets stopped out it could have had a profit. I’ll be managing the trade how I see fit because sometimes it’s just too obvious that it’s about to dump ($SFIX / $HUYA recently).
I was too tired to get up so I didn’t go live. No trades today anyway. I’ll try again tomorrow.
I finally let it trade live. Nothing really going on today though. Could be the holidays or the market being slow / choppy. $MTLS had a perfect 5m flag setup but the volume was too low.
I shut it down early at 12:00 PM since most of the trades occur before that time. If it hasn’t made a trade by then it probably won’t later on. Not worth waiting around all day for it. Besides, it’s only watching 23 stocks which means there’s nothing moving. As I said previously, on good days it’s watching 50 stocks by 10:30 / 11:00.
Let’s see what happens tomorrow.
I wasn’t up today. Fed announcement at 2:00 PM so I wasn’t planning to let it trade. No paper trades before 12:00 so it didn’t matter anyway.
At 1:05 PM it tried to take $WGO but no fill. Slow grind up. It would have exited for a $10 gain due to the maximum hold time being 35 minutes. Not bad.
A little later $MRIN which was a good setup but it was a bit extended to keep going. I think the ideal times are 9:50 to 12:00 then 3:00 until end of day.
I don’t really trust flags to work in this market so I’m hesitent to go live again. If I do then I’ll have to transmit the orders manually to be on the safe side.
This one sort of worked but it dumped first. Probably could have made it all back going long on the candle that broke above VWAP.
Dumped immediately on the entry. Choppy flag though.
I started working on a similar bull flag algo that looks for perfect pennants and bull flags. Both flags have the highs being lower on each candle but with a pennant the lows uptrend. They are slightly different but I think that might work a little better in terms of improving accuracy. If the setup looks perfect more people are able to recognize it and see what’s likely to happen next.
Next week is shorter plus a half day on Monday. Last few weeks have been slow so hopefully next year there will be some better opportunities for flags.
One trade on $PTI today but it couldn’t even get to the target so it had a $1 gain. Not a bad setup besides that giant wick. Just not enough movement. I may experiment with using the 9 EMA as the stop instead so it always trails it up. A lot of the time it gets stopped out due to moving it up to break even and it dumps then runs. It’s a difficult balancing act.
Half day today. One trade on $MRIN which worked OK but had a double top then dumped. There was actually a deadlock so it didn’t exit until the stop was moved up and it dumped into it. This flag is part of my new pennant algo. It would have still been taken by the original algo.
Market is closed on Christmas then normal trading hours the rest of the week.
Insane bounce today. Only one algo trade from the previous bull flag algo. I really don’t think this old algo is going to ever work because it’s not precise enough. Sometimes it gets some huge gains but most of the time it get stopped out.
Nice move out of $WATT today. Two flags but it only took one of them because the first one broke the high of the flag top and it does not chase. I’ve added code to buy on the dip if it comes back down below the previous candle high.
I actually had it running live but not transmitting orders. I should have just taken the first one on my own when it dipped. If I used the same risk level it would have been perfect.
Holidays plus a Friday so it’s watching only 5 stocks by 10:00. I let it trade live until 11:00 but it was only watching 13 stocks by then. Just a really boring day.
I’ve started adding crypto trading support and so far the same bull flag algo appears to work on the hourly chart for Litecoin. I need to optimize it a bit and figure out how to get 1m candles past a few months so I can properly backtest it.
Last day of the year and it’s a half day! Market is closed on the 1st. I’m letting the algo trade the pennant’s live and normal bull flags will be submitted but not transmitted. This gives me the ability to choose which trades it takes.
No trades today. I’m almost done with the algo order flow for GDAX.
I’ve already been going live but now I’m moving those trades over to a new post. Hopefully we see some nice moves in the first few months of 2019!
I am not a registered financial adviser/broker/anything. Use this information for entertainment/informational purposes only. Any tickers mentioned are not recommendations to buy/sell/or sell short. They are used as examples only.
Please remember that past performance may not be indicative of future results.