Trading Update - 10

Update 9

Just like my last post, it’s been a while since I’ve written one of these. I simply had to create another post detailing some of my recent trades.

First up is a trade I took following the Hivemind algo. It was a Ranger trade that got stopped out but I held because X3 got back in on the open. I probably should have added one contract since it dipped after hours but oh well - can only do so much.

I was watching it for most of the night and was waiting for it to get near my target of 2933 which was resistance from a few days ago. It randomly squeezed almost 20 points in my favor but did not reach my target. I instantly moved my order down and got out at the top. It was simply too perfect. X3 exited a day later at about the same price.



Next is a dip I just had to buy. I watched it start dumping after hours on some trade talk news. It was at the bottom of the range so I put an order at 2892 hoping for a bounce. I was instantly out for a $20 gain and it kept going.

Later it went lower and found support again. I had an order at 2883 but it never dumped again and had a huge move back up on more trade news. I missed every large move but at least I caught something.



And the last trade was just a 1 point short trade scalp for $4 profit. I was right about there being a pullback but it went higher first so I was too early. I did not screenshot this one.

Trading futures has been going really well so far and I haven’t had a single loss. I’ve been down close to $200 following the Hivemind but never closed out. I want to start using hotkeys for orders but I feel like they are too impulsive. They’re configured but I’ve never used them live on $MES.

Also, I now have a small TradeStation account which I’ll be using exclusively for algos. I may trade the Hivemind in it as well just to pad it up a bit.

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

Trade Review - September 2019

It’s been a while since I’ve done one of these.

I signed up for Triforce’s Tri Pro subscription that includes Hivemind alerts and have been trading them since September. This is the first time I ever made money following trade “alerts”. I hate even calling it that because it’s a system and not a “guru” telling you to buy/sell something. I am not being compensated in any way or asked to write this.

I haven’t been trading all of the alerts, just the @ES ones with the @MES contract and even then only some of the alerts. I still made enough trading the @MES contract to pay for the $130 subscription cost of September. Pretty awesome.

And while I’ve been live trading I am still working on my own algos for @ES. In one of his recent daily videos it gave me an idea and so far it looks promising. I wrote something over the weekend and it takes similar intraday trades compared to one of his algos. It needs a lot of testing before I ever trust it to trade live, but what I can do is let it output the necessary data and manually take the trades if I want to. I hate being this vague but I don’t want to give anything away.

For the most part I have stopped watching stocks all together. I fail to see the point in trading them when @ES has so much range and is open 23 hours a day. Why should I waste my time trying to find one or two stocks that have a perfect pattern?

The interesting thing about trading @MES futures is that I have no emotion when I’m down. With stocks it always feels like it’s going to collapse and I’ll be yet another bag holder. There’s always risk involved but I feel stocks, and especially penny stocks, have way more risk.

Take a look at this trade I took following the Ranger algo. I actually got in lower because I waited for it to dip again before entering. It doesn’t happen every time but can you really do this on stocks? You would have to be insanely lucky to find a penny stock that did this in a single day. Not to mention the amount of shares you would need to buy.

That’s it for this trade review. I’ve started trading the Hivemind and am still working on algos.

Ranger



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.

Creating a VM with DigitalOcean for Trading

Disclaimer: I take no responsibility if you follow this guide and get hacked and lose all your money. It’s best to run everything at home or hardware you own when possible.

I’ve already made a guide about moving trading algorithms to Linux and using Docker for Trader Workstation which can be found here. In this guide I will be going over how to setup a VM (aka VPS) at DigitalOcean for basically nothing to run Trader Workstation. You can follow the same steps with EC2 (or Lightsail), Google, Linode, or another provider. I would not recommend using a random cheap host you found off Google.

Affiliate link

Oracle now provides a free tier that gives you access to two VMs (at the time of writing). Give that a try if you don’t want to spend any money.

Step 1

  • I’ll be using Ubuntu 18.04 x64 with the cheapest $5 plan. This should be plenty for my needs and if not I can easily upgrade to the $10 plan with 2GB of memory.
  • I recommend enabling backups since it’s only $1 a month and if something bad happens you can restore the VM almost instantly.
  • The location is important since IBs servers are near New York. I have chosen the New York 3 location (not pictured).

Step 2

  • I recommend that you create a firewall rule to only allow SSH (port 22) inbound and ICMP. During the Linux setup part I will use ufw to create rules that only allow SSH inbound as well.

Step 3

SSH into the server (hopefully you’re using SSH keys and not passwords!). If you don’t know how to do that you probably shouldn’t be following this guide.

