Send SMS alerts from your trading algorithms in Python

Occasionally there may be some important alerts that you want your trading algorithms to send to you that require immediate attention. One that I use frequently is daily account drawdown. Here’s how you can set up Twilio to send you a text message when your account enters a certain percentage of drawdown.

Head over to Twilio

You do need to purchase a number to text from. It costs $1/month. You can find that here.

You’ll now need to go to your general settings page to retrieve your live credentials.

The next step is to install Twilio on your operating system. I use Ubuntu this can be done with the following command

sudo pip3 install twilio

Great now you’re ready to code.

The first thing you want to do is write a simple Python script to test your message sending capabilities. In the below code you’ll want to change a few variables:

account_sid – Change with your Twilio information found on your account page.

Auth_token – Change with your Twilio information found on your account page.

Using the format +19998887777 change to_num to your cell

Using the format +19998887777 change from_num to your Twilio phone number

def send_sms(to_num,from_num,body_message):
    import os
    from twilio.rest import Client

    account_sid = 'Enter your account sid here'
    auth_token = 'Enter your account token here'
    client = Client(account_sid, auth_token)

    try:
        message = client.messages.create(
            to=to_num,
            from_=from_num,
            body=body_message
        )

        print(message.sid)
    except Exception as e:
        print(e)

if __name__ == '__main__':
    send_sms(+14809999999,+17149999999,'test')

Now that we have a function that can send text messages we just need to incorporate this into our code.

Setting up Python algos to run on Ubuntu startup using systemd

If you’re running your trading algorithms on Linux the best way to get them to start on bootup is to use a service called systems. Here are the steps on setting that up.

Go to:

/etc/systemd/system


Then create a new service as root:



sudo nano trading_algo_23.service


Here is a sample of what the file should look like. You can find your account name by using the command whoami in linux



[Unit]
Description=This algo is designed to hedge...



User=your username
WorkingDirectory=/directory/of/algo
ExecStart=/usr/bin/python3  /directory/of/algo/algo_23.py
Restart=always



[Install]
WantedBy=multi-user.target

Now reload systems

sudo systemctl daemon-reload


Enable the service

sudo systemctl enable

Start your script:

sudo systemctl start trading_algo_23.service


Check the status:

sudo systemctl status trading_algo_23.service

Setting up Python algos to run on Ubuntu startup using crontab

If you’re using Ubuntu or some other flavor of Linux you more than likely want your algorithm to start with the server. This is a pretty straightforward process.

The first thing you’ll want to do is make sure cron is installed

sudo apt-get update
sudo apt-get install cron

Next run crontab -e select nano when it asks which editor. The code below can be used as a template The first two lines are just writing the current date to the log files on reboot so you know when the server was restarted.

@reboot date >> /home/me_jeremywhittaker_com/AAII/log.txt
@reboot date >> /home/me_jeremywhittaker_com/AAII/errors.txt

    

I actually am running two scripts for this particular strategy. Each one gets its own line of code. This basically tells it to run on on startup @reboot then the path to the script to execute,

@reboot /home/me_jeremywhittaker_com/queen_of_stonks/queen_of_stonks_monitor.py >> /home/me_jeremywhittaker_com/queen_of_stonks/logs.txt 2>> /home/me_jeremywhittaker_com/queen_of_stonks/errors.txt 

@reboot /home/me_jeremywhittaker_com/queen_of_stonks/queen_of_stonks_trade.py >> /home/me_jeremywhittaker_com/queen_of_stonks/logs.txt 2>> /home/me_jeremywhittaker_com/queen_of_stonks/errors.txt

That’s it. We can now do a sudo reboot and our scripts should start with our server and save to the log files indicated.

Earn 7.12% on money sitting in your checking or savings account and hedge against inflation, risk-free, here’s how.

If you’re like me you probably have money sitting in your checking, savings, or money-market account. Paying practically zero interest and getting eaten alive by inflation. Here’s what you can do to earn 7.12% on that money and get inflation-adjusted returns on your excess cash.

Yield on savings and checking accounts are horrible

If you’re like me you’re probably trying to move your liquid funds around into these high-yield savings accounts which aren’t exactly keeping up with inflation. In fact, to date, the highest I can find is LendingClub at 0.60%

Inflation is a regressive tax on the poor and middle class

The annual inflation rate in the US has surged to 6.2% in October to 2021 according to the US Bureau of Labor and Statistics. This means your buying power is dropping significantly if you are holding on to cash. You of course know this if you have bought anything recently.

Use I bonds for risk-free inflation-adjusted return on your cash

To get the 7.12% yield you can buy I bonds which are backed by the United States government. They are inflation-adjusted. Meaning, you’re not technically building any wealth but you’re also not allowing the government to steal it through inflation. You can read more about how the rate is calculated here.

  • I bonds are an excellent investment rather than holding cash
  • They are exempt from state and local taxes
  • Subject to federal taxes.
  • Tax-deferred until you redeem them.
  • Mature in 30-years or until you redeem them
  • Redeemable after the first year of purchase
  • Early redemption is penalized with 3-months worth of interest
  • Interest is compounded every 6-months
  • Your money is locked up for a duration of 1-year

Historical I bond rates

Period when you bought
your I bond
Composite rate for your six-month earning period starting during November 2021 – April 2022
(See “When does my bond change rates?”)
FromThrough
Nov. 2021Apr. 20227.12%
May 2021Oct. 20217.12%
Nov. 2020Apr. 20217.12%
May 2020Oct. 20207.12%
Nov. 2019Apr. 20207.33%
May 2019Oct. 20197.64%
Nov. 2018Apr. 20197.64%
May 2018Oct. 20187.43%
Nov. 2017Apr. 20187.22%
May 2017Oct. 20177.12%
Nov. 2016Apr. 20177.12%
May 2016Oct. 20167.22%
Nov. 2015Apr. 20167.22%
May 2015Oct. 20157.12%
Nov. 2014Apr. 20157.12%
May 2014Oct. 20147.22%
Nov. 2013Apr. 20147.33%
May 2013Oct. 20137.12%
Nov. 2012Apr. 20137.12%
May 2012Oct. 20127.12%
Nov. 2011Apr. 20127.12%
May 2011Oct. 20117.12%
Nov. 2010Apr. 20117.12%
May 2010Oct. 20107.33%
Nov. 2009Apr. 20107.43%
May 2009Oct. 20097.22%
Nov. 2008Apr. 20097.84%
May 2008Oct. 20087.12%
Nov. 2007Apr. 20088.36%
May 2007Oct. 20078.47%
Nov. 2006Apr. 20078.57%
May 2006Oct. 20068.57%
Nov. 2005Apr. 20068.16%
May 2005Oct. 20058.36%
Nov. 2004Apr. 20058.16%
May 2004Oct. 20048.16%
Nov. 2003Apr. 20048.26%
May 2003Oct. 20038.26%
Nov. 2002Apr. 20038.78%
May 2002Oct. 20029.19%
Nov. 2001Apr. 20029.19%
May 2001Oct. 200110.23%
Nov. 2000Apr. 200110.64%
May 2000Oct. 200010.85%
Nov. 1999Apr. 200010.64%
May 1999Oct. 199910.54%
Nov. 1998Apr. 199910.54%
Sept. 1998Oct. 199810.64%

Here’s how you can buy I bonds

The first step is to sign up for a TreasuryDirect account which can be done here.

Once your account is set up you can log in here. You should have received your account number via email confirmation.

Once logged in you’ll see this screen.

Click on the BuyDirect option at the top. You’ll want to select series I bonds.

The most you can buy per social security number is $10,000/year

That’s it. Click submit.

And finally your confirmation page. Pretty simple and straightforward process.

Have kids?

