YouTube Channel

I’ve decided to create a YouTube channel and have started uploading my trades to document my progress/algos progress. There are already tons of people posting daily recaps, but how many are posting live algorithmic trades? Certainly not what I’m attempting to achieve: scanning stocks in real-time then trading patterns when they show up. I looked through YouTube and could not find anything like this. It’s always forex/futures/specific stocks ($AAPL / $TWTR). I prefer to do what I’m doing simply because the patterns I look for should appear a few times each day on different stocks; which means there’s more opportunity to test and/or profit.

As far as I know there is not any backtesting software that allows you to backtest intraday candles and ticks based on the hot stocks appearing in a scan for the day. Obviously you can do it for individual stocks you select, but not for real-time scanning based on a set criteria. The software I wrote is totally custom for IB/TWS.

For now it’s all simulated trades until I’m confident in my strategy (manual and algo). Let’s see where this goes.

Check out my about page for other social media stuff.



Trading Update - 2
Trading Update - 1



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.

Trading Update - 2

I found an interesting bug that caused my algorithms to only trade from one IB scan that I had listed. I discovered it because it did not trade a perfect flag setup on $SYN a few days ago despite it being in most of the scans.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Starting backtest on $SYN...
Retrieving intraday candles/ticks...
Retrieving daily candles...
Backtesting 09/28/2018...
[09/28/2018 10:10:00] Entry 50 @ $4.15, target $4.57, stop $3.88 [ Bull Flag ]
Trailing stop: 3.88, 4.01, 4.15
[09/28/2018 10:15:00] Exit @ $4.59 [ $0.44 ]
Drawdown: $0.33 / -7.85%
Max profit: $0.52 / 12.66%
P/L: $21.89
[09/28/2018 11:00:00] Entry 25 @ $6.65, target $7.32, stop $6.06 [ Bull Flag ]
Trailing stop: 6.06, 6.65, 7.01
[09/28/2018 11:10:00] Exit @ $7.33 [ $0.68 ]
Drawdown: $0.32 / -4.94%
Max profit: $1.26 / 19.44%
P/L: $17.00
Gross P/L: $38.89 / $0.00
Commissions: $-4.00
Net P/L: $34.89
Win/Loss: 2 / 0 (100.00% / ∞)
Trades: 2 (2 long, 0 short)
Avg $ win/loss: $19.44 / $0.00
Best/Worst: $21.89 [ Bull Flag ] / $0.00 [ ]

After fixing it on Friday I figured on Monday it would do one of the following:

  1. Still take the same amount of trades because the ideal perfect setup is not occurring that frequently.
  2. Take more trades but probably all terrible.
  3. More trades but all great because the pattern is well known.

#2 is exactly what happened. The pattern is still good (I’ve seen it work many times) but because there’s a lack of volume and/or trades occurring, the stock does not move up and has a higher probability of working as a short.

As you can tell from the entries/exits from below, the trades didn’t exactly work. Both setups do look pretty good so it is trading the right pattern, and the second one actually worked. It didn’t hit the target so it stopped out near break even. The problem is if you look at the 1 minute chart it’s extremely illiquid with gaps and barely any volume on each 1m candle.

$NTGN 5 minute candles

$NTGN 1 minute candles (illiquid)

I believe this stock came from the TOP_PERC_GAIN / TOP_OPEN_PERC_GAIN scans. These are good basic scans but they don’t tell you anything useful except that the stock is up on the day. IB allows you to see the volume and trades for each candle but I have yet to find a good indicator to determine how “hot” or volatile a stock is.

I could look at the volume of each candle or trades per candle or even relative volume. It’s not that meaningful though since what happens when the pattern occurs perfectly before the volume conditions are met then it takes the trade at a later time and it ends up with a loss. I’ve had this happen with relative volume > 1 checks. Volume pours in immediately after the pattern sets up and you get in too late and buy high or short low.

There are other scans like TOP_TRADE_RATE / TOP_TRADE_COUNT / MOST_ACTIVE that return the stocks with the most volume/trades/trade rate so I will be testing those to see what it trades. I have a decent algo for trading flags now, so it just needs to be applied to the correct stocks.

Fall has just started, which is a great time to be trading with real money, so I’d really like to get this working. I could set the API to read-only and see what it wants to trade that way, but it’s just not the same and you don’t get a complete picture of what it’s doing with fills/moving stops/random bugs.


