Clean Windows Caches

I wrote a simple PowerShell script that will delete all files/folders inside the temporary file paths. It will also clear the shader cache for AMD GPUs. I set this up to run on every reboot.

1
2
$folders = @("C:\Windows\Temp\*", "C:\Windows\Prefetch\*", "C:\Documents and Settings\*\Local Settings\temp\*", "C:\Users\*\AppData\Local\Temp\*", "C:\Users\*\Appdata\Local\Microsoft\Windows\Temporary Internet Files\*", "C:\Users\*\AppData\Local\AMD\DxCache\*", "C:\Users\*\AppData\Local\AMD\GLCache\*")
Remove-Item $folders -force -recurse -ErrorAction SilentlyContinue

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.

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

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)

My Trading Problem

Ever since my large loss on $CALI, I’ve been more hesitent when I trade. I don’t know if it’s entirely caused by that one trade alone or because of the cumulative, yet small, losses that I’ve had in my IB account. The problem I’m faced with is entirely psychological. When I paper trade with the exact same setup in TWS, I do not hesitate to make trades and as long as I stick to patterns I recognize, I end up with decent gains even with 100 shares.

The problem seems to come down to risk management. I always try to determine my risk before entering a trade; which is obviously best practices. This ends up being a trap though since I generally determine there is too much risk (such as 20c to the downside, which is usually the low of a previous candle). I then do not take the trade and end up watching the setup play out perfectly. I always talk myself out of the trade by finding an excuse as to why it will not work: big spreads (5-10c), declining volume, huge 5m candle wick, time of day not ideal, etc.

I started watching “How to Think Like a Professional Trader” on YouTube. This part really stuck out to me:

(it has since been removed by YouTube)

If you didn’t watch the next 10 minutes of it, my main takeaway is this: you have to size down to the point where being wrong or losing money no longer matters. I thought 100 shares was small enough for me where I could focus on patterns and not care but it is not. On Monday I am sizing down to 10, and if that’s not enough I’ll go to 1.

After a few weeks of this I should be able to size up to 20 then 50 then 75 and hopefully back to 100 and just keep progressing slowly. I’m so glad I’m not under the PDT and the fees at IB are small. Every trade will still be a loss due to commissions but that doesn’t matter. Percent gain is what I’ll be going after when I post my trades, and I’ll be removing the dollar gain/loss from the chart. That way I can focus on just the chart and try to have good entries/exits.


Wednesday

I saw some “OK” opportunities on Monday and Tuesday but I either passed them up or missed them. Today I saw $GRPN had earnings and it had a nice morning panic. I waited for it to go green on the day (get over the open price) then I bought in with small size. My risk was down to the 5m 9 EMA or VWAP. I did not expect a huge move out of it and I got out when it couldn’t get over the premarket bounce at $5.50.

That ended up being perfect since there was a conference call at 10:00 that I was unaware of and then it proeceded to tank. I managed to stay in and not get faked out by the drop and captured almost all of the move.

$GRPN


That’s pretty much it for the week. I ended up paper trading on Friday for half the day and managed to make some money on $HEAR twice, and made a little on another stock that went red to green. Both worked out rather well. This weekend I’m going to work on my algorithm again with some new ideas.



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.

Trade Ideas - VWAP Scan

The basic idea behind this strategy:

  1. Buy after it breaks above VWAP and holds it, risk a few percent below VWAP.
  2. Buy after it has been rejecting VWAP for several candles and finally gets above, risk a few percent below VWAP.
  3. Short after it drops below VWAP and rejects it, risk a few percent above VWAP.

It’s not always obvious as to what you should do since each trade is unique.

If the stock is up a lot on the day, look for it to come down and test VWAP. If it breaks down through, wait for it to pop up and test VWAP. If it holds: long, if it rejects: short. Note that it can break a few cents above VWAP and then come down.

The opposite works if the stock is down a lot on the day. Wait for it to bounce into VWAP. If it breaks through and holds: long, if it comes back down and rejects: short the pop.