If you have kids you can gift $10,000/year to them as well in I bonds. Read more on gifting I bonds here.

Want to purchase $5,000 more in I bonds every year?

You are also allowed to buy an additional $5,000 worth of I bonds every year with your tax return. That is of course if you have a tax return. You can do this by overpaying your taxes intentionally to the IRS via their website, here. I wouldn’t overpay by exactly $5,000 but probably an amount over. You can read more of the details on that process here. They are going to send you paper I bonds so you will want to convert them and attach them to your online account for ease of management. You buy I bonds with your tax return by submitting tax form 8888 with your taxes

Converting your I bonds to treasury direct electronic format

Directions on this process can be found on the treasury direct website, here.

You will need to create a conversion account one time.

You then need to create a registration list that matches the paper bond ownership that is printed on the paper bonds.

How to enable Python API in Interactive Brokers Trader Workstation

You’re going to want to open Interactive Brokers trader workstation as normal. Then head over to edit>Global Configuration and check that first box.

Enable ActiveX and Socket Clients

The next thing you’ll want to download is the API’s found here – http://interactivebrokers.github.io/

Next, open the command prompt as an administrator and switch directories where you installed it.

d:

D:\TWS API\source\pythonclient

python setup.py install

You will see this if it is completed successfully

Installed c:\program files\python39\lib\site-packages\ibapi-9.76.1-py3.9.egg
Processing dependencies for ibapi==9.76.1
Finished processing dependencies for ibapi==9.76.1

D:\TWS API\source\pythonclient>

I use IntelliJ to to test I’m going to run a simple command

import ibapi

You can see it ran successfully.

So let’s test a little further.

I’m going to run the following Python code

import ibapi

from ibapi.client import EClient
from ibapi.wrapper import EWrapper

class IBapi(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)

app = IBapi()
app.connect('172.16.105.5', 7496, 123)


app.run()

import time
time.sleep(2)
app.disconnect()

This shows it was successful

“C:\Program Files\Python39\python.exe” “G:/My Drive/IdeaProjects/interactive_brokers/interactive_brokers_api_test.py”
ERROR -1 2104 Market data farm connection is OK:usfarm.nj
ERROR -1 2104 Market data farm connection is OK:cashfarm
ERROR -1 2104 Market data farm connection is OK:usfarm
ERROR -1 2106 HMDS data farm connection is OK:euhmds
ERROR -1 2106 HMDS data farm connection is OK:fundfarm
ERROR -1 2106 HMDS data farm connection is OK:ushmds
ERROR -1 2158 Sec-def data farm connection is OK:secdefnj

Shorting stocks to protect your home’s equity without selling your house

Almost everyone in the United States who owns a home has seen a massive increase in the equity of their house. In the Phoenix metro area, we have seen massive gains. For instance, a house I purchased 1-year ago has seen around a 50% increase in value. Today I was discussing with a friend his options for protecting his equity shorting housing stocks rather than selling his primary residence.

Let’s take a look at the Case-Shiller and Zillow estimates for our local Phoenix market.

Phoenix has been one of the hottest real estate markets over the last few years. In addition, we have seen a huge population increase in Arizona.


2020 Population
2010 Population+ People+ %
Utah3,271,6162,763,885507,73118.4
Idaho1,839,1061,567,582271,52417.3
Texas29,145,50525,145,5613,999,94415.9
North Dakota779,094672,591106,50315.8
Nevada3,104,6142,700,551404,06315
Colorado5,773,7145,029,196744,51814.8
District of Columbia689,545601,72387,82214.6
Florida21,538,18718,801,3102,736,87714.6
Washington7,705,2816,724,540980,74114.6
Arizona7,151,5026,392,017759,48511.9
South Carolina5,118,4254,625,364493,06110.7
Georgia10,711,9089,687,6531,024,25510.6
Oregon4,237,2563,831,074406,18210.6
Delaware989,948897,93492,01410.2

But are the prices high? I was to pause for a minute and look at the median sales price overlayed on the median family income. You have to normalize the price of a house. Given that people by houses a fair way to normalize this variable is to make it relative to the income of the average family or individual if you prefer.

You can also use the median sales price of a house as the numerator and income as the denominator. This creates an oscillating indicator in which the peaks show the high price values and the troughs show the low price values. Do keep in mind this does not adjust for interest rates. This is a much more complicated formula so I won’t dive into this deeper. However, I do believe it is extremely relevant. Also, the data available on FRED isn’t updated to 2021 yet. So all of the appreciation we’ve seen in the last year or so is not accounted for in these charts. If I had to guess house prices are up significantly more than income.

I have heard a lot of people talk about selling their houses to capture the appreciation value because they “know” the prices will come back down. This is an extremely speculative comment but it’s one that I’ll entertain. In fact, I’ve thought about selling some houses as well. But know speculating with your primary residence is risky.

I want to outline some basic math here for anyone who is thinking about selling their house and the true cost. Let’s say you have a house that is now worth $400,000. You paid $200,000 initially. You now have $200,000 in equity. However, if you were to sell this house you’re looking at commissions for the buying and selling realtor plus miscellaneous fees. Let’s call this a total of 8%. It’s going to cost you roughly $32,000 to sell this house. Not to mention all of the other stress that comes with moving. This $32,000 represents almost 16% of your equity. You’re going to lose 16% of your equity if you make this move.

So let’s talk about creating a market-neutral position by short-selling residential construction companies in Arizona. I did not perform a comprehensive search for residential construction companies in Arizona. But I was able to pull up 6 publicly traded residential construction companies pretty quickly. Below you will find their 1-year return charts.

So let’s say you want to protect your $200,000 in equity as in the previous example. You could open short-sale positions in all of these stocks evenly. I highly recommended against short-selling one stock with any large percentage of your portfolio. The reason why is the downside loss is infinite. Short selling is extremely dangerous. The math for short selling these stocks is evenly balanced is pretty straightforward. You take your $200,000 and divide it by 6. This gives you $33,333 that you will want to short of each stock. You then take this number and divide it by the share price of the stock. In the last example, Toll Brothers is selling for $63.48. This would mean you would sell short 525 shares of this stock. So what we have essentially done here is make the determination that these stocks represent the value of house prices or that they have a high cointegration to house prices. Therefore if the housing prices go up you will lose money on your short and gain money on your house’s equity. Likewise, if housing prices go down you will make money on your short and lose money on your house’s equity. This puts you in what is called a market-neutral position. This occurs when you find highly cointegrated assets and place trades in opposite directions. Inherently you are long your house because you own it. So what we’re trying to accomplish is a short position equal to the value of your house. Or equal to the value of your equity.

There are also a few other techniques that I will not go into in this article.

  • I would recommend analyzing the short interest ratio of the stocks you plan on shorting. This is the open short interest divided by the daily trading volume.
  • Resaearch out of the money put options. This is a much cheaper way to make this bet with a limited downside risk. But options require a lot of effort and research.
  • Instead of short selling specific stocks you can short sell the entire residential construction industry through different ETFs like XHB, HOMZ, or PKB.

Delta Variant is Coming and I’m not Concerned.

If you look at the cases of the Delta variant of Covid coming out of the UK it looks alarming and it appears we’re getting ready to get another wave of Covid to shut down the world. But not so fast.

Let’s take a look at the hospitalization and the death rate.

Hospitalizations are clearly ticking up but clearly not with the velocity of the infection rate.

Death rate although lagging appears to be the same.

Pretty flat given what the first and second waves did to the UK.

One of two things are happening. Either A, the delta variant is not as deadly. Or B, the vaccinations are working.

But what about the kids? Kids or people under 20 haven’t really been impacted by Covid. Deaths aren’t a perfect summary of this. But they do give you an idea of the impact. You can extrapolate the hospitalizations based on these figures.

