Trading Psychology - Self-Sabotage

This post is about something I discovered while algo trading recently. The issue I seem to be having is due to multiple losses and fear of another loser or fear of losing money in general. Despite letting an algorithm trade for me, I still end up screwing up the trade by taking losses too early without letting the trade play out and work.

Here is the definition of self-sabotage from Psychology Today:

Behavior is said to be self-sabotaging when it creates problems in our life and interferes with long-standing goals.

It all goes back to “Trading in the Zone” by Mark Douglas. My losing trades are mostly caused by myself not fully trusting the algo or not fully accepting the risk of each trade.

I started algo trading at the beginning of this year and actually found a little bit of success; then I had one “large” loser that stopped me out of a trade due to the stop loss not being at the correct price. That trade would have worked if it were not for that technical error. Next, there was a trade on $USAT that wasn’t really working so I stopped my algo when it was about to trade $MBOT. I couldn’t stand having yet another losing trade.

Because of that first big losing trade, I stopped trusting it to make proper decisions despite seeing trades work over and over in my paper account. And guess what happened with the $MBOT trade it wanted to take? An easy win that worked almost instantly that would have taken out both losses. In fact, I would have been profitable on the day because it would have sold $USAT sooner rather than getting stopped out.

$MBOT 5m candles

I am sabotaging myself by not letting it take every trade or not letting the algo decide when it’s not working and it should get out. It follows rules so I don’t have to think.

Today, on $MBOT again, I did not like how the stock was acting so I sold it too soon. The trade worked without ever touching my stop price.

$MBOT 5m/1m candles

The Solution

The only thing I can come up with is to size down even further so the risk is a $5 max loss instead of $10. This is not much money either way but it feels like a lot if you have one double digit loser after another.

Once you’re in a trade you have to stop thinking. Risk is set, there is nothing else to do but wait. Some trades will work instantly and others will take time to get going.

This week has been pretty tough and the most trades I’ve ever taken in a day or even week. I’ve sized down to $5 of risk so tomorrow I’ll just sit on my hands and let the algo trade each setup.

I have “Trading Psychology 2.0” on my shelf but it’s tough to get through. I’ll force myself to read it at some point.

At least I’m aware of this problem so I can try working towards a solution. I don’t need income from trading so it’s not a “life or death” situation. These small losses don’t matter in the beginning. I’m only just getting started.

Trading Update - 6

Update 5 - Bull Flag 2 Trades

I can’t believe I’m already on part 6 of this series and it’s 2019. I’ve learned quite a bit from watching it paper trade the last few months.

Now that it’s January, I’m ready to test it semi-live. There are now two algos: standard bull flag algo from the other post, and another one that is more specific that trades perfect pennants and bull flags. Both are very similar in the way they look for the patterns and take the trades. The first algo sometimes takes choppy flags but also has ones that are perfect but don’t meet the critera of the pennant algo.

  1. Standard bull flag algo
    • Orders are submitted but not transmitted so I get to choose if it trades them
    • Sometimes finds choppy flags
    • Not as specific as the pennant algo but is the majority of trades and gains
  2. Pennant algo
    • Transmitted live
    • Looks for perfect pennant setups and bull flags
      • Must be all red candles (except the high candle)
      • Candle tops / bottoms must be inside the high candle
      • Pennants / flags: candle tops must downtrend along with volume
      • Pennants: candle bottoms must also uptrend

If the flag doesn’t meet the requirements of the #1 algo it shouldn’t trade the #2 algo due to how similar they are. I plan to let the algos do their thing unless I see an exit indicator. It’d be nice if the first trade it took was a winner.



01/02/2019
Today it’s watching a lot more stocks compared to the holiday weeks even though the morning was painfully slow.

One attempted trade on $CRC that I canceled. Not a bad setup but the last time it traded it it dumped off then ran. Not really a fan of this stock. It did manage to hit the target after a slow grind up.

1
2
3
4
5
6
[01/02/2019 10:40:00] Entry 45 @ $17.19, target $17.65, stop $16.97 [ Bull Flag ]
Trailing stop: 16.97, 17.22
[01/02/2019 11:00:00] Exit @ $17.38 [ $0.18 ] (exit indicator)
Drawdown: $0.19 / -1.10%
Max profit: $0.18 / 1.04%
P/L: $8.32