First, I’ll be upgrading and installing a couple packages. fail2ban is an easy way to block SSH brute force attempts. It’s not really necessary when using SSH keys. unattended-upgrades is to keep the system up to date without interaction.

1
2
3
apt update && apt upgrade -y && apt dist-upgrade -y
apt install fail2ban unattended-upgrades -y
apt autoremove -y

Reconfigure unattended-upgrades to automatically install stable updates.

1
dpkg-reconfigure unattended-upgrades

Reconfigure tzdata and set the timezone to US/Eastern. This might not be necessary but I don’t want any weird bugs popping up due to the timezone not being Eastern.

1
dpkg-reconfigure tzdata

Finally, reboot to use the new kernel that was probably upgraded.

1
reboot

Step 4

Configure the firewall.

1
2
ufw allow 22/tcp
ufw enable

Step 5

Now it’s time to install docker.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get install docker-ce docker-ce-cli containerd.io

It’s probably a good idea to hold the packages so if you upgrade while TWS is running it won’t upgrade docker and TWS will not restart. You can upgrade it manually each time by unmarking these packages.

1
apt-mark hold docker-ce docker-ce-cli containerd.io

Create a swap file since DigitalOcean does not have any swap to begin with.

1
2
3
4
5
fallocate -l 2G /swap
chmod 600 /swap
mkswap /swap
swapon /swap
echo '/swap none swap sw 0 0' | sudo tee -a /etc/fstab

Step 6

I will be using my own docker container for TWS. You can use someone elses or build your own like I did. In the future I may change the container to mount a volume for TWS settings so it’s not necessary to copy the configuration into the container.

1
2
git clone https://github.com/ryanclouser/docker-tws.git
cd docker-tws

This is where it gets a little tricky. You must go into your C:\Jts folder and look for a folder that is unusually long. This is used to identify settings for your account. You should have one for live and another for paper.

Copy the tws.xml from it into your docker-tws folder on the server. Go back one directory and copy jts.ini to the docker-tws folder as well.

Edit Dockerfile and replace the PROFILE value with it like so. It should be significantly longer than what is shown in the screenshot.

Change the PASSWORD field to something else if you want a strong VNC password.

Build the container.

1
docker build -t tws .

Step 7

And finally we can start the container and see it using VNC.

1
docker run -d --rm --name tws -e ARGS="username=IB_USERNAME password=IB_PASSWORD" -p 5900:5900 -p 7496:7496 -p 7497:7497 tws

You will need to reconnect with SSH using these parameters so local port 5900 connections are forwarded to the remote server through the SSH tunnel.

1
ssh ... -L 127.0.0.1:5900:127.0.0.1:5900

I like using TightVNC on Windows. There’s RealVNC on macOS and iOS which is just as good. And of course Remmina on Linux.

Final Thoughts

  • If TWS never logs in and opens, you probably need more RAM or a different Java version to be installed.
  • If you’re using this for algo trading where you do not need to see charts and what it’s doing every second, you can opt to use IB Gateway which is way less resource intensive.
  • 1GB of memory ended up working but I needed to create a swap file. If you chose to use TWS with an algo instead of IB Gateway, I would recommend at least 2 cores so TWS doesn’t hog it all.
  • At the time of writing I do not use any VPS for trading and simply run everything at home as that is more secure and the easiest/cheapest option.

Moving Algos from Windows to Linux

I always try to write code that is portable like using boost instead of calling native APIs or in the case of algo trading using C# which runs on most operating systems with Mono. Lately, I’ve been having so many issues with Windows or hardware that I’ve decided to just move it all to Linux so I don’t have to worry about it not starting when the market is open.

My main issues with Windows:

  1. Random Windows updates or doing updates then it decides to reboot in the middle of the night.
  2. Hardware or driver issues causing system instablity that take forever to diagnose.

I use Linux and docker for almost everything now so it only makes sense to move it to containers. I created containers for TWS and IB Gateway a few months ago but never got around to actually setting it up with the algos.

This is what my old setup was like: (for futures, otherwise just start at 9:25 AM on weekdays)

  1. Start TWS at 12:50 AM on weekdays using Windows scheduler.
  2. Start TWS at 5:55 PM on Sunday.
  3. Start the algo application 5 minutes after TWS opens.

I replicated the same process under Linux using cron and containers. I just setup the cronjobs so do not rely on them working as they have not been tested, yet.

TWS

I do not use a service here because I want to control it with cron. If you decide to do this make sure the docker IP has been whitelisted inside TWS (172.17.0.1 in my case).