Scans

I went through a few of the different scans and landed on HOT_BY_VOLUME and TOP_TRADE_COUNT. The latter is what it originally traded with when it had the bug I described earlier. Both of these scans seem to return similar stocks so it should cover all the bases (lots of volume / lots of trades). After changing this, it traded $CRBP at 11:57 AM while I wasn’t even here.

$CRBP 5m/1m candles

It should have gotten in on the previous candle but it was not up enough on the day to warrant a flag. Still making minor adjustments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Starting backtest on $CRBP...
Retrieving intraday candles/ticks...
Retrieving daily candles...
Backtesting 10/02/2018...
[10/02/2018 11:50:00] Entry 50 @ $7.47, target $8.22, stop $7.28 [ Bull Flag ]
Trailing stop: 7.28, 7.47, 8.01
[10/02/2018 12:00:00] Exit @ $8.23 [ $0.76 ]
Drawdown: $0.17 / -2.25%
Max profit: $0.68 / 8.99%
P/L: $38.00
Gross P/L: $38.00 / $0.00
Commissions: $-2.00
Net P/L: $36.00
Win/Loss: 1 / 0 (100.00% / ∞)
Trades: 1 (1 long, 0 short)
Avg $ win/loss: $38.00 / $0.00
Best/Worst: $38.00 [ Bull Flag ] / $0.00 [ ]

$VTVT

I recorded a lengthy video of me trading $VTVT manually on a 1m setup then a perfect 5m bull flag formed and my algo took it a few seconds after me. I’ll try to post more of these if I get something interesting.






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.

EZ Arch Encrypted Installation

  1. Download the Arch ISO.

  2. Find your disk.
    fdisk -l

  3. Partition (zero out the drive first using dd / secure erase if you want to).

    • fdisk /dev/nvme1n1
    • n
    • 1
    • enter
    • +550M
    • n
    • 2
    • enter
    • enter
    • t
    • 1
    • 1
    • w
  4. Encrypt. aes-xts should be the fastest if your CPU supports AES instructions. Most modern CPUs do. Also, Grub does not support LUKS2 yet so do not bother trying it.

    • cryptsetup benchmark
    • cryptsetup -v --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-urandom luksFormat /dev/nvme1n1p2
    • cryptsetup luksOpen /dev/nvme1n1p2 rootfs
  5. Format.

    • mkfs.vfat -F32 /dev/nvme1n1p1
    • mkfs.ext4 /dev/mapper/rootfs
  6. Mount.

    • mount /dev/mapper/rootfs /mnt
    • mkdir /mnt/boot
    • mount /dev/nvme1n1p1 /mnt/boot
  7. Install.

    • pacstrap /mnt base base-devel
    • genfstab -U /mnt > /mnt/etc/fstab
    • arch-chroot /mnt bash
  8. Grub.

    • pacman -S grub efibootmgr
    • Edit /etc/mkinitcpio.conf and add encrypt to the HOOKS field
    • mkinitcpio -p linux
    • Edit /etc/default/grub and uncomment GRUB_ENABLE_CRYPTODISK
    • Change GRUB_CMDLINE_LINUX to GRUB_CMDLINE_LINUX="cryptdevice=UUID=<uuid>:rootfs"
    • Replace the UUID above with the encrypted partition UUID from blkid
    • grub-install --target=x86_64-efi --bootloader-id=arch --efi-directory=/boot --recheck
    • grub-mkconfig -o /boot/grub/grub.cfg
  9. Swap. If you have tons of RAM this isn’t really necessary. Having a swap file instead of a partition makes things easier in case you need to remove the swap device or increase/decrease its size. It will also be encrypted since it’s located inside the LUKS partition.

    • dd if=/dev/zero of=/swap bs=1M count=2k
    • chmod 0600 /swap
    • mkswap /swap
    • swapon /swap
    • Edit /etc/fstab and add /swap none swap defaults 0 0
  10. Time zone.

    • ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
  11. Locale.

    • Edit /etc/locale.gen and uncomment your locale. Probably en_US.UTF-8.
    • locale-gen
    • Edit /etc/locale.conf and add LANG=en_US.UTF-8
  12. Hostname.

    • Edit /etc/hostname and set it to what the machine should be called.
  13. User.

    • useradd -m -g users -G wheel,storage,network,power,rfkill -s /bin/bash <username>
    • passwd <username>
    • passwd root
    • Edit /etc/sudoers and uncomment %wheel ALL=(ALL) ALL
  14. Reboot.

    • exit
    • reboot
  15. If you did everything correctly, you should see a Grub OS selection that will take you to a prompt to enter your password.

  16. I’ll be installing GNOME, but you can choose anything you like.

    • sudo systemctl start dhcpcd.service
    • sudo pacman -S xorg xorg-server gnome gnome-extra
    • sudo systemctl enable NetworkManager.service
    • sudo systemctl enable gdm.service
    • reboot