I canceled another on $WATT. I’m not seeing any crazy volume stocks so none of these look like they will work. It also hit the target and would have been an $18 gain.

1
2
3
4
5
6
[01/02/2019 11:30:00] Entry 90 @ $6.34, target $6.54, stop $6.23 [ Bull Flag ]
Trailing stop: 6.23, 6.37
[01/02/2019 11:40:00] Exit @ $6.55 [ $0.21 ]
Drawdown: $0.10 / -1.58%
Max profit: $0.16 / 2.48%
P/L: $18.90

I’m thinking tomorrow I’ll just let it transmit all the orders it wants. I’m like trying to predict which ones will work and which ones won’t but that’s not how the market works. Worst case scenario I can just sell it back instantly for a commission loss if the flag is garbage looking.

01/03/2019
Everything is live today. Big gap down in the $SPY like yesterday. Hopefully I get a win - even if it’s $2.

Watching 3 stocks by 10:00. 5 by 10:30. 9 by 11:00. If the market continues to sell off it’s unlikely there will be a trade today. Never know for sure though.

Market started to bounce around 11:00 similar to yesterday.

Stopping it at 1:00 PM. $SPY is just sideways in a range and it’s only watching 39 stocks. Not much going on today in terms of small caps. Eventually it will trade something like it did yesterday.

Try again tomorrow.

I just realized something with my $CRC thought process from yesterday and it goes back to what Mark Douglas said in Trading in the Zone. Each trade is random and unique even though we believe in our minds that what happened previously will have the same outcome again. I thought $CRC wouldn’t work because it hadn’t before. If I have more data to back up my reasoning, like with $NBEV, then I can assume flags usually do not work on a particular stock.

01/04/2019
$SPY is up a lot from yesterday’s close. I’d like to see it get over 250, but there’s going to be a lot of resistance. Hopefully we see similar action to Wednesday with more stocks moving.

Not a whole lot moving this morning.

So I finally got an algo trade and it was 2. $FLXN and $TWTR.

Both of these I manually took profits/losses. $FLXN just couldn’t get over prior close so I sold when it started to crash into $12.25. $TWTR was really choppy and slow so I took profit on the ask when it finally broke over the high. It didn’t hit the target anyway so my exit was solid.

The $SPY did manage to get over $250 like I wanted due to some fed news which is really good. Monday should be interesting if the momentum continues.



$FLXN 5m/1m candles
$TWTR 5m/1m candles

01/07/2019
$SPY held most of its gains but is coming down a little during premarket. I’m seeing quite a few things moving around which is good. I just want to get one good win in so I can build up a cushion. It doesn’t really matter because over time this strategy should come out on top. I just like the idea of trading with profits and not losing money in my account.

It’s almost 10:00 and it’s only watching 7 stocks. I’d be OK with it not trading anything since there’s not much moving besides $ROKU and $ARRY.

One trade on $EPZM for a $6 gain. I was watching this setup a few minutes before it took it but I was hoping it’d dump first because of that huge topping wick. I manually took profit into a large spike. I seem to be pretty good at determining when I should get out. So far no amazing trades that work instantly. Earnings season is coming up so that should get really interesting.

Stopping it at 11:00 AM.



$EPZM 5m/1m candles

01/08/2019
$SPY is still climbing which is great. I just want to keep building up that cushion and hopefully one of these days get a full move out of one of these trades.

I don’t see too much going on so I doubt there will be a trade. It does end up surprising me a lot though.

Only watching 5 stocks by 10:00. Not looking too good.

Nothing going on today and the $SPY is now below yesterdays close so I’m stopping it at 11:00. $TMDI looked really promising for a 5m setup but it failed. I can’t wait for earnings season to start.

No trades.

01/09/2019
$SPY is up again. We’ll see if it holds up. Not too much going on during premarket but there could be something later on.

It’s watching more stocks today but there’s not a lot going on. $TWTR, $HUYA, and $LJPC had early flags but they didn’t meet the requirements. It was about to take $WATT but it failed and it didn’t look good. $LJPC had another flag around 10:30 but it looked way too choppy. It somewhat worked but the backtest shows it would have gotten out due to a double top.