You’d be surprised how responsive it is with VNC. Oh, and do not run this over the internet without some additional security like an SSH tunnel or a VPN.

1
2
3
50 0 * * 1-5 docker stop tws; docker run -d --rm --name tws -e ARGS="username=USER password=PASS" -p 5920:5900 -p 7496:7496 -p 7497:7497 tws
55 17 * * 0 docker stop tws; docker run -d --rm --name tws -e ARGS="username=USER password=PASS" -p 5920:5900 -p 7496:7496 -p 7497:7497 tws
0 17 * * 5 docker stop tws

TWS running inside docker

AlgoTrade

I use a simple systemd service that does not auto restart on exit.

1
2
3
55 0 * * 1-5 systemctl restart AlgoTrade.service
0 18 * * 0 systemctl restart AlgoTrade.service
0 17 * * 5 systemctl stop AlgoTrade.service

AlgoTrade


I decided to move TWS from cron to systemd services so it’s easier to restart things if needed. This has been tested more thoroughly.

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=TWS
Requires=docker.service
After=docker.service
[Service]
ExecStart=/usr/bin/docker run --rm --name tws -e ARGS="username=USER password=PASS" -p 5920:5900 -p 7496:7496 -p 7497:7497 tws
ExecStop=/usr/bin/docker stop tws
[Install]
WantedBy=multi-user.target

Updated cron:

1
2
3
4
5
6
7
8
50 0 * * 1-5 systemctl restart TWS.service
55 17 * * 0 systemctl restart TWS.service
0 17 * * 5 systemctl stop TWS.service
52 0 * * 1-5 systemctl restart AlgoTrade.service
0 18 * * 0 systemctl restart AlgoTrade.service
0 17 * * 5 systemctl stop AlgoTrade.service
0 0 * * 1-5 systemctl stop AlgoTrade.service

I use TWS instead of IB Gateway because I want to be able to more easily monitor trades, and trades rarely occur during the IB restart times so it’s been fine so far.

Update 8/20/19

I have been using this method of starting TWS and my algo app for a few weeks and it has been working perfectly. I never have to worry about it not starting at the appropriate time due to Windows.

thinkscript - Python Trade Analyzer

thinkorswim allows you to create custom strategies and backtest them but it is missing useful stats like winning percentage. This simple Python script will parse the trades and output a few basic stats.

Save the report from thinkorswim and run this script in the same directory as it.

thinkscript - Bollinger Band Alert

This script will sound an alert when a candle is outside the upper/lower bollinger band. It also looks at the candle size based on ATR to filter out some of the alerts. It may alert several times per candle if it continously ticks above/below the bollinger band and it may disappear entirely if it closes inside.


Outside Bollinger Band
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
input bollinger_length = 20;
input bollinger_devs = 2.0;
input bollinger_price = close;
input atr_length = 14;
input alert_text = "Outside Bollinger Band";
input use_alerts = {false, default true};
input alert_type = {default "BAR", "ONCE", "TICK"};
input alert_sound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};
def upper = BollingerBands(length = bollinger_length, price = bollinger_price, "num dev dn" = -bollinger_devs, "num dev up" = bollinger_devs)."UpperBand";
def middle = BollingerBands(length = bollinger_length, price = bollinger_price)."MidLine";
def lower = BollingerBands(length = bollinger_length, price = bollinger_price, "num dev dn" = -bollinger_devs, "num dev up" = bollinger_devs)."LowerBand";
def atr = ATR(length = atr_length);
def condition1 = (low < lower) and (close < open) and (open - close > atr);
def condition2 = (high > upper) and (close > open) and (close - open > atr);
def at = alert_type;
Alert((condition1 or condition2) and use_alerts, alert_text, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, alert_sound);
plot Above = condition1;
Above.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot Below = condition2;
Below.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);



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.

Trade Review - April 2019

I kind of took a little break in April. I wrote an @ES trading strategy using thinkscript and I made a tutorial for how to get started with it here, and because of how good the results have been I added futures support to my algo trading app.

It’s been interesting to say the least. A few winners and a few losers. I’m impressed with the results in thinkorswim so I’ve been paper trading it and making sure the trades line up between them. I’ve let my other stock algos trade but they seem pretty inconsistent, and I think it might be impossible to trade flags due to how often they dump. I decided to reverse the flag strategy to short and I’ll have to see how well that does.