I would be concerned if I was elderly, had pre-existing conditions, or wasn’t vaccinated. Meaning I would still wear a mask and social distance. But outside of those parameters, this new variant does not appear to be nearly as deadly as the first for people who are vaccinated.

Are we living in a simulation?

I was reading this article today from the Wall Street Journal – Brain Implant Lets Man ‘Speak’ After Being Silent for More Than a Decade(Original article from the New England Journal of Medecine). It begs the question, are we living in a simulation?

It may be a good time to watch the movie, The Matrix. Perhaps it wasn’t so far-fetched after all.

Here is a brief overview of the concept of the technology.

This means we’ll be able to communicate with each other without ever speaking or hearing. The concept is amazing if you take a second to think about it. Computers are interpreting our senses. They are reading the signals from this man’s brain, pushing those through a deep neural network, and decoding those signals into sentences.

  • Imagine tasting without ever putting anything in your mouth.
  • Imagine smelling without ever sniffing.
  • Imagine seeing without ever opening your eyes.
  • Imagine talking without opening your mouth.
  • Imagine hearing but there is no noise.

Once this technology emerges there is no reason why the matrix could/does not exist. In fact, it makes it difficult to argue that you may potentially be living in a simulation currently. Keep an eye on Elon Musk’s Neuralink.

Finding the Next Gamestop or AMC

As we see the surge of meme stocks like AMC 30.28 +1.71 +5.99% or GME 181.56 +1.72 +0.96% you might be wondering how you can profit and get the jump on the next meme stock to pop. You can actually look at the stock options volume leaders chart. This chart will give you ideas for what stocks are most likely to pop before they actually do. Another chart to look at is the most active stocks by volume.

Once you do your research and are ready to invest in a specific company you can then use a breakout strategy like turtle trading to place stop orders to enter your trades at specific price levels. Another approach is to buy out of the money put or call options that have the ability to drastically increase in value as the stocks start to move.

Closing SLV trade – 121% in ~10 months

Last year during Covid I decided to purchase some silver options.

4/20/202025925191587Bought SLV Jan 21 2022 15.0 Call @ 3.25
4/20/202025925192864Bought SLV Jan 21 2022 15.0 Call @ 3.25
4/21/202025951958123Bought SLV Jan 21 2022 20.0 Call @ 2.03
5/15/202026407463083Bought SLV Jan 21 2022 30.0 Call @ 1.15
5/28/202026590777533Bought SLV Jan 21 2022 19.0 Call @ 2.59

Reasons for the trade

  • Gold/Silver ratio was the highest it’s been in years.
  • Covid was sure to send the government into a massive printing spree.
  • Silver is the “poor man’s gold” most people could afford to buy it.
  • APMEX.com where I buy my precious metals had a huge spread on silver over spot price.

Exiting the Trade

I’ve now closed this trade with 121% in profit. What is funny is the profit came the same week I initially made the purchase. I just held it for a long time because I thought the government’s printing press would push it a lot further. However, I’m starting to lose confidence in precious metals as a hedge to government printing, for the short term anyway. I more so think we’ll see inflation and as that loses control a shift to precious metals as a hedge to wealth preservation. I’m keeping my VDC(Vanguard Consumer Staples ETF) position open for now.

3/10/202133321473374Sold SLV Jan 21 2022 30.0 Call @ 1.94
3/10/202133321512258Sold SLV Jan 21 2022 19.0 Call @ 6.25
3/10/202133321508484Sold SLV Jan 21 2022 15.0 Call @ 9.5
3/10/202133321479857Sold SLV Jan 21 2022 20.0 Call @ 5.59

Keeping the trade open

I think there is plenty of reason for someone to keep a trade open based on some of the supply volatility we’ve seen over the last couple of months. However, my precious metals positions are getting hit pretty hard lately and I’m not sure I want to maintain this trade.

I should also note I still maintain 1-2% of my net worth in physical silver. The target is 1% but the fluctuation comes from price increases.

Closing ULTHF trade 17.8% – 13 days

You can read about my previous post on this short position here.

This stock has returned to its normal volatility and I’m up 17.8% in about two weeks. I’m happy with this trade. I closed my position today at .82

The original premise of the trade was to short this giant undeserved spike in the price indicated in the picture below. I’m still confident there is a ton of room for this to continue to the downside. However, it’s recent volume is low and I have no reason to expose myself to any unforeseen risk.

Why I’m shorting ULTHF

I woke up to this text message yesterday.

It was completely unsolicited and I have no idea what the source of it is. Could it be a potential pump and dump given the current market circumstances? Maybe… so I decided to dig a little into this company. It looks like it spiked a few years back and has been basically worthless for the last 3 years.

What’s interesting is it looks like it is being pumped again recently. Here is the last 2 years.

Zooming in closer it looks like there has been a massive amount of volume increase in the last 3 days. Hence my text message perhaps?

What about Google Trends did people recently just start searching for ULTH or ULTHF?

I wonder what reddit has to say.

Financials

Finally, I wonder what their financials look like? Would I be comfortable holding this short position?

Let’s keep in mind this company has a market cap of $42m

But..

Only $80k in cash.

$7,500 in accounts receivable

$92k in assets

$323k in liabilities

-$5,032,200 in retaind earnings

But Lithium is rare and the price is about to explode!

So let’s take a look at LIT which is an ETF that holds a bunch of Lithium related stocks. https://www.globalxetfs.com/funds/lit/

As you can see from their holdings ULTHF is not listed. This adds further evidence this stock should be shorted. In fact, if you wanted to take a more market neutral approach to this trade you could go long an equal-weighted amount of LIT.

Time to get short

Seems like more pump and dump hype. I’m definitely going short.

I tried to get short on 2/24 @ 1.40 but my broker didn’t have any shares available.

So I got an email this morning…

I was able to open a position this morning short @ 1.15. It has fallen already so I’m opening another short position @ 1.01. This trade would already be up 40% if it wasn’t rejected yesterday.

The world’s largest short squeeze tomorrow? My 2020 trade already up 193% should benefit heavily.

Last year I was looking to up my precious metal holdings. I like to keep 10% of my net worth in gold and 1% in silver. I bumped my gold holdings to 20% given the Coronavirus outbreak amongst other reasons outlined below. However, when I went to go and purchase silver from APMEX. I noticed the cheapest bullion I could get was something like 10-20% over spot price So I switched to long-dated options instead. I landed on a few. But eventually piled in on one a strike price of 30 with an expiration of January 21st, 2022. I bought these for $1.15 at the time. Looks like I actually picked the worst out of the four that I bought. No worries though I’m not complaining at a 192.68% increase.

The reason for my trade were as follows:

Physical silver was trading way over spot price at APMEX

The gold to silver ratio was the highest it has ever been in the last 100-years.

When governments get in trouble they just inflate your money away. It has been this way since the beginning of time.

This image has an empty alt attribute; its file name is image-3-1024x925.png

The federal reserve rate was basically dropped to 0% indicating massive problems.

This image has an empty alt attribute; its file name is image-1-1024x521.png

Silver is the “poor man’s gold” as Covid struck harder I assumed it would rally on the Fed’s printing press which was sure to accelerate and the Fed’s balance sheet had spike massively.

This image has an empty alt attribute; its file name is image-6-1024x374.png

The fed now owns 1/3 of all mortgage-backed securities. They are literally bailing out every asset class at risk of jeopardizing the future of the sovereign credit.

This image has an empty alt attribute; its file name is image-7-1024x484.png

Update:

r/wallstreetbets - Wikipedia