I’m just going to try again tomorrow. Everything is crappy today. I don’t want to push my luck until earnings season.

01/10/2019
$SPY finally gapped down. It may go green later. Can’t really predict that. I got up a bit late so I’m just going to paper trade it today. I don’t see much going on anyway so it may not even trade.

No trades.

01/11/2019
The last half of this week has been so slow I don’t have the urge to wake up early. $SPY is downtrending and it’s watching 6 stocks by 10:00. It may trade something since it’s been a while without a trade. I’m just paper trading it now. On Monday I’ll get back to live trades.

One paper trade on $AXSM. It sold for a $3 gain when a double top occurred and if it stayed in it would have hit the target. Not bad I guess.

1
2
3
4
5
6
[01/11/2019 12:10:00] Entry 90 @ $7.68, target $7.88, stop $7.57 [ Bull Flag ]
Trailing stop: 7.57
[01/11/2019 12:30:00] Exit @ $7.71 [ $0.03 ] (exit indicator)
Drawdown: $0.13 / -1.69%
Max profit: $0.06 / 0.77%
P/L: $2.57

No screenshots because I only want to catalog live trades here.

I think the ATR indicator is broken in IB or the smoothing done by TA-Lib is different. The ATR for all of the candles in IB are less than 0.10 and the algo would not trade if they are below that. Odd.

01/14/2019
This is the start of the earnings season! All I want is a single win to keep building that cushion.

Significant $SPY gap down but it is earnings season so I still want to trade. Maybe it will reverse or there will be some earnings winners not tracking the market.



Got a trade on $SAEX that literally touched my stop for not even a second then ran. I’m not sure if that’s because a trade occurred below my stop or the bid dropped below it. If I didn’t get stopped out I could have had a small gain on this since it blasted through my entry afterwards. If I let the algo do its thing it would have been a break even trade.

$SAEX 5m/1m candles

Another trade on $USAT. I closed my algo app at this time since it was looking to trade $MBOT next. I should not have done that since at some point it has to have a win. This one would have been about a $7 loss instead of a full $11 if I didn’t close the algo.

So really I should have only been down like 8-10 total and maybe I would have let it trade $MBOT then. Ugh.

$USAT 5m/1m candles

1
2
3
4
5
6
[01/14/2019 10:35:00] Entry 43 @ $5.40, target $5.94, stop $5.17 [ Bull Flag ]
Trailing stop: 5.17
[01/14/2019 10:35:00] Exit @ $5.95 [ $0.55 ]
Drawdown: $0.82 / -13.46%
Max profit: $0.09 / 1.51%
P/L: $23.65

(I don’t think the drawdown / max profit values above are working correctly so just ignore them)

$MBOT would have worked but I decided against it because all these trades have been garbage. I can’t win. I should have let it do its thing, but I could not stand having another loss. I can afford to lose $20+ otherwise I wouldn’t be trading. I just hate seeing my account value drop.

You don’t get to choose which trades will work.

I will say that my fills are pretty solid on the stop losses. It’s not many shares but I haven’t really gotten any slippage on these.

I went back and looked at the trade data. Not a single trade occurred below my $5.80 stop loss which means stops get triggered if a trade occurs at or below your stop price. This can be changed in TWS but I don’t see anything better than “Last” which is the default. I’ve changed the stop price to be 1c below which should prevent stupid exits like this. It should not have been a loss!

Here’s the tick data for my trade time period. I’ve highlighted my exit. Somehow I got 5.81 and not 5.80 so either IB is doing a pretty good job or they’re slow on the executions and the bid popped up for a second. Entries/exits were both executed on ARCA.


$SAEX tick data

01/15/2019
$SPY is up a tiny bit today and I’m seeing quite a few low priced stocks up. I plan to let the algo trade everything and never prevent it from trading. If you try to avoid more losses you will only end up with more losses.

Despite $MBOT going nuts it’s only watching 4 stocks by 10:00. There might not be a trade today since yesterday there were a lot. I plan to stop it around 12:00 if nothing is going on. The overall market has been straight up and the $SPY tapped 260. It needs to get over that level otherwise I expect there to be a dump.