That’s pretty much it. Check out my short guide about improving desktop responsiveness.

Pot Stocks In 2018

When the cannabis sector heats up you can reference this list for potential trades. If you know of any more, leave a comment and I’ll add it.

Listed

OTC

  • $ACBFF
  • $HEMP
  • $KSHB
  • $POTN
  • $MJNA
  • $GRNH
  • $CANN
  • $EMHTF
  • $NUGS
  • $BUDZ



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.

Learning to Day Trade - Part 19

Swing Trading

Lately I’ve been looking at swing trading or at least looking for obvious breakouts / flags on the daily chart. I created a screener to narrow the search down.

finviz screener

What this screener does is look for small caps (not low float) that are “half up” on decent volume. These are stocks that are trending higher and not trending down. It’s much more likely that a stock will continue higher if it’s trending that way.

  1. The stock does not need to be breaking out when you’re looking for potential plays. Add it to your watchlist and set alerts near the pivot point.
  2. Price does not matter so long as there is decent range.
  3. There should be a recent catalyst to carry it higher or the chart setup is perfect/obvious and will bring in buyers.
  4. There should be decent volume traded each day otherwise the spreads will be terrible.
  5. Take partials once you have some profit in order to lessen the risk.
  6. Profits take care of themselves, it’s the losses you have to worry about.

This is a perfect example of something to look for. A nice uptrending chart that is consolidating with an obvious breakout of around $28.15. This one was on the screener for serveral days so it is possible to make these trades with ample preperation.

The intraday chart is not as pretty. It had a midday crash then rebounded. You do not need to buy instantly at the open. Wait for it to prove itself.

$BOOT daily chart from finviz.com (breakout)



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.

Convert PAL 25 to NTSC 23.976

This script will convert PAL MKVs to NTSC 23.976 MP4s. You can play around with the container format (MKV instead) or audio codec.

It appears to work by slowing down the video/audio so the duration ends up being a little longer and the audio pitch is lower. Some frames are still dropped and I’m not quite sure why. The duration of the file is longer though. I’ve tested it with 42 episodes of a PAL DVD TV series. They all appear to be correct without any problems showing up.

DVD ISO VOBs -> Handbrake (0 CRF for max quality & copy audio) -> ffmpeg script

1
2
3
4
5
6
7
#!/bin/bash
for f in *.mkv
do
echo "Converting $f"
ffmpeg -loglevel panic -y -i "$f" -vcodec libx264 -preset veryslow -tune film -x264opts crf=16:videoformat=undef:force-cfr -acodec aac -strict -2 -ab 448k -filter:v setpts='25025/24000*(PTS-STARTPTS)' -filter:a asetpts='25025/24000*(PTS-STARTPTS)',aresample=48000:async=1:min_comp=0.01:comp_duration=1:max_soft_comp=100000000:min_hard_comp=0.3 -r 24000/1001 "${f%.mkv}.mp4"
done

Reviewing My $ALLY Trade

This is my first attempt at buying at trend line support with real money. It ended up working perfectly and I got in almost at the exact bottom on Wednesday.

As you can see from the daily chart, I drew the support/resistance lines and had been actively watching this stock for several days. It had two things going for it: running into the 200 day EMA as well as another touch of the uptrending trend line. My plan was to buy around $26.55 with a goal of selling near $27 in a few days.

$ALLY daily candles

It tapped the bottom trend line almost perfectly and started to reverse. I bought 100 shares with a limit of $26.49. Low of day was $26.45. Luckily I had a good entry and it reversed off that bottom.

The next day it gapped up just over $26.90, so I was in the green over 40c and didn’t have to worry about being red. I gave it as much time as I could stand to get over $27, but it started to top at $27.10. I decided to just take the 54c profit and call it a day. This was pretty good even though it managed to get to $27.23. Can never get the exact bottom or top and that’s OK.