Not all stocks will follow VWAP so it mostly comes down to experience and how the chart looks. Avoid choppy/illiquid stocks and ones that have large 5m wicks. It seems to work best before 1:00 PM EST.

Here is the cloud link to the current scan that appears to find what I’m looking for. I made this with the demo account and modified it during the 5-day trial period. I’m sure I will tweak it in the future.

Unforunately VWAP does not appear on the charts accurately (with 4.2.28). It’s a known issue and they are working on it. Scanning is perfectly fine though.



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.

Trade Ideas - macOS

Trade Ideas is a stock scanner, screener, charting, etc. application that is Windows only (.NET). Fortunately the 32-bit version of it runs fine under macOS with Wine. I assume it also runs fine under Linux since it works with Wine.

Wine

  1. Download and install Wine.
  2. Download the 32-bit beta release.
  3. Install Wine by copying it to the Applications folder.
  4. Launch “Wine” and it should bring up a terminal.
  5. Install winetricks using brew.
  6. winetricks dotnet45 corefonts
  7. Navigate to your Downloads folder.
  8. Install Trade Ideas using: wine <exe name here>

Crossover

Crossover is a bit easier since it has an installer option for Trade Ideas Pro. It will automatically download the required packages without you needing to do anything. It’s very nice and worth paying for if you can afford it. Paying for it directly supports the Wine project because any bug fixes/improvements are added back to Wine.

  1. Download and install Crossover.
  2. Download the 32-bit beta release.
  3. Once you have installed Crossover, open it and select “Install a Windows Application”.
  4. Type in “Trade Ideas”.
  5. Go to the “Select Installer” tab and choose the latest TI Pro beta 32-bit EXE that you downloaded earlier.
  6. Follow the instructions and you should be good to go.

thinkorswim - Reversal Scan

This custom scanner will look for 3 consecutive red candles in a row along with an RSI below 20. It has not yet been tested during market hours, but that’s something I plan on doing tomorrow.

It will definitely need to be tweaked and possibly a “RateOfChange” study will need to be added. At the moment it is picking up two stocks at the close but they are not even down more than 2% in 15 minutes. It should only pick up stocks that are crashing hard and down more than 5% in a short amount of time.

Simple Reversal Scan

1
close is less than open and close from 1 bars ago is less than open from 1 bars ago and close from 2 bars ago is less than open from 2 bars ago and RSI("average type" = "SIMPLE")."RSI" is less than 20

thinkorswim - Use the News

thinkorswim has a built-in news scanner that allows you to sort based on recent news that has come out. For penny stocks I think this is mostly useful during premarket so you can get in before everyone else.

I haven’t found a way to filter based on price or float which is unfortunate.

Use the News

Click on the tiny play button separator to sort by recent news.

Use the News

Trading Review 2017

2017 was pretty good. I learned an incredible amount this year and cannot believe how little I knew when I first started trading in OptionsHouse / RobinHood.

I finally landed on the right broker and have begun focusing on setups I like instead of chasing the open like I was doing at the beginning of the year.

I made quite a few mistakes that ended in sizeable losses compared to my position size, but I still managed to keep the losses tight. It’s all part of the process.

profit.ly 2017

Trading Goals for 2018

  1. Eventually size up in a few weeks/months. Move up to 250, 500, and eventually 1,000 share positions.
  2. Start making $100+ per day when I start sizing up. That’s only a 10c move on 1,000 shares.
  3. Focus on 1-2 patterns (dip buys / breakouts on strong stocks).
  4. Rewatch some of Tim’s DVDs. I’ve seen most a few times but it never hurts to watch again!

Unrelated Goals for 2018

  1. Exercise more frequently.
    • I have kettlebells but I rarely use them. I want to work my way up to heavier weights.
    • I enjoy listening to podcasts while walking but that’s not very intense. I’d like to start sprinting and luckily I have a sizeable hill to sprint up. I’ve done that twice so far but the weather has been too cold for me to want to do it.
  2. Eat less refined carbs.
    • I’m a big fan of the ketogenic diet but sugar is so addictive and palatable that I end up falling out of ketosis. So mainly I just want to eat more leafy greens and cut out refined sugar as much as possible.