Got a trade on $MBOT on the 5m flag setup. Lost $6 on it. I decided to bail early because it should have had instant resolution but the move got stuffed. The timing for it ended up being off and this would have been a win if I had held.

$MBOT 5m/1m candles

Next trade on $VHC. Another loser but this time I sized down to $5 of risk and let my algo do whatever. It sold it early when it topped at 5.50. This was amazing timing since it dumped on the next candle.

Good thing I adjusted stops to be 1c lower because this one dropped instantly to my stop price then came back up. I got a better exit because of that.

$VHC 5m/1m candles

Stopping at 11:00. Nothing else going on and today is not a good day for me. I will let it paper trade the rest of the day though.

I looked at the stats and currently the win rate is only 28% and this is because I got screwed on $SAEX, didn’t let it trade $MBOT yesterday, and sabotaged myself with $MBOT today. Otherwise the win rate is about 62%.

This is why I decided to algo trade. So it could find the right setup and I don’t have to worry about the stop price or where to get out. It does it all. Of course that doesn’t prevent self-sabotage and fear of losing. I’ve had so many losers in a row now that I never expect any trade to ever work. At least I am aware of this problem and can try to avoid making the same mistakes.

Trading is hard and I’ll make back the losses even if it takes months.

01/16/2019
$SPY opened above $260 which is great. I couldn’t sleep much so I’ll be stopping at 11:00 so I can go back to bed. I’ve sized down to $5 of risk so even if I lose it doesn’t matter. Somehow $MBOT is still going.

Since I sized down I was able to just walk away after it took a position on $CENX. The algo sold due to a double top for a $2 loss. It’s a very slow stock. One of these trades has to work.

I realized earlier that accuracy is much higher since $CRC and $WATT worked from before but I didn’t let it trade them. Have to let it trade everything otherwise you have an accuracy skewed to the losing side.

Not as much stuff going on today so I’m stopping at 11 so I can sleep. I’ll let it paper trade the rest of the day.



$CENX 5m/1m candles

I let it paper trade the rest of the day and it got a perfect win on $UNFI. I can’t believe this strategy seems to only work when I paper trade it. It’s so frustrating.



1
2
3
4
5
6
[01/16/2019 14:45:00] Entry 33 @ $13.20, target $13.57, stop $13.05 [ Bull Flag ]
Trailing stop: 13.05, 13.23
[01/16/2019 14:50:00] Exit @ $13.58 [ $0.38 ]
Drawdown: $0.24 / -1.76%
Max profit: $0.32 / 2.39%
P/L: $12.54

01/17/2019
I’m taking today off since I developed a sore throat yesterday and I couldn’t sleep. I don’t know if it’s just too dry and cold now or what. I really do not want to take a day off but I feel like I need to. I may also take Friday off so I can get back to it on Monday. This week has been crazy.

No morning paper trades. $FOSL was looking good but it didn’t take it. Would have worked out OK but it’s slow.

Later it got a trade on $ALDR. It almost hit the target after slowly grinding up. There was plenty of time to exit around $12.50.

1
2
3
4
5
6
[01/17/2019 15:15:00] Entry 41 @ $12.36, target $12.57, stop $12.24 [ Bull Flag ]
Trailing stop: 12.24, 12.39
[01/17/2019 15:30:00] Exit @ $12.47 [ $0.11 ] (exit indicator)
Drawdown: $0.21 / -1.68%
Max profit: $0.05 / 0.40%
P/L: $4.51

I may trade tomorrow if I start feeling better.

01/18/2019
Took today off as well. There were a few paper trades. One on $HUYA and another on $HEAR. $HUYA got stopped out for basically break even. $HEAR was perfect and slowly grinded up to the target.

Yet another flag on $OSTK near end of day. Up $5 on that. Crazy how if I just stop screwing with things it ends up with gains.

Pretty good paper trading day. I just realized Monday is closed which is perfect since I still feel a bit sick.

Accuracy is 76% if I include the trades where I screwed them up, the $SAEX one, and the recent paper trades. That’s insanely good.