$ALLY 5m candles

I’ll be watching it for another setup like this. Possibly a little higher like $26.60 or $26.65 when it sets up again. Just have to be patient and wait for it.



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.

Trading Update - 1

Is anyone reading these? They’re mostly to track my progress so I guess I don’t care too much.

I’ve stopped creating watchlists and have not made a trade since $AMD earnings a few months ago. I haven’t found watchlists to ever be helpful for some reason. I’d mark support/resistance and areas I’d like to get in at but they’d never do what I want or I wouldn’t pull the trigger. Most of the time you’re just playing the stock too late and it isn’t volatile enough the next day.

I’ve found looking at the top gainers / losers in premarket with a fresh catalyst is much easier. Identifying the premarket trends with daily support/resistance levels then trading based off the trend changes makes it easier, too. It’s still really difficult because sometimes the stock just doesn’t do what you think it would, or you don’t pull the trigger and it does exactly what you want.


Anyway. The last few months I’ve still been working on trading algorithms for stocks. It’s taking forever to get each algorithm perfected because you can’t just backtest one stock going back 100+ days to make sure it works. Each day is different because of news and which stocks gap up/down the most. It will rarely, if ever, trade the same stock the next day. The patterns are valid but the pattern may not occur on the same stock going back X days.

The cool thing is it has made profitable trades going long and short (paper trading of course). Just yesterday it traded $SAIL on a red to green move and made a quick 50c/share. Today it took another red to green setup but it got in too late after the whole move was made. It could have been profitable but the volume came in after it already spiked (I have a relative volume check to filter out junk). So relative volume finally met the requirments after it made the move. It bought too high and got dumped on for a 25c loss.

I have to go in and optimize it to make sure it does not buy too far off from the open price. It’s a tedious process that takes forever because it might not take a trade for a whole week. I’m able to backtest using IB’s tick data on each individual trade to make sure it has proper entries and exits.

Another cool thing is one of my strategies I found because of Kunal Desai from Bulls on Wall Street (I’m not affiliated with them in any way) months ago. I was in his webinar and he was asking people to give a good example of an “opening range breakout” that occurred that day (it was technically a bull flag so I don’t know why he labeled it an ORB). Well, guess which stock my algo traded that day? $VRAY. The exact same one he said was a perfect example.

$VRAY

Example backtest:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Starting backtest on $VRAY...
Retrieving intraday candles/ticks...
Retrieving daily candles...
Backtesting 07/25/2018...
[07/25/2018 09:45:00] Entry @ $11.40, target $12.20, stop $11.12 [ Bull Flag ]
Trailing stop: 11.12, 11.42
[07/25/2018 09:50:00] Exit @ $12.22 [ $0.82 ]
P/L: $82.00
Gross P/L: $82.00 / $0.00
Commissions: $-4.00
Net P/L: $78.00
Win/Loss: 1 / 0 (100.00% / ∞)
Trades: 1 (1 long, 0 short)
Avg $ win/loss: $82.00 / $0.00
Best/Worst: $82.00 [ Bull Flag ] / $0.00 [ ]



Here’s an example of a trade it took recently on $CRTO. This is a bear flag chart pattern and it ended up working perfectly. It nearly caught the exact bottom which always impresses me. I let the algo do everything. I wanted to bail and/or take profit as soon as it dumped but I let it do its thing. I believe this was the largest move it ever captured. It was about 98c/share.

$CRTO 5 minute candles

Example backtest:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Starting backtest on $CRTO...
Retrieving intraday candles/ticks...
Retrieving daily candles...
Backtesting 08/01/2018...
[08/01/2018 09:50:00] Entry @ $26.41, target $25.41, stop $27.19 [ Bear Flag ]
Trailing stop: 27.19, 26.86, 26.52, 26.39, 26.21
[08/01/2018 10:10:00] Exit @ $25.38 [ $1.03 ]
P/L: $103.00
Gross P/L: $103.00 / $0.00
Commissions: $-4.00
Net P/L: $99.00
Win/Loss: 1 / 0 (100.00% / ∞)
Trades: 1 (0 long, 1 short)
Avg $ win/loss: $103.00 / $0.00
Best/Worst: $103.00 [ Bear Flag ] / $0.00 [ ]

Note the entry and exit is not exactly the same as the trade it took. This is due to it taking the trade on the exact tick that met the requirements to short and not with a 5 second delay.

