Moved to Wordpress

This blog has moved to Wordpress. GOTO the new blog now.

There will be no new updates here. Most of the posts have also been expanded.

2011/02/20

Moving to Wordpress!

I've been migrating my content over to a Wordpress blog over the last few weeks. I could have automated the task but I wanted to make sure that switching was a good option, so I did it all by hand.

Overall I'm impressed with Wordpress and I will definitely be switching. However there are some nice things that one gives up by switching to a Wordpress hosted Wordpress blog, like Google Analytics or anything else that requires Javascript.

Living without Javascript kind of sucks, but as a whole Wordpress seems to be a better platform for managing my blog content. On the bright side I've read of success installing Wordpress on a Sourceforge account as well, so that may be an option to take back some control.

Go to the new blog.

2011/01/29

What In The Hell Are Functions

Functions go by many names depending largely upon the programming language you use. You may hear them referred to as subroutines, procedures, methods, routines and probably more. There are many names to describe functions, but in the end they all boil down to just about the same thing. A function is a method of grouping a set of instructions to preform a certain task.

The simplest way to explain this concept is with an example. Suppose you wanted a program that displays the procedure for getting the area of a circle. First let’s explore the most straightforward way to achieve this.



When you run this program it will output:

The formula for the area of a circle is Pi*r2
The radius of the circle is: 5
The area of the circle is: 78.5

OK. We’re done. But wait, what if you want to show the area of more than one circle? Three circles you say? Ok that’s easy, just cut and paste the code above three times and we get the following program.




Which will print out:

The formula for the area of a circle is Pi*r2
The radius of the circle is: 5
The area of the circle is: 78.5

The formula for the area of a circle is Pi*r2
The radius of the circle is: 10
The area of the circle is: 314.0

The formula for the area of a circle is Pi*r2
The radius of the circle is: 10
The area of the circle is: 314.0


That wasn’t too bad. But what about 1,000 circles? That certainly is a lot of copying and pasting. Fortunately for us there is a better way. It is called a function.

If you look at the code that we copied and pasted above you’ll notice a lot of similarities. We’ll use these similarities to create a function called circleRadius to print this information for us. Our new program now looks like this:




And the output is exactly the same as last time:

The formula for the area of a circle is Pi*r2
The radius of the circle is: 5
The area of the circle is: 78.5

The formula for the area of a circle is Pi*r2
The radius of the circle is: 10
The area of the circle is: 314.0

The formula for the area of a circle is Pi*r2
The radius of the circle is: 15
The area of the circle is: 706.5


The code using the function is a lot shorter than the code we copied and pasted. It is also a little more clear than the previous version. However the real benefit comes when we want to make a change to how the information is displayed. Suppose that you just wanted to print the radius and the area, like this:

radius = 5
area = 78.5

It would take you quite a lot of work to change all those copy/paste versions to make this work. But with a function you only have to change it in one place and it will work all over. Our new version looks like this:




And the output is:

radius = 5
area = 78.5

radius = 10
area = 314.0

radius = 15
area = 706.5


Notice how the “circleRadius(x)” has not changed? The power of functions extends well beyond this small example, but this should get you started writing smaller, modifiable and reusable code.



Check back for articles that cover some of the more advanced features of functions, including recursion, nesting and closures.

2011/01/27

pyTrade Screenshots (Pre-Alpha)

pyTrade is a stock charting program and portfolio management tool.

pyTrade provides a "Paper Trading Mode" to allow you to learn how to trade, or test new strategies. The paper trading mode sends you back in time and lets you buy or sell stocks.

pyTrade is currently pre-alpha software so expect bugs and changes.

Here's a preview of the pre-alpha release. You can download pyTrade now and play with it, but remember, it is not ready yet. There will be bugs and features that aren't implemented yet.


Chart Styles

Candlestick Charts


Zoom Charts In and Out


OHLC + HLC Charts


Bar Charts


Dot Charts


Line Charts


Indicators

Simple Moving Averages


Set Your Own Colors


Multiple Indicators
Weighted Moving Average


Donchian Channels


Bollinger Bands


Tabbed Chart Viewing
Symbol entry in top left corner launches new tabs.


Persistent Indicators
Indicators stay on when changing charts.