01/22/2019
Starting to feel better but not enough to trade live. I want to start trading all day and I don’t think I’m up for that while sick. Maybe tomorrow but I might just take the entire week off to recover.

Not much going on. Huge market dump. One paper trade on $AXSM for a loss.

01/23/2019
I’m writing this the night before. Taking Wednesday off again since I’ve got a slight headache now and I just want to not be sick when I trade. This could be the start of a new downtrend in the $SPY so I’m not expecting this week to be that great.

Got one paper trade on $SPI for a small winner. I’ll take it considering the entire market dumped today.

01/24/2019
Also writing this one the night before. Still a bit sick so if I don’t wake up for the open then I won’t trade live. Anthem VIP demo comes out on Friday in the morning, so if I’m awake for that I may trade live for a few hours but otherwise I’ll be playing that instead. This week has been pretty slow for flags which is great since me being sick was perfect timing.

One trade on $TBLT but it didn’t get filled. Would have gotten stopped out for break even.

Very slow this week compared to last week so I’ll probably just skip Friday again and let it paper trade while I play Anthem. Next week should be better.

01/25/2019
Took today off again.

Two trades on $OSTK. Neither of them had much follow through. The second trade did move up a bit and it basically got out break even.

$MGNX had this insane topping wick that I almost want to write code to ignore. Got a tiny move up then it dumped.

The second $OSTK trade would have made back the loss then on $MGNX there were several signs to get out like two topping wicks in a row. So today could have been profitable but it was pretty crappy.

Another trade on $OSTK. No follow through.

This week was very slow and that seems to happen a lot. Every other week tends to be good.

01/28/2019
This is the last week of January. I’ll probably do a review of the month then start another post with more live algo trades. I’m finally not sick so back to live trades, and I want to let it trade all day since there have been some trades near 2:00 PM that worked well.

Big $SPY gap down and I don’t see too many stocks up premarket that look interesting. We’ll see what happens. If there’s nothing by 12 I might just go to sleep.

Got a trade on $AWSM that hit the target perfectly and more. I took it early because my heart was racing for no apparent reason. I think taking that week off made me forget about risk management and letting trades play out.



$AWSM 5m/1m candles

I’m taking the rest of the day off. There was nothing else really going on.

01/29/2019
I was really tired so I slept in until about noon. I don’t think much was going on but it may have traded despite that. $AMD had a huge earnings spike after hours. If it gets back to $16-17 in a few weeks I’ll be buying some.

I’ll try to be up tomorrow morning for live trades, but I’ve developed some sinus pressure from my runny nose so if I feel like garbage I’ll be sleeping in again.

01/30/2019
Head is hurting a bit so I’ll just take it easy and sleep all day. When I wake up I’ll see what it paper traded.

Algo didn’t start. Thanks Windows.

01/31/2019
Last day of the month. I’m doing something that is crazy CPU intensive so I don’t want to live trade. Also, I’m pretty tired so at this point I’ll probably just wait until February to get things going. Finally not as sick so that’s nice.

Got a paper trade on $SXTC. Ended up being break even but plenty of time to sell at $7.90. Crazy spreads on it.

Surprisingly only watching 25 stocks by EOD so only that one trade in the morning. It wasn’t terrible just a little early and rejected $8.


January Trade Review



Disclaimer

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.

Trading Review 2018

2018 was interesting. I traded a little at the beginning but the market felt even more difficult to trade after the state of the union address. I just couldn’t find anything I liked so I ended up not trading much at all. I had a few losses but I can’t even remember them now because they were so long ago.

My main wins were from swing trading $ALLY and $AMD. I successfully dip bought $ALLY when it hit my daily trend line and I sold it the next day for a nice win on 100 shares.

Most of the year I was working on my algo trading application to integrate with IB then actually writing algorithms. I experimented with different setups like red to green, 5m/15m opening range break out, MACD, and bull/bear flags. There were some that worked but bull flags have been the most consistent. Bear flags work too but I couldn’t make them as consistent. I’ll have to revisit them since I think they need a slightly different algo to work and you can’t just flip a bull flag upside down like some have said.