If anyone is interested in this, here’s a few things I’ve learned:

I’m no expert and I’m still working on my algos so take this advice with a pile of salt.

  • MACD / moving average crossovers / other indicators are never going to work alone.

In hindsight they appear to work, but should only be used to confirm what you already know (aka a chart setup). One of my initial attempts at writing an algorithm used the MACD and it worked flawlessly on $ECYT but never anything else. I had to abandon that idea because I simply couldn’t filter out enough junk to make it work on multiple stocks.

  • Volume is very important for trading stocks.

Not just “minimum 100K traded on the day” but above average volume (aka relative volume greater than 1). IEX has a completely free API that can be used to retrieve the daily chart history for calculating relative volume. This will remove 90% of the bad trades alone. My algo trades significantly less since I’ve added this.

  • Range is also important.

What’s the point of trading some stock that has volume if it’s only moved 10c on the day? There should be decent range, at least 20c.

  • I threw out my old indicator based algos and decided to write code to identify chart patterns/setups that are likely to work.

So for instance the red to green move I mentioned above, that is a setup I’ve seen work over and over again and I use indicators to confirm the setup. It should be above VWAP and above the 9 EMA if it’s a long (or below those if it’s a short). If it meets all of the critera, it will take the trade.

This is what every “guru” teaches anyway, right? Chart patterns. Well, why not automate it?

  • Determining to exit a trade when it isn’t working is very important.

I look at multiple topping wicks / dojis / bottoming tails and multiple candles topping at a certain price to determine when it’s not working. Most of the time you get a nice bounce over your entry after a dip. So when the stock starts to top and can’t breakout of a range, you should just get out for a small win. This also prevents you from taking a larger loss because your stop wasn’t hit yet. When it bailed due to an exit indicator I have yet to see the setup go in my favor afterwards. The setup should work relatively quickly.

  • 1 minute chart is noisy and real time tick by tick candles are not necessary.

All of my intraday strategies work off the 5m chart with a delay of 5 seconds. There’s generally way too much crap happening on the 1m and if you try to algo trade off it, you’ll get stopped out all the time. Sometimes you have to give the setup time to work and 5m setups tend to be cleaner anyway.

  • Whole dollars reject and support all the time.

This is common knowledge and it’s psychology. I tend to target below a whole dollar for a long setup because they often reject or support. Also, I don’t buy or short near whole numbers for this same reason. If you short into a whole number, it’s probably a bottom or at least a temporary one that will stop you out. This has happened so many times that I had to add code to check for it.

  • “Perfecting” an algorithm takes time.

I’ll reiterate what I said earlier. No matter how clearly you define your strategy, you’ll most likely still end up with it taking bad trades because of something you forgot to check for. Especially since this is for stocks and you can’t backtest every single stock in the entire market over a period of months or years. This does not mean you should constantly change your algorithm. Sometimes the setup just won’t work.

  • Backtesting is useful.

I had to write my own backtesting code to utilize TWS tick data and IEX daily candle data. It wasn’t too difficult and the results are very helpful. Once I fix a bug in a strategy, I try to go back to a previous pattern / stock it traded and make sure it still does the same thing. Also, you need to use tick data for this! Simply using candles only does not give an accurate entry or exit.

  • Trailing stops lock in profit.

Once you’re in a trade and up say, 50c, move the stop to break even + a few cents so you cannot lose. Afterwards, only trail the stop if a previous low, VWAP, or EMA is above your entry. This will help follow the stock up and maximize gains. This is something that can be done after you have a working strategy. This is where backtesting is useful.

  • Patterns occur on stocks of all price ranges.

My algorithms have traded stocks ranging from $3 to $50. The price doesn’t matter so long as you take the same percentage gain out of it. You can limit your max share size (100) and max dollar value ($2,000) in a trade to minimize risk when trading higher priced stocks.

  • Writing your own trading application can be done using the TWS API and free APIs from IEX and tiingo.

If I was not using IB, I would not be able to write my own algo trading application. I probably wouldn’t have even gone down this road if they didn’t have an API.



So that’s where I’m currently at. Refining algorithms so I can eventually trade them with real money in the future. I still want to get better at trading in general so I can make money that way without algos and write new algorithms based on new things I learn.