I feel like at this point I should just trade @ES futures (or the micro contract when it comes out this month) because of how terrible stocks are. You can’t know if a particular setup will work on the next “hot” stock that pops up. At least with my @ES strategy it’s been somewhat consistent compared to stocks.

Besides algos, I’ve been slowly building a position in $SDIV since it pays a nice monthly dividend and I’m not doing too much with my IB account. I have 75 shares at the moment and want to get more and hold for a while.

I think I will stop posting algo trade recaps since they’re only useful if I want to go back and see what it traded. If I start live algo trading again then I’ll definitely log them with screenshots and video logs. All trades are logged into a database anyway so I can see what happened.

That’s pretty much it. Still working on algos, but focused more on futures.



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.

EZ WireGuard Setup

Keys

Generate keys on both the server and client.

1
wg genkey | tee privatekey | wg pubkey > publickey

Server

1
2
3
4
5
6
7
8
9
10
[Interface]
PrivateKey = <server private key>
ListenPort = 51820
Address = 10.0.0.1/24
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer]
PublicKey = <client public key>
AllowedIPs = 10.0.0.0/24

Client

1
2
3
4
5
6
7
8
[Interface]
PrivateKey = <client private key>
Address = 10.0.0.2/24
[Peer]
PublicKey = <server public key>
Endpoint = <server public ip>:51820
AllowedIPs = 10.0.0.0/24

Run

1
wg-quick up wg0

Daemon

1
2
systemctl enable wg-quick@wg0
systemctl start wg-quick@wg0

Headless Fluxbox / TightVNC

This guide is for Ubuntu 18.04. I needed a super lightweight GUI to run some applications without installing a full blown desktop environment and this seemed like a pretty good option. I would not recommend using this over the internet without an SSH tunnel.

  1. Install fluxbox and tightvnc.

    • apt install fluxbox tightvncserver xterm
  2. Run the VNC server manually on the user so you can set a password.

    • tightvncserver :0
    • tightvncserver -kill :0
  3. Edit /etc/systemd/system/tightvnc.service (change the user/group if needed)

    • 1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      [Unit]
      Description=TightVNC
      [Service]
      User=ubuntu
      Group=ubuntu
      Type=forking
      ExecStart=/usr/bin/tightvncserver -depth 24 -geometry 1440x900 :0
      ExecStop=/usr/bin/tightvncserver -kill :0
      Restart=on-failure
      [Install]
      WantedBy=multi-user.target
  4. Start.

    • systemctl daemon-reload
    • systemctl start tightvnc.service
  5. If you want to run GUI applications from outside VNC, export the display.

    • export DISPLAY=:0
  6. To add a custom menu edit ~/.fluxbox/menu

    • Add below [begin]
    • [exec] (xterm) {xterm}

Backtesting with thinkscript

I cobbled together a bunch of examples I found through Google into the samples provided below. thinkorswim is not that great for this, but it does allow you to visualize trades and get some idea of how well a strategy works. However, there is no way to fully auto trade a strategy. It’s possible to trigger an order based on a strategy being “true” but I would not recommend doing so. One thing to note is the sound alerts do not work and I haven’t found a solution.

Limitations

  1. Strategy can only be backtested on the chart duration it is applied to. This means a full backtest of years worth if intraday data is not possible unless you use the “OnDemand” feature.
  2. Strategy results window only shows basic trade P/L and a total P/L. No information about winning percentage or useful averages.
  3. Targets/stops end up trailing if the value changes (ATR in this case) and I haven’t found a way to make them static. I found examples to do that but they never worked properly.

Warning about stops. If you start seeing drastic improvements to your algos losses, make sure thinkorswim did not remove the price field from the stop loss order. This seems to occur when you save the strategy and it contains an error.

Creating a Strategy

The strategy will now appear in the “Price” window.

You should now see some trades on the chart. If not, it means your strategy has no trades or there’s something wrong with your stop loss/profit target prices causing it to only show up one time.

Backtesting

Now that you have a test strategy that shows up on the chart, you can backtest it to see the P/L. The first thing you will want to do is change the timeframe to as far back as possible. On the 5m, thinkorswim only allows you to go back 180 days. You can experiment with different timeframes and using the “OnDemand” feature to go back to certain years.

Right click on any entry, target, or stop and go to “Show report”.

And here are the results of the “Long Example” below starting on 4/13/19 going back 180 days on the 5m chart.

The strategy technically made money, however, it’s wildly inconsistent. Just because it made money in the end does not make it worth trading.