I don’t think I watched a single Tim DVD like I said I would from 2017. I’ve seen them all and I still don’t know what his strategy is. There’s nothing about how to trade flags or any technical indicators/patterns. It’s just support/resistance, which is fine, but I need some type of chart pattern to trade. I can’t just randomly buy some dip and hope it holds. That’s not feasible. I need a clear entry and stop loss.

This is why I like Kunal (and even Ross). I said in another post that I based my flag trades on his “how to trade the open” presentations that he does everywhere. He described the setup so well that I was able to mostly automate it. I mean it still has losses or even a string of losses but that could just be the recent small cap market being slow.

I started a YouTube channel to document my algo trades and have had some insane wins. When bull flags work they really work.



profit.ly 2018

Trading Goals for 2019

  1. I’ve been letting my algo trade live recently, but it hasn’t taken any trades yet. For 2019, I want to try and be here every day and let it trade as much as possible if it looks good. I have the ability to manually transmit the orders in case the setup is terrible or I know the stock never makes moves. I’m hoping January is good for 5m flag setups.
  2. I’m writing this on the very last day of 2018 and the past few days I’ve started working on adding GDAX support for my trading app. I’ve backtested bull flags on the 1H chart going back 2 years and it looks promising. I want to focus on that as well as stock trading.

Crypto Datasets

I had a hard time finding 1m datasets for LTC so I wrote some code to pull all of it from 2017 until 2018 on the GDAX exchange. I cannot guarantee the accuracy of this data. Use at your own risk.

The format is a SQLite3 database. It should be easy to export to a CSV if necessary. Use 7-zip to extract.

Bitcoin 1m data going back further than 2016 can be downloaded from Kaggle.

IB Fixed vs Tiered

I only trade small positions at the moment so this is just my opinion.

Interactive Brokers has two commission options available: fixed and tiered.

Fixed

Fixed is exactly what it sounds like, you pay a fixed rate of 0.005/share with a $1 minimum (plus a few pennies for FINRA fees and whatnot). This means you can trade up to 200 shares for $1. IB will keep the rebates for themselves if there are any.

Tiered

Tiered is 0.0035/share (depending on your volume) with a 0.35 minimum but you pay ECN fees and keep rebates if there are any. You also have the option to direct route.


So which is better? Anything over 200 shares it is better to use fixed unless you always add liquidity and can take advantage of ECN rebates. However, 100 shares and under it’s better to use tiered. We’re only talking about a few cents difference per trade and obviously if you’re that worried about a few cents on commissions your strategy probably isn’t valid.

In my case, with testing algorithms, I’ve always been on tiered with their paper trading account. Fees end up being between 0.20 and 0.60 which is essentially free. My algorithm has a max loss of $10 and it sizes in according to the stop price. So every trade it takes is going to be 100 shares or less for the most part.

When I go live I will most likely switch to tiered so even if I get stopped out for a tiny $1 win I won’t lose because of commissions. This should make testing less stressful.



Disclaimer

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.

Gaming on a Macbook with Insane Battery Life

I watched one of LinusTechTips recent videos where he demoed game streaming from a service I hadn’t heard of called Shadow (coupon: RYA1BMUE). I was intrigued by the fact that you get a full Windows 10 VM with 8 cores, 12 GB RAM, and a GTX 1080 or Quadro P5000 to install whatever you want onto (besides mining) with very low latency.

It was only $15 after the coupon code (use mine if you decide to try: RYA1BMUE) so I said why not. So, after the initial setup there was massive latency of 1 second or more even though my ping is 7ms to the date center in New York. This was solved by rebooting the VM and it’s been fine ever since. However, there is still some latency so for multiplayer FPS games like CS:GO or Overwatch I would not recommend it. Anything singleplayer or co-op like Fallout 4 or Left 4 Dead it would be fine.

They must be overprovisioning their service so this is essentially how it works (my best guess):

  1. They expect most people to not be gaming while their service is active so they can overprovision and have more paying customers. This is actually a good thing because it brings the cost down for everyone substantially.
  2. Your individual VM storage lives on another server in the DC.
  3. When you open the Shadow software and launch your Shadow, it is spun up on a random server with your block storage attached.
  4. When you close the Shadow software, your VM is turned off after several minutes so someone else has the chance to use the hardware.