It has been rumored that online bullion sites have ran out of silver until the markets open tomorrow and Wall Street Bets may have their sites set on SLV as their next target. I’m not so sure they can pump silver up 1,600% like they did with GME but it will be interesting to see what can be done. Supply of silver is already very low after the markets closed Friday. Here is a quote from WSB, “Corner the market. GV thinks its possible to squeeze $SLV, FUCK AFTER SEEING $AG AND $GME EVEN I THINK WE CAN DO IT. BUY $SLV GO ALL IN TH GAINZ WILL BE UNLIMITED. DEMAND PHYSICAL IF YOU CAN. FUCK THE BANKS.

I just put in a big order for SLV options 30.5 strike expiring 2/5/21. My issue is the market is closed. I put in the order at .23 limit and I’m not sure if it will get filled. Regardless I’m still holding a bunch of futures from my previous trade. Future markets are already showing a large breakout.

Here is a message from the CEO of APMEX:

APMEX Statement On Current Market Conditions:

In the last week, we have seen a dramatic shift in Silver demand from our customers. For example, the ratio of ounces sold per day was running about two times earlier in the week and closer to four times the average demand by the end of the week. Once markets closed on Friday, we saw demand hit as much as six times a typical business day and more than 12 times a normal weekend day. Combined with the extremely high demand levels, we are also seeing a surge in new customers. On Saturday alone, we added as many new customers as we usually add in a week.

Any Precious Metal dealer will take a long position in the futures market to protect against spot price exposure when the markets open. We do this because it is our goal not to take a speculative position on metal. The weekends are unique as we are not able to real-time hedge our position. We took an aggressive position this weekend, but clearly could not have predicted the volumes that were seen. We have partnerships around to world that allowed us to cover these long positions, but only to a point. Once we exceeded our comfort levels, we had little choice but to stop the sale of Silver on our website. This was a difficult decision to make and unprecedented in our history.

As we evaluate the markets, it is difficult to know where Silver’s price and demand will go in the coming day and weeks. APMEX is highly capitalized and has more than $150 million in inventory to support demand. We have made strategic decisions to procure additional metal, locking up any metal we can find in the market place. We suspect premiums will rise and rise quickly, as we are seeing significant increases in our costs, when we can even locate the metal. It is also highly likely that we will need an additional day or two to fill orders based on current order counts. The one guarantee we can make to our customers is that you will only be sold metal that is on-site, or we have procured the metal with a firm commitment date from our partners. In markets like this, we feel this is the best approach a retailer can take, as no one can predict product availability.

We want to thank our customers for their patience and understanding during these turbulent times. APMEX prides itself on best in class service and delivering on promises to our customers.

Regards,

Ken Lewis
CEO, APMEX

I’ll let TheHappyHawaiian explain:

Here is his updated post:

Want $300 for free?

I remember back in 2000 during the dot com bubble all of these companies would pay you just to surf the internet using their browser or plugin. We may be in another bubble of some sort but that’s not my purpose of this article.

Recently I received a pop up on Facebook for SoFi. A free $350 just for funding a loan. Interesting, so for kicks I applied. My application is still pending but I can’t imagine I won’t get funded. They had a minimum loan amount of $10,001.

They indicate that they will give you the $300 within 30 days of funding your loan. The interest rate is 9.25% which is about $77/month in interest. So you’ll want to pay the loan off with the money you receive as soon as the bonus funds are received. Technically you’re probably only going to net $223. But hey that’s almost 40% of what the government is giving out for stimulus.

What’s interesting is this company is also giving away a free $50 in stocks just for opening an investment account. Another free $25 in Bitcoin just for opening a crypto currency account and buying at least $10 worth of crypto.

Seems like they’re pretty desperate to boost their sales for their upcoming IPO and inflate their valuation. You might as well take advantage of it.

Cannabis Grow journal

Water

You always want to make sure your water is at a pH of 5.8. I calibrated my pH meter and then measured my tap and RO water. You can always then measure these two as a baseline to make sure your meter doesn’t need to be recalibrated.

Tap water pH: 6.1 / RO water pH: 6.6

1.16.21-Tap water pH: 7.3 / RO water pH: 8.2

Here is a list of things you will need to calibrate your water.

2021.1.3 2100

First step is to simply drop your seeds into RO water. I would recommend a max of 5 per cup for 15 hours.

2 green crack seeds in RO water. 4 Jack Herer in RO water.

2021.1.4 1300

Seeds have been soaking for 16 hours moving to napkin in Ziplock, black bag, and box. Placed on Ether Miner for heat.

2021.1.5

Checked the seeds no growth yet.

2021.1.6

Two green crack seeds have sprouted so I’m going to move these to root riot plugs.

The four Jack Herer seeds have not yet sprouted so I’m going to stick them back in a ziplock covered in a paper towel, black bag, and box.

2021.1.7

Jack Herer seeds still don’t seem to be germinating that quick. I’m going to leave them another day.

Also no sprouting in the humidity dome from the Green Crack plants.

One of the Green Crack plants popped through in the pm.

2021.1.8

So I probably let this Green Crack plant go for too long in the dark. I’m going to move it into the grow tent where it can get a ton of blue spectrum light. This will promote bushy growth vs. the red spectrum which will cause growth in length and is better for flowering.

I’m going to move all the Jack Herer seeds to the humidity dome with the exception of one which doesn’t appear to have popped open. One of them appears to have broke when I moved it. I feel like I may have left my paper towel too wet.

Here is the placement of the seeds in the humidity dome.

Humidity

You’re going to want a humid environment for your plants. I would recommend something like this.

2021.1.9

Lights

Any of these smaller lights will work for the seedling phase.

Powerful LED’s

You are eventually going to need something more powerful. This is what I use.

2021.1.10

Looks like all of the seedlings popped except one. Haven’t added any water since the original move from the plastic bag. Also the last Jack Herer seed is refusing to germinate. I left it in the bag but typically when it takes this long they’re duds.

2021.1.11

2021.1.12

Pretty sure that bottom left Jack Herer is shot. Plus the last seed doesn’t appear to be germinating.

2021.1.14

Looks like roots are starting to appear. I’ll probably move these to a hydroponic setup soon.

First nutrients

Now that these seedlings are getting a little older I’m going to add some Clonex nutrients. I’m going to mix up 1 gallon of water and 18mL of Clonex.

1.21.2021

So I definitely got lazy and waited too long to move these into my hydroponic box in my window seal. You can see some of the leaves are in bad shape.

I’m going to put these in my south facing window seal for light. I’m going to supplement it with a florescent light 18 hours on and 6 hours off.

Water and Nutrients

Here is my template for maintaing the hydroponic system. This one is just a single 5 gallon bucket that pumps the water onto the roots and it drains back down.

The main nutrients I use are made by General Hydroponics.

I also use a few additives in addition to these.

h2o2 also known as hydrogen peroxide. In hydroponic setups you’re apt to get some type of root rot or infection. I use h2o2 as a preventative along with Armor Si made by General Hydroponics.

You’ll want to use RO water with your setup. This way your water is pure. With that being said it’s important to add calcium and magnesium back into the water.

Flushing your water

Every 7-14 days you’ll want to completely drain and flush your water. What I’ll typically do is drain all the water. Replace it with tap water and this FloraKleen product. Let this run for 2-4 hours and then completely drain it.

1.27.2021

I haven’t done anything to the plants. I just let them grow with 18 hours of LED light and then the natural sunlight through the window.

1.29.2021

I wanted to post an update of what the roots look like at this point.

I also lost one of the plants and only had 4 growing. So I decided to germinate two more today. A Harlequin and a Blueberry plant. I tried twice to get a Harlequin to germinate and failed both times. So I’m just going to move this Blueberry over to the window seal hydroponic setup.

2.1.2021

The Blueberry is looking healthy after a few days.

2.11.2021