Long Example

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
29
input contracts = 1;
input rsi_length = 14;
input atr_length = 14;
input profit_mult = 2.0;
input stop_mult = 1.0;
input alert_text = "Long Example";
input use_alerts = {false, default true};
input alert_type = {default "BAR", "ONCE", "TICK"};
input alert_sound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};
def rsi = RSI(length = rsi_length);
def atr = ATR(length = atr_length);
def condition = (rsi < 30);
# Long
AddOrder(tickcolor = Color.GREEN, arrowcolor = Color.RED, name = "Long", tradeSize = contracts, condition = condition, type = OrderType.BUY_TO_OPEN);
# Profit
def target = EntryPrice() + ATR() * profit_mult;
AddOrder(type = OrderType.SELL_TO_CLOSE, high[-1] >= target, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Target", price = target);
# Trailing stop
def stop = EntryPrice() - ATR() * stop_mult;
AddOrder(OrderType.SELL_TO_CLOSE, low[-1] <= stop, tickcolor = Color.GRAY, arrowcolor = Color.GRAY, name = "Stop", tradeSize = contracts, price = stop);
# Alerts
def at = alert_type;
Alert(condition and use_alerts, alert_text, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, alert_sound);

Short Example

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
29
input contracts = 1;
input rsi_length = 14;
input atr_length = 14;
input profit_mult = 2.0;
input stop_mult = 1.0;
input alert_text = "Short Example";
input use_alerts = {false, default true};
input alert_type = {default "BAR", "ONCE", "TICK"};
input alert_sound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"};
def rsi = RSI(length=rsi_length);
def atr = ATR(length=atr_length);
def condition = (rsi > 70);
# Short
AddOrder(tickcolor = Color.GREEN, arrowcolor = Color.RED, name = "Short", tradeSize = contracts, condition = condition, type = OrderType.SELL_TO_OPEN);
# Profit
def target = EntryPrice() - ATR() * profit_mult;
AddOrder(type = OrderType.BUY_TO_CLOSE, low[-1] <= target, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Target", price = target);
# Trailing stop
def stop = EntryPrice() + ATR() * stop_mult;
AddOrder(OrderType.BUY_TO_CLOSE, high[-1] >= stop, tickcolor = Color.GRAY, arrowcolor = Color.GRAY, name = "Stop", tradeSize = contracts, price = stop);
# Alerts
def at = alert_type;
alert(condition and use_alerts, alert_text, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, alert_sound);

Buy Open/Close (stocks)

Buy Close Sell Open

1
2
3
4
5
6
7
8
9
10
11
input Size = 100;
input OpenTime = 0930;
input CloseTime = 1600;
def condition = SecondsFromTime(CloseTime) == 0;
# Buy
AddOrder(type = OrderType.BUY_AUTO, tickcolor = Color.GREEN, arrowcolor = Color.RED, name = "Long", tradeSize = Size, condition = condition, price = dailyClose);
# Sell
AddOrder(type = OrderType.SELL_TO_CLOSE, SecondsFromTime(OpenTime) == 0, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Target", price = dailyOpen);

Buy Open Sell Close

1
2
3
4
5
6
7
8
9
10
11
input Size = 100;
input OpenTime = 0930;
input CloseTime = 1600;
def condition = SecondsFromTime(OpenTime) == 0;
# Buy
AddOrder(type = OrderType.BUY_AUTO, tickcolor = Color.GREEN, arrowcolor = Color.RED, name = "Long", tradeSize = Size, condition = condition, price = dailyOpen);
# Sell
AddOrder(type = OrderType.SELL_TO_CLOSE, SecondsFromTime(CloseTime) == 0, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Target", price = dailyClose);

Some additions you could make to these is seeing if it closed red or closed green on the day.

1
2
def dailyOpen = open(period = AggregationPeriod.DAY);
close > dailyOpen

or buy only on specific days of the week:

1
2
def day = GetDayofWeek(GetYYYYMMDD());
(day == 1 or day == 5)

Stops

Checking for a double top:

1
high == high[1]

Checking for a double bottom:

1
low == low[1]

Ticks for a stop loss:

Add/subtract the tick size from the entry price depending on a long/short trade.

1
def stop = EntryPrice() + (TickSize() * 4);

Filtering Open/Close Times

1
2
3
4
5
6
7
8
input OpenTime = 0930;
input CloseTime = 1600;
# Between open/close time
def timeframe = SecondsTillTime(OpenTime) <= 0 and SecondsTillTime(CloseTime) >= 0;
# Outside open/close time
def timeframe = (SecondsTillTime(OpenTime) > 0 or SecondsTillTime(CloseTime) < 0);



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.