That’s a brief overview of my thoughts on it. Now, about laptop gaming.

There’s this little utility called Volta that can be used to undervolt and limit the maximum wattage of your CPU on macOS. On Windows you can use Intel XTU. I don’t think AMD has a way to do this yet.

Basically, what I did was limit the maximum wattage of my 2013 Macbook Pro 13” to 5w and ran Shadow for game streaming. My Macbook got a little warm but never hot (fan was off the whole time) as I played Left 4 Dead on a bed comforter.

Activity Monitor said I had about 6 hours of battery life while Shadow was running which is pretty good considering it was hogging about 40% of the CPU. I have a Ubiquiti AP so even playing over WiFi there wasn’t much of a difference between wired.

It’s fairly impressive but since I have a PC better than the VM, it would make more sense to stream the game locally for even less latency. I haven’t tested Steam in-home streaming with the capped power limit so that may work. Last time I tried it the quality wasn’t very good and it killed the battery quickly.

SMART - Error X occurred at disk power-on lifetime

I was setting up a Debian server with all SSDs and I kept getting a strange error that caused mdadm to not be able to flush data which made the entire system lock up.

I decided to check the SMART log and I saw a strange error. All of the SMART attributes are good with no reallocated sectors. I’m using all Intel SSDs and I’ve never had a problem with them until this one.

The error does not appear to be the drive itself as I tested another Intel 730 SSD and even moved a known good drive to the port and it still ocurred. It’s actually a problem with the cable. Most likely it was just loose and not making perfect contact with the SATA port on the motherboard. I moved the cables around and I have yet to see it happen again.

One strange thing is the other 730 drive I tested already had a bunch of these errors. I do not recall having issues with it so maybe it was from unplugging it while it was on?

As you can see I also ran an extended SMART test and it passed just fine.

TL;DR Check the SATA cable and reseat it.

SMART (Intel 730 240 GB)

SMART (Intel 730 480 GB)

Docker - MSSQL 2017

Microsoft has released MSSQL for Linux and they even released a docker container for it. This makes things pretty straight forward to get running.

There are some issues with ZFS datasets because ZFS does not support O_DIRECT. There’s a hack to get it working but it did not for me. It works fine with ext4 though.

  1. Download the container.

    • docker pull mcr.microsoft.com/mssql/server:2017-GA-ubuntu
  2. Configure the systemd server. Change your SA password and the persistent database path (mine is /mnt/db).

    • /etc/systemd/system/mssql.service
    • 1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      Description=MSSQL
      After=docker.service
      Requires=docker.service
      [Service]
      Restart=always
      ExecStartPre=/usr/bin/docker pull mcr.microsoft.com/mssql/server:2017-GA-ubuntu
      ExecStart=/usr/bin/docker run --rm -e ACCEPT_EULA=Y -e SA_PASSWORD=PASSWORD -e MSSQL_PID=Express -p 1433:1433 --name mssql -v /mnt/db:/var/opt/mssql mcr.microsoft.com/mssql/server:2017-GA-ubuntu
      ExecStop=/usr/bin/docker stop mssql
      [Install]
      WantedBy=local.target
  3. Use a Windows PC to access the database using SQL Server Management Studio.

Trading Update - 5

Update 6 - Live
Update 4 - Bull Flag 1 Results
Update 3 - Bull Flag 1 Trades

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.

11/1/2018
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.

$CLVS 5m/1m candles

Forgot to add this Greek shipping stock to the ignore list.

$PXS 5m/1m candles

Break even. Spreads were really bad on this one. Almost hit the target before getting stopped out.

$HUYA 5m/1m candles

11/2/2018
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.

11/5/2018
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.

$GALT 5m/1m candles

11/6/2018
No trades. Hopefully something happens tomorrow after the election results are in.

11/7/2018
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.

11/8/2018
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.

$LCI 5m/1m candles

11/9/2018
No trades. Very boring day. It wasn’t even watching any stocks until 10:00 AM because everything sold off.

11/12/2018
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.

11/13/2018
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.

11/14/2018
No trades.