So I neglected these plants again. I haven’t added any nutrients since the initial move on 1.23.2021. It gives you an idea of how maintenance-free this setup is. You can also see a large amount of growth in a relatively short timeframe. The roots grew way too big to pull through the plastic containers so I lost a good portion of them while transplanting tonight. It will be interesting to see how they respond. You can see how they’re in their final spot which is the 5-gallon bucket until they flower and harvest. I had to leave two of them in the window seal due to a lack of room in the tent. Their roots are going to get way too big for this setup. I may let them flower early or move them to a dirt container.

Notice the Blueberry is the smallest one and is about 10 days old.

Tent

The plants are now in this tent.

Lighting

The LED light I’m using is this.

Exhaust Fan

You’ll also want a fan to keep the airflow and vent the plants. I use this one.

Timer

I use these timers to control the lights.

Humidity

You’ll also need a humidifier to keep your air humid.

The method I use are 5-gallon buckets in which one bucket is the control bucket. It’s empty and they all drain back into it. Then the water gets re-circulated using a pump to spray the roots.

2.25.2021

Here are the plants in their final home. In Arizona, you can grow up to 12 plants per household so long as there are two adults in the household.

3.5.2021

Updated status.

3.12.2021

Updated status.

3.17.2021

Lighting Schedule change

Today I’m switching the lights to be on 12 hours and off 12 hours. What this does is it signals to the plant it’s time to flower, or create buds. This will be the final phase of my grow in about 6-8 weeks the bud will be ready to harvest.

3.22.2021

I wanted to show what a male plant looks like. I had to take this one out of the grow tent. You don’t want males as they will pollinate the females and ruin the crop.

You can see how big this plant has gotten and it has developed quite a rooting system!

4.1.2021

4.13.21

Buds are starting to come to life. Just a few more weeks left of flowering.

Hacking your SRP time-of-use bill with a DIY Tesla Powerwall made from recycled scooter batteries

I’ve always been fascinated by technology. I love building all types of electronic projects and automating things. Recently I ran across a guy who discussed building a battery backup using recycled scooter batteries that contained 18650 rechargeable batteries. The same ones that you find in Tesla cars and Powerwalls.

I started thinking. I wonder if it would be possible to trickle charge a battery during low-cost energy hours (6PM-3PM) and then dump it back into the grid when the electricity was expensive(3PM-6PM). Or at least offset your peak hour usage with battery power. So I created some formulas and crunched some numbers. Before you read any further I want to say this is a complete hypothetical experiment. I would never connect this to my SRP system and risk them terminating my services.

Here is a list of SRP’s different electricity rates. You can see the greatest offset is in the months of May, June, July, August, September, and October. The variance in winter is not that great and you really can’t save that much using this method.

Ok, let’s compile a spreadsheet using these formulas.

ROI

Analyzing the ROI this setup using a simple 3kWh battery and a 1kW inverter we can yield 18.27% with a completely paid for system in 5.47 years. Not a bad return for someone with a little bit of money to invest.

Parts

So I started buying parts.

6 – Scooter batteries

1 – Inverter

1 – Charge/Discharge monitor

1 – Smart switch

1 – Battery Charger

1 – AC auto transfer switch

1 – Distribution block

1 – Arduino Nano

1 – Buck converter

Part 2

I’ll be assembling and testing over the next week. To be continued…

How to invest like a hedge fund manager with almost a 1,400% return in the last 14 years

A popular strategy that I have followed in my investments is crowdsourcing hedge fund manager investments. Many people don’t know this but any hedge fund that manages over $100 million dollars must report their stock holdings on a form called a 13f. This is filed with the SEC. There is a website that conveniently maps all of these filings so you can scan through your favorite investment manager and see what stocks they are buying and selling.

For instance, if you’re a fan of Warren Buffett and Charlie Munger you can take a look at Berkshire Hathaway’s holdings – https://whalewisdom.com/filer/berkshire-hathaway-inc Here is a list of their holdings which are over 1% of their portfolio

Or may be you’re a fan of Ray Dalio and you want to see what Bridgewater is holding? Here is a list of all their holdings that represent more than 1% of their portfolio.

Let’s take a look at Jim Simon’s fund Renaissance Technologies.

You get the point. You are able to get some pretty good insight as to what massive hedge funds are buying.

WhaleIndex

What I like about Whale Wisdom is they categorize the most successful hedge fund managers using what they refer to as a WhaleIndex.They then put together a list of 30 stocks based on successful fund managers. Some of their requirements are as follows.

  • Between 5 and 750 holdings in their 13F filing
  • At least 3 consecutive years of quarterly 13F filings
  • Hold no fewer than five stocks in its portfolio
  • Manage more than $100 million in marketable securities
  • Hold at least 20% of its portfolio in its top 20 stocks
  • Managers considered to be a bank, trust, pension, or insurance company are excluded

The top 40 managers who have maintained an average WhaleScore over the past 5-years higher than the five-year average WhaleScore of the S&P 500 is used in the WhaleIndex. Based on the holdings disclosed on their SEC filings, WhaleWisdom identifies the 100 stocks most commonly held among the respective managers’ 13F holdings.

The Whale Fund 2.0 is the one I follow. Since 2006 this strategy has yielded 1,345% – https://whalewisdom.com/whaleindex/portfolio_2_0

A few words of caution

13f filings come out 45 days after the quarter ends. This means the data is somewhat stale. It should also be noted that the fund could have purchased that stock at any time during the quarter. Meaning the data could be as old as 135 days. Secondly, funds are not required to report short positions or hedged positions. So you should not assume you know exactly what their portfolio consists of.

Broker

You’ll want to find a broker that allows for fractional investing if you don’t have enough money to buy full shares. Here are a couple for reference.

Firstrade – 4 free stocks with $100 deposit

Robinhood – Sign up link your bank account and get a free stock.

In Conclusion

Despite its downfalls, Whale Wisdom’s returns are still solid. While I wouldn’t recommend this strategy for your entire portfolio this is a good strategy to deploy a fixed percentage of your portfolio. There is also a book that written about this concept which you can find here – https://www.amazon.com/Invest-With-The-House-Hacking-ebook/dp/B01A3L1VEO and also an ETF that was created named VIP ETF

Getting St. Louis FRED Data in Google Colab for Python Analysis

At times when creating trading strategies using big data you need access to historical economic data. One of the best sources of data is the Economic Research branch of the St. Louis Federal Reserve or FRED. Today I’m going to show you how to pull that data into a dataframe so that you can analyze it using machine learning or AI.

The first step is to import Pandas datareader. What this piece of code does is it downloads all the data for Corporate AAA bond yields. Every dataset in FRED has a symobl. In this case it’s DAAA.

import pandas_datareader.data as web
import datetime

today = pd.to_datetime("today")
start = datetime.datetime(1900, 1, 1)
end = today

df_Corp_AAA_yield = web.DataReader(['DAAA'], 'fred', start, end)

# not working - Corp_AAA_yield = web.DataReader(['DAAA'], 'fred', start, end)
df_Corp_AAA_yield.head()
df_Corp_AAA_yield.tail()

We can now visualize our dataframe by plotting it.

df_Corp_AAA_yield.plot(grid=True)

Normalizing Stock data for Machine Learning

When analyzing historical time frame data in machine learning it needs to be normalized. In this code example I will show how to get S&P data then convert it to a percent of daily increase/decrease as well as a logarithmic daily increase/decrease.

Colab can be found here

The first part of this code will use yfinance as our datasource.

#we're going to use yfinance as our data source
!pip install yfinance --upgrade --no-cache-dir

import pandas as pd
import numpy as np
import yfinance as yf

Next we’re going to create a dataframe called df and download SPY data from 2000 to it. Finally we’ll print the result of df so you can get an idea of what is inside of it.