I feel like I should mention that I have not read a single book about algorithmic trading, yet. I bought an intro book by Kevin Davey after seeing a webinar he did for TradeStation. That will arrive on Sunday.

This took a while to write so if you found this helpful, consider sending me a tip:

BTC: 12BMo7nBeBhDGDGagwqSRPAv3fkQi8nCfq
BCH: qrjulqz4ceapc0fp2449apu6g769mef3j5std2sl9r
LTC: LVSmZByqa6Cp1BFwgqeUyMjKmpfHP23ApR
ETH: 0xd163fdde358f9000A4E9290f23B84DFb6E9190D3
ETC: 0x4c60D3527AE8ea7b2085E4E399C47361E8ddc04b
DGB: DT4KW5ZJ56vqayBdftjbTftsXwCXyymXK7



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.

Learning to Day Trade - Part 18

Identify Trend Changes

The trend is your friend. I’m sure everyone has heard this saying at some point. Once a trend is established, it becomes much easier to trade. What I’ve discovered is: as soon as the trend changes, get in and go long/short depending on what the new trend is.

For this to work you have to be patient and not chase the new trend. Wait for the chart to develop and play the trend changes. If you can’t easily draw trendlines or the lines look too steep, then don’t trade them. It should be obvious.


On $TOPS, I first made a really dumb chase trade since I thought it’d squeeze and get up to $1.50 or so then top again. It didn’t, so I took 1c profit when it came back up. The trend was still in tact so I didn’t panic sell when it dropped. If I had noticed the first change to the upside I would have longed the breakout instead of chasing it that high. I immediately recognized this and knew it was a bad trade. Oh well.

A few minutes later, I identified another trend change based on the trendline I drew previously. The candle dropped really fast and I shorted when it came back up. I covered too soon but this trade was flawless.

$TOPS 1 minute candles

Next on $BBOX there was a huge spike/uptrend. I was unable to draw the uptrend on the 5m chart so that’s why you don’t see it here. It dropped and a new downtrend formed.

It changed trend again over about $1.52 and spiked into the premarket highs. Perfect. What you don’t see on the chart is it later dumped back to $1.46 at the open.

$BBOX 1 minute candles

Neither one of these were huge moves but these trend changes can occur on all stocks.


The next trading day (Monday) there wasn’t anything that crazy but there were some decent setups. $STAF had multiple descending triangles that worked perfectly. These pullback/continuation chart patterns work insanely well. So much so that there must be thousands of other traders drawing the same chart patterns and buying when they breakout.

I saw on Twitter that Roland traded the first entry that I marked. For some reason I rarely see people drawing these patterns when they post their charts. Maybe they don’t notice it and simply learned to recognize good entries.

$STAF 5 minute candles

Swing Trading



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.

Hiding Symbols in ELF Binaries

Under Linux when you compile C++ code using GCC or Clang there ends up being tons of debugging information that simply should not be there when you are not releasing open source software. The strip command does not do enough to remove that information.

In order to do this you need to pass -fvisibility=hidden and -fvisibility-inlines-hidden to the compiler. This will hide symbol names and reduce the size of the binary. However, if you are linking to something like boost, you won’t be able to hide symbols for the entire binary. In that case, you need to create two header files to programmatically change the visibility of your .cpp and .h files.

visibility_hidden.h:

1
2
3
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC visibility push(hidden)
#endif

visibility_pop.h:

1
2
3
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC visibility pop
#endif

In every code file / header file you’ll need to do this:

1
2
3
4
5
6
7
... other includes
#include "visibility_hidden.h"
... your code
#include "visibility_pop.h"

After you compile your program, you should then run strip --strip-all --discard-all ... and also sstrip ... from ELF Kickers.

Here’s a quick Python script I wrote to add the headers to .cpp files on Windows. It will look for the stdafx include and insert the visibility include underneath it then add the pop header to the end of the file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
stdafx = '#include "stdafx.h"'
for name in os.listdir():
if not name.endswith('.cpp'):
continue
with open(name, 'r', newline="\r\n") as f:
text = f.read()
if text.find('visibility') != -1:
continue
idx = text.find(stdafx)
if idx == -1:
continue
text = text[:idx + len(stdafx)].strip() + "\r\n" + '#include "visibility_hidden.h"' + text[idx + len(stdafx):]
text += "\r\n\r\n" + '#include "visibility_pop.h"'
with open(name, 'w', newline='') as f:
f.write(text)