I haven’t explained much about what my program is actually doing (or attempting to do, rather), so I think now would be a good time to do so, if only for posterity.
I’m by no means an expert programmer or stock trader; my highest hopes right now is for this to generate me some extra side money, I’d be happy with $100-200 a month. To that end, this is not a day-trading or long term program, I think it fits neatly in the swing trading realm; buy a stock under ideal conditions, sell a few days or couple weeks later, under ideal conditions. As best I can, I’m programming in some functions to determine basic ideal conditions, such as RSI being below 30 or above 70, daily price crossing 50-day EMA, etc.
Right now, it does straight buying and selling if certain conditions are met. Some of the conditions are simple, but as I continue working on the code, it’s getting more and more complex, such as: “If today’s price is lower than yesteday’s, AND the price is above the EMA, AND the SMA isn’t lower than the price”, etc., and this is starting to become problematic. Certain conditions have to be programmed in a certain order, otherwise they don’t work. There are also other elements I’m working on that will eventually factor into the trading decision, such as a 5 day price difference average, monthly, yearly, etc. (all weighted, of course).
So there’s a lot of moving parts to this, obviously, which is getting difficult to manage. I’ve recently come to the conclusion that I’ll have to rewrite some of the code to take more of a “score card” approach to the workflow, where instead of events being triggered when a combination of conditions are met, all conditions are evaluated and scored (added up), and then take a decision based on the final score. This will allow me to do two things: 1) make it easier to add in other criteria and conditions to test for and 2) it may also let me vary the trade itself. Right now it’s an all or nothing trade, where it spends all available money on a buy, and dumps all available shares on a sell. By using a score, it might be interesting to see what happens if I can tell it to only spend a certain percentage of available money, or do hold on to a certain amount of shares, etc. It will also allow me to more easily integrate shorting, which is still much further down the road.
Also when I say trading, it’s only trading one given stock at a time; it trades from the earliest price I have available (up to 20 years ago) until the current day and spits out the results, for each individual stock (over 21,000, comprised of AMEX, NASDAQ, NYSE and OTCBB). Once I retool the code to include the coding system, I’ll move on to what I WAS going to move on to sooner, adding code for the server to run through all the stocks on its own (right now it only analyzes what I manually ask it to). It’s a huge undertaking but it’s really the only way to compare stocks to each other. One thing being done to reduce the workload is neglecting any stocks that don’t have activity in the past 5 trading days, stocks with pricing below $0.001, and stocks with an average daily volume of less than 1,000; there’s also a variable where it ignores stocks that cost more than whatever the current portfolio value is, because if I can’t afford it, it’s not worth bothering with it.
One interesting thing I’m working on at the moment is my own “indexes”, which will help me do a broad comparison between both individual stocks and their respective markets. I have one index each for the markets (AMEX, NYSE, etc.), and then 15 indexes for sectors (industrial, financial, materials, etc.). I may add more niche indexes like market/sector combos (AMEX Industrials, NYSE Health Care, etc.), first I want to see how well these work out and whether it even needs to be broken down that much (AMEX/NYSE Industrials may all be the close enough to each other, but NASDAQ Tech and OTC Tech may be wildly disproportionate).
Lots of interesting ways to go still. I’m hoping to have something “useable” in the first or second week of September, we’ll see what happens.Tags: programming, project, stock market