#Here we're creating a dataframe for spy data from 2000-current
df = yf.download('spy',
  start='2000-01-01',
  end='2020-08-21',
  progress=True)
  #dauto_adjust=True,
  #actions='inline',) #adjust for stock splits and dividends
#print the dataframe to see what lives in it
print(df)

We’re going to drop all the columns except Adj Close. Then we’ll rename it adj_close. Next we’ll create a column labeled simple_rtn. This is the daily simple return or percent increase/decrease. The next line of code creates a logarithmic increase/decrease. Logarithmic gives equal bearing to the Y axis and can be defined as follows, “A logarithmic price scale uses the percentage of change to plot data points, so, the scale prices are not positioned equidistantly. A linear price scale uses an equal value between price scales providing an equal distance between values.”

#only keep adj close
df = df.loc[:, ['Adj Close']]
df.rename(columns={'Adj Close':'adj_close'}, inplace=True)
#create column simple return
df['simple_rtn'] = df.adj_close.pct_change()
#create column logrithmic returns
df['log_rtn'] = np.log(df.adj_close/df.adj_close.shift(1))
print(df)

This next command just analyzes the data so you can spot check what you’ve created.

#here we can analyze our data
df.info()

This next section describes what the daily increase/decrease of the SPY looks like. You can see didn’t statistically relevant information about S&P here.

#get statistical data on the data frame
df.describe()

Next we can see a distribution of adjustable close, logarithmic return, and simple return.

#view chart of data to get an overview of what lives in the data
import matplotlib.pyplot as plt
df.hist(bins=50, figsize=(20,15))
plt.show()

This is all for data normalization. You can now apply different algorithmic analysis to the data.

Predict S&P Using Google Colab & Facebook Prophet

A few years ago Facebook decided to open source Prophet. This is their analytics algorithm that uses an additive model to fit non-linear data with seasonality. I started to wonder, “If this algorithm were in place in March when the stock market’s crashed what would it have advised?” So I decided to give it a spin.

Let’s assume you had a significant amount of money invested in S&P index funds on March 23, 2020. Since the beginning of the year, you would have lost 31% of your money. At this point you might be thinking, “Oh shit, what do I do, sell, buy, hold?”. A lot of investors would panic and sell. The market thrives and two psychologies, fear and greed.

But let’s take an analytics approach to this problem. What would Facebook’s Prophet algorithm advise you do to? Here is how you can approach that problem.

The first thing I did was fire up Google Colab. The entire notebook can be found here.

The first part of this code uses a Python DataReader to pull SPY from Yahoo Finance. I created an end date of 3/23/2020. This only gives Facebook’s Prophet access to data up until this point. We are then going to have it predict where it thinks the price would be today 8/20/2020 without feeding it any future data.

# Python
import pandas as pd
from fbprophet import Prophet

from pandas_datareader import data as web
import datetime

import pandas as pd
import matplotlib.pyplot as plt

stock = 'spy'
endDate = datetime.datetime(2020, 3, 23)
#start_date = (datetime.datetime.now() - datetime.timedelta(days=2000)).strftime("%m-%d-%Y")
start_date = (endDate - datetime.timedelta(days=2000)).strftime("%m-%d-%Y")
#print(start_date)
df = web.DataReader(stock, data_source='yahoo', start=start_date,end=endDate)
#date is the index so you need to make it a column
df["Date"] = df.index

import matplotlib.pyplot as plt

plt.plot(df['Close'])
df.head()
df.tail()

The next part of code renames the imported columns from “Date” to “ds” and “Close” to “y”. DS and Y are the two variables that Prophet will be looking for.

# Python
df = df.rename(columns={"Date": "ds", "Close": "y"}, errors="raise")

This next part of the code starts to set up Prophet. The only variable you should be concerned with is 151. This is telling the algorithm to look out 151 days. Then it forecasts three variables yhat, yhat_lower, and yhat_upper. Yhat is the predicted price with upper and lower being the bounds in which it assumes the price will fall in.

# Python
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=151)
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()

You can see that it predicts the closing price for tomorrow will be 331.52. Remember it is only using data from March 23rd to make this calculation. Given the wild gyrations in the market, this is extremely close to being accurate. The SPY closed today at 338. Prophet predicted it would close at 331. It was off by 2%. This is using a 5-month look ahead forecasting model.

Here is the visual representation of what that looks like.

from fbprophet.plot import plot_plotly, plot_components_plotly

plot_plotly(m, forecast)

And more charts…

plot_components_plotly(m, forecast)

Finally here is the visualization of the predicted price vs. the actual price chart.

Memory handler errors in MT4 while importing history files or csv files

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

If you have issues with Memory handler errors in MT4 it is because you’re trying to convert too many symbols at the same time. Close all of your charts and only leave open the pair you’re working with. When you’re done close it and go on to the next. This will get rid of the memory errors that MT4 complains about once terminal.exe starts to use more than 1GB of memory.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Monitor Account Balance and Send Email Alerts in Metatrader When Account Drops Below Threshold

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

I had a strategy that I programmed awhile ago that completely drained my account. The strategy itself was fine. In fact it was doing so good I decided to apply it from some of my currency pairs to XAU/USD. After applying I caught a flight to LAX to pick up a Porsche I had found online. I had never traded gold before but judging from the backtest it should have performed relatively well. The problem was I did not anticipate the large spread on gold. The spread was enough to send my strategy constantly opening and closing positions. The buy rules and sell rules were being met because of the huge spread. Once I landed I had picked up the Porsche and headed to my hotel, not realizing at the time I had left my briefcase and laptop in the back of the taxi that I caught at LAX. When I arrived at my hotel I checked my phone only to realize one of my accounts was down around 70%, only 30% of my capital remaining. I immediately freaked out and started my investigation. It was then I realized the large spread in gold was constantly opening and closing positions. Costing me the spread every 5 minutes or so. I called Oanda as I then realized I lost my laptop I could not shut off the robot. Closing the trades manually from my phone only made the account drain faster.

Now you see my reason for writing this code. The purpose of it is to grab your account balance at a specific time and then if it drops below a threshold to send an email notification. This code is in mqh format. Which is an include file. The reason for this is so that it can be applied to any expert advisor.


//+------------------------------------------------------------------+
//| DailyBalanceCheck.mq4 |
//| Copyright © 2011, Jeremy R. Whittaker |
//| http://www.JeremyWhittaker.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Jeremy R. Whittaker"
#property link "http://www.JeremyWhittaker.com"

double todaysBalance, dDouble;
int iHandle, iErrorCode;
extern string sFileName=”dailyBalance.csv”;
int iDecimalPlaces=2;
int sendWarningCount, sendBalanceCount;

void dailyBalanceCheck(){
int count;
double onePercent;

if(todaysBalance<1){
fnReadFile();
todaysBalance=dDouble;
}

if(Hour()==16 && Minute()==59){
count=0;
sendWarningCount=0;
sendBalanceCount=0;
}

if(Hour()==1700 && Minute()==0){
if(count==0){
todaysBalance=AccountBalance();
dDouble=todaysBalance;
fnWriteFile();
if(sendBalanceCount<1){
SendMail(“Account Update”,”Good evening Mr. Whittaker todays balance is “+todaysBalance+”. Your current account equity is “+AccountEquity());
Print(“Sending Balance Email”);
sendBalanceCount=sendBalanceCount+1;
}
count=count+1;
}
}

onePercent=todaysBalance*0.01;

if(AccountEquity() SendMail(“Warning account equity down 1%”,”Account Balance at 5PM was “+todaysBalance+”. Now it is “+AccountEquity());
Print(“Sending Warning Email”);
sendWarningCount=sendWarningCount+1;
}
return(false);
}