11/15/2018
Tried to take a trade on $SWCH but no fill. Order was canceled.

11/16/2018
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.



$NBEV 5m/1m candles

11/19/2018
No trades.

11/20/2018
No trades.

11/21/2018
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Starting backtest on $ABIL...
Retrieving intraday candles/ticks...
Retrieving daily candles...
Backtesting 11/21/2018...
[11/21/2018 10:05:00] Entry 52 @ $4.37, target $4.81, stop $4.18 [ Bull Flag ]
Trailing stop: 4.18, 4.40
[11/21/2018 10:10:00] Exit @ $4.82 [ $0.45 ]
Drawdown: $0.41 / -8.76%
Max profit: $0.36 / 7.67%
P/L: $23.40
Gross P/L: $23.40 / $0.00
Commissions: $-2.00
Net P/L: $21.40
Win/Loss: 1 / 0 (100.00% / ∞)
Trades: 1 (1 long, 0 short)
Avg $ win/loss: $23.40 / $0.00
Best/Worst: $23.40 [ Bull Flag ] / $0.00 [ ]

11/22/2018
Thanksgiving holiday.

11/23/2018
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.

$OSTK 5m/1m candles

11/26/2018
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.



$ANY 5m/1m candles

11/27/2018
No trades. Pretty boring.

11/28/2018
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.

$PYX 5m/1m candles

11/29/2018
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.

$ALQA 5m/1m candles

11/30/2018
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.

$ADIL 5m/1m candles

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.

$AGE 5m/1m candles

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.

12/3/2018
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.



$TWTR 5m/1m candles

12/4/2018
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.

12/5/2018
Stock market is closed.

12/6/2018
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.

12/7/2018
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)



$SQQQ 5m/1m candles

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.



$MNTA 5m/1m candles

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.

$DOMO 5m/1m candles

12/10/2018
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.

$XPER 5m/1m candles

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.

$INNT 5m/1m candles

12/11/2018
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.



$TWTR 5m/1m candles

I thought there was a daily flag setup on this one but I guess not. Basically caught the exact top. Amazing.

$ASNA 5m/1m candles

12/12/2018
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?

$SFIX 5m/1m candles

This is the 3rd or 4th time it has traded $NBEV and it rarely ever works. I’m adding it to the ignore list.

$NBEV 5m/1m candles

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.

$HUYA 5m/1m candles

12/13/2018
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.

$HUYA 5m/1m candles

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.

$SQQQ 5m/1m candles

12/14/2018
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.

$HUYA 5m/1m candles

Setup seems OK but the market has been too choppy lately.

$TQQQ 5m/1m candles

Live

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).



12/17/2018
I was too tired to get up so I didn’t go live. No trades today anyway. I’ll try again tomorrow.

12/18/2018
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.

12/19/2018
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.

12/20/2018
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.

$INPX 5m/1m candles

Dumped immediately on the entry. Choppy flag though.

$OSTK 5m/1m candles

12/21/2018
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.

$PTI 5m/1m candles

12/24/2018
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.

$MRIN 5m/1m candles

12/25/2018
Christmas.

12/26/2018
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.

$CRC 5m/1m candles

12/27/2018
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
[12/27/2018 09:50:00] Entry 40 @ $6.45, target $6.98, stop $6.20 [ Bull Flag ]
Trailing stop: 6.20, 6.48, 6.51
[12/27/2018 10:15:00] Exit @ $6.89 [ $0.44 ] (exit indicator)
Drawdown: $0.08 / -1.25%
Max profit: $0.60 / 9.40%
P/L: $17.60
[12/27/2018 10:40:00] Entry 34 @ $7.17, target $7.76, stop $6.88 [ Bull Flag ]
Trailing stop: 6.88, 7.20
[12/27/2018 10:50:00] Exit @ $7.19 [ $0.02 ]
Drawdown: $0.28 / -3.86%
Max profit: $0.25 / 3.45%
P/L: $0.68

$WATT 5m/1m candles

12/28/2018
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.

12/31/2018
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.

I’ll be writing another trading year review today like I did for 2017.

No trades today. I’m almost done with the algo order flow for GDAX.

Live

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!



Disclaimer

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.