//+——————————————————————+
bool fnReadFile()
{
iHandle = FileOpen(sFileName,FILE_CSV|FILE_READ,’;’);
if(iHandle < 1)
{
iErrorCode = GetLastError();
if (iErrorCode == 4103)
Print(“File not found”);
else
Print(“Error reading file: “,iErrorCode);
return(false);
}
dDouble = StrToDouble(FileReadString(iHandle));
FileClose(iHandle);
return(true);
}

//+------------------------------------------------------------------+
bool fnWriteFile()
{
iHandle = FileOpen(sFileName,FILE_CSV|FILE_WRITE,';');
if(iHandle < 1)
{
iErrorCode = GetLastError();
Print("Error updating file: ",iErrorCode);
return(false);
}
FileWrite(iHandle,DoubleToStr(dDouble,iDecimalPlaces));
FileClose(iHandle);
return(true);
}
//+------------------------------------------------------------------+

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Whittaker hourly ATR indicator for Metatrader

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

How MT4 Calculates Spread and How to Manually Change it.

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

MT4 has a crude way of calculating the spread on each trade.  It basically takes the current market spread at the time you run your backtest and applies that to all of your trades.  Unfortunately, if someone is programming and testing on the weekends all of their results are going to be skewed because of the fact that the spreads on the weekend/after-hours are so high.  You can check the spread that your MT4 platform is going to use by clicking on the symbol properties button from within your tester.

If you want to statically set this variable for your backtest purposes you need to download spread changer.  It can be found here.  http://www.jeremywhittaker.com/wp-content/uploads/2011/04/SpreadChanger.exe

Using this utility is not exactly straightforward.  You need to find the file named Symbols.sel within your MT4 program files directory.  Once you find the Symbols.sel file drag and drop it onto the Spreadchanger.exe utility and it will allow you to modify it. 

The last step is you need to add a fake proxy server to your MT4 platform to trick it from accessing the internet.  Because if it can access the server it will over ride your setting.  You must also edit the symbols.sel file while your platform is closed.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Setting up Metatrader for better backtesting quality

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

If you’re working with a default installation of MT4 or Metatrader chances are you modeling quality is not very good. I have composed this post to show how I import data into MT4 for better backtesting performance.

First thing you need is high quality historical data in CSV format. I have found Forex Tester to be very beneficial for that, http://www.forextester.com/data/datasources.html.

1. You will want to download the file that pertains to the pair you will be trading.

2. The next step is unzipping the file using a simple Zip program.

3. Before proceeding to import your new data you will want to go ahead and delete all of your old data first. So that you are not mixing the two up. If you are running Windows7 or Windows Vista you have to look in two locations for the .hst files and delete all of them. If however you are running Windows XP you need to only look in one. These locations can vary greatly depending what broker you download your platform from. I use Interbank but you will have to look and mind and figure out where yours are. Or you can just search your entire hard drive for *.hst files.
C:\Program Files (x86)\Interbank FX Trader 4 – B\history
C:\Users\%username%\AppData\Local\VirtualStore\Program Files (x86)\Interbank FX Trader 4 – B\history\IBFX-MT4 Mini-2

4. Now that you have unzipped the files they should be in .CSV format. From here you can now open your Metatrader platform. Then go to tools>options click on the chart tab and change the “max bars in history” and “max bars in chart” to 999999999. Once you close this window Metatrader will adjust to the highest possible setting automatically.

5. You will now want to go to tools>history center. Double click your currency pair that you are trying to import. Then double click on the 1m timeframe underneath it. Now click on the import button. Browse to the location of the .txt file that you extracted in step 2. You may have to change the rows setting to 0. If it works correctly you will be able to see every row from the file that you are importing. Click ok and all of your 1m data is now complete.

6. The next step is to generate your 5m 10m 30m 60m 240m 1440m and 10080m data. This will get all of the commonly used timeframes. You can also do custom ones if you wish.

7. To do this you need to go to navigator from Metatrader terminal. Select the scripts from the navigator window and look for one named “period_converter”.

8. Open a 1m chart of the currency pair that you just imported.

9. Now double click on period_converter

10. It’s going to ask you for an input labeled “ExtPeriodMultiplier”. The default value is 3. Change this to 5 to generate your 5 minute chart data.

11. If you have your terminal window open in Metatrader select the experts tab. You will see something that says period_converter GBPUSDm,M1: 726279 record(s) written. This is how you know it is complete.

12. Double click period converter again. This time select 10 for 10 minute chart. Continue doing steps 10 and 11 until you have created your 5m 10m 30m 60m 240m 1440m and 10080m data. You are now ready to move on to your next currency pair.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Whittaker volatility breakout indicator

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

I wanted to share with everyone an indicator that I programmed and I find very useful. It is called the Whittaker Volatility Breakout Indicator or WVBI. The purpose of this indicator is to represent the range of a bar in percentage terms rather than in points. I think the flaw of most traders or programmers is they often write code and optimize it for pips of a given pair. This I truly believe is one of the core fundamental flaws of sustainability of a strategy. When people start programming static values. Whether it be in money management, entries, exits, or take profit levels.

What this indicator does is as follows:

  1. Takes the range(high-low) the last x bars.
  2. Averages the range of the last x bars.
  3. Displays as a histogram the percentage of change from the average.
  4. Takes an average of the percentage of change from the average.
  5. Allows you to set a horizontal line at your preference so you can see when the average is breaking out.

This indicator has 3 inputs:

  1. “ATRPeriod” which allows you to specify the amount of bars to average out for the Average True Range of that period
  2. “WVBIAverage” is a setting that allows you to specify the amount of bars to which will be the average of the percentage of the ATR.
  3. The last setting is pretty straightforward it is “TooFar”.  This simply will draw a horizontal line across the indicator so that you can visually see where the percentage is in comparison to other bars.  Its purpose is to simply put things in perspective.

All of this might seem confusing at first. However, I assure you this a very useful indicator for detecting volatility in a market.

You can see from this example of above the bar in question exceed it’s 14 day ATR by 203.95%.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Whittaker COT index variant a

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

If you are a currency trader it can be quite annoying when you cannot access volume data as you can in other markets. This can be instrumental to ones success if your strategy from another insrument outside of Forex requires some type of volume indicator. Although it is not perfect you can use the futures market COT or Commitment of Traders report to gauge this.

Since 2000 the COT reports are released weekly. However, you must keep in mind the reports are released on Friday but reflect data from Tuesday. As the reports are closed off on Tuesday but not published until 3 days later.

When it comes to the COT report there are a few different sections that are valuable:

Commercial: These are organizations that use the futures market to hedge their positions. They are not traders by nature. They only use futures to guarantee their profits for the future.
Non-Commercial: These are the speculators who trade the futures market for a living. They include hedge funds and other individuals who speculate the market and make the requirements that are set by the CFTC.
Reportable: Positions held above specific reporting levels set by the CFTC.
Non-Reportable: These are individuals or organizations who do not meet the minimum requirements set forth by the CFTC to be categorized.
Open Interest: The open interest is the amount of futures or options contracts which are not offset by another transaction.

The Whittaker COT Index Variant-A is an MT4 or MQL4 indicator. Basically what it will do is go through the data from the COT report and extract the above sections. It will then as a percentage let you know how many traders are long in each category.

To use this indicator you must visit the CFTC website and weekly download the updated report. Here is a link to the report that must be downloaded, http://www.cftc.gov/MarketReports/CommitmentsofTraders/HistoricalCompressed/index.htm

Use the image below to make sure you’re downloading the correct link. Save this file to C:\Program Files (x86)\Interbank FX Trader 4\experts\files. This path is obviously because I use InterbankFX. Depending on your broker this path may be different.

You first must unzip the file that you downloaded. You can do this with any “zip” software. Once you extract this file it must be converted to CSV format for MetaTrader to read it.You can do this by opening the file located at C:\Program Files (x86)\Interbank FX Trader 4\experts\files\annual.xls with Microsoft Excel. Once it is open in Excel go to file>save as. From the save as type window select CSV(Comma Delimited) (*.csv). You will want to name the file annual.xls.csv this by default is what Whitaker COT Index will be looking for.

The actual Whittaker COT Index variant-A can be downloaded here. Save the file to C:\Program Files (x86)\Interbank FX Trader 4\experts Once the file is downloaded simply add it to your chart.

Due to the fact that this is a stripped down version of my EA that I use to trade live it is programmed as an EA or expert advisor. I realize it should technically be an indicator and I will reprogram it when I get the opportunity. Also, if you are testing this out on the weekend it is not going to work. It only generates numbers “on tick”, so if the market is closed it is not going to do anything.

Update:
I have reprogrammed this EA as an indicator so that it does not have to be loaded as an EA. You can download the updated version here. Save to C:\Program Files (x86)\Interbank FX Trader 4\experts\indicators\

Update 2:

The original source file I created this from is here – http://www.cftc.gov/MarketReports/files/dea/history/dea_fut_xls_2011.zip

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Whittaker COT Index Variant-A

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

If you are a currency trader it can be quite annoying when you cannot access volume data as you can in other markets. This can be instrumental to ones success if your strategy from another insrument outside of Forex requires some type of volume indicator. Although it is not perfect you can use the futures market COT or Commitment of Traders report to gauge this.

Since 2000 the COT reports are released weekly. However, you must keep in mind the reports are released on Friday but reflect data from Tuesday. As the reports are closed off on Tuesday but not published until 3 days later.

When it comes to the COT report there are a few different sections that are valuable:

Commercial: These are organizations that use the futures market to hedge their positions. They are not traders by nature. They only use futures to guarantee their profits for the future.
Non-Commercial: These are the speculators who trade the futures market for a living. They include hedge funds and other individuals who speculate the market and make the requirements that are set by the CFTC.
Reportable: Positions held above specific reporting levels set by the CFTC.
Non-Reportable: These are individuals or organizations who do not meet the minimum requirements set forth by the CFTC to be categorized.
Open Interest: The open interest is the amount of futures or options contracts which are not offset by another transaction.

The Whittaker COT Index Variant-A is an MT4 indicator.  Basically what it will do is go through the data from the COT report and extract the above sections.  It will then as a percentage let you know how many traders are long in each category.

To use this indicator you must visit the CFTC website and weekly download the updated report.  Here is a link to the report that must be downloaded, http://www.cftc.gov/MarketReports/CommitmentsofTraders/HistoricalCompressed/index.htm

Use the image below to make sure you’re downloading the correct link.  Save this file to C:\Program Files (x86)\Interbank FX Trader 4\experts\files.

Once you download this file it must be converted to CSV format for MetaTrader to read it.  You can do this by opening the file located at C:\Program Files (x86)\Interbank FX Trader 4\experts\files\annual.xls with Microsoft Excel.  Once it is open in Excel go to file>save as.  From the save as type window select CSV(Comma Delimited) (*.csv).  You will want to name the file annual.xls.csv  this by default is what Whitaker COT Index will be looking for.

The actual Whittaker COT Index variant-A can be downloaded here. Save the file to C:\Program Files (x86)\Interbank FX Trader 4\experts  Once the file is downloaded simply add it to your chart.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Setting up MetaTrader for better backtesting quality

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

If you’re working with a default installation of MT4 or Metatrader chances are you modeling quality is not very good. I have composed this post to show how I import data into MT4 for better backtesting performance.

First thing you need is high quality historical data in CSV format. I have found Forex Tester to be very beneficial for that, http://www.forextester.com/data/datasources.html.

1. You will want to download the file that pertains to the pair you will be trading.

2. The next step is unzipping the file using a simple Zip program.

3. Before proceeding to import your new data you will want to go ahead and delete all of your old data first. So that you are not mixing the two up. If you are running Windows7 or Windows Vista you have to look in two locations for the .hst files and delete all of them. If however you are running Windows XP you need to only look in one. These locations can vary greatly depending what broker you download your platform from. I use Interbank but you will have to look and mind and figure out where yours are. Or you can just search your entire hard drive for *.hst files.
C:\Program Files (x86)\Interbank FX Trader 4 – B\history
C:\Users\%username%\AppData\Local\VirtualStore\Program Files (x86)\Interbank FX Trader 4 – B\history\IBFX-MT4 Mini-2

4. Now that you have unzipped the files they should be in .CSV format. From here you can now open your Metatrader platform. Then go to tools>options click on the chart tab and change the “max bars in history” and “max bars in chart” to 999999999. Once you close this window Metatrader will adjust to the highest possible setting automatically.

5. You will now want to go to tools>history center. Double click your currency pair that you are trying to import. Then double click on the 1m timeframe underneath it. Now click on the import button. Browse to the location of the .txt file that you extracted in step 2. You may have to change the rows setting to 0. If it works correctly you will be able to see every row from the file that you are importing. Click ok and all of your 1m data is now complete.

6. The next step is to generate your 5m 10m 30m 60m 240m 1440m and 10080m data. This will get all of the commonly used timeframes. You can also do custom ones if you wish.

7. To do this you need to go to navigator from Metatrader terminal. Select the scripts from the navigator window and look for one named “period_converter”.

8. Open a 1m chart of the currency pair that you just imported.

9. Now double click on period_converter

10. It’s going to ask you for an input labeled “ExtPeriodMultiplier”. The default value is 3. Change this to 5 to generate your 5 minute chart data.

11. If you have your terminal window open in Metatrader select the experts tab. You will see something that says period_converter GBPUSDm,M1: 726279 record(s) written. This is how you know it is complete.

12. Double click period converter again. This time select 10 for 10 minute chart. Continue doing steps 10 and 11 until you have created your 5m 10m 30m 60m 240m 1440m and 10080m data. You are now ready to move on to your next currency pair.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.

Whittaker Volatility Breakout Indicator

I no longer trade using Metatrader. I noticed users kept hitting an invalid link on my website to this search phrase. So the purpose of this post is to catch those invalid links related to Metatrader. I would recommend learning Python and custom developing your algorithms. It will be much more rewarding.

I wanted to share with everyone an indicator that I programmed and I find very useful. It is called the Whittaker Volatility Breakout Indicator or WVBI. The purpose of this indicator is to represent the range of a bar in percentage terms rather than in points. I think the flaw of most traders or programmers is they often write code and optimize it for pips of a given pair. This I truly believe is one of the core fundamental flaws of sustainability of a strategy. When people start programming static values. Whether it be in money management, entries, exits, or take profit levels.

Download WVBI!

What this indicator does is as follows:

  1. Takes the range(high-low) the last x bars.
  2. Averages the range of the last x bars.
  3. Displays as a histogram the percentage of change from the average.
  4. Takes an average of the percentage of change from the average.
  5. Allows you to set a horizontal line at your preference so you can see when the average is breaking out.

This indicator has 3 inputs:

  1. “ATRPeriod” which allows you to specify the amount of bars to average out for the Average True Range of that period
  2. “WVBIAverage” is a setting that allows you to specify the amount of bars to which will be the average of the percentage of the ATR.
  3. The last setting is pretty straightforward it is “TooFar”.  This simply will draw a horizontal line across the indicator so that you can visually see where the percentage is in comparison to other bars.  Its purpose is to simply put things in perspective.

All of this might seem confusing at first. However, I assure you this a very useful indicator for detecting volatility in a market.

Attached are zip files I had or that I was working on for Metatrader. I don’t know if they’re up to date, if they work, or support them in any form.