Hi Abhi,
I'll try to explain the basic thinking behind the algorithm.
This algorithm was a basic experiment in "surfing" market sentiment. This means I was trying to detect breaks from normal market activity, and then "ride the wave" of changing price.
To try and detect normal market activity for a period, I used the vwap and standard deviation.
The vwap (volume weighted average price) represents the average price of the market over the given time period, weighted by the volume of trades people are making.
The standard deviation is a measure for a period of time of how spread out numbers are around the average (there's a good explanation here - http://www.mathsisfun.com/data/standard-deviation.html).
The basic assumption behind this algorithm is that when price remains within the range around the average given by the standard deviation, it is considered to be normal trading (and so not doing anything particularly interesting). Therefore, it assumes that when the price for the given asset "breaks" out of this normal trading range, that there is a change in normal market activity indicating either an upward or downward movement.
Upon a larger than normal (from the given date range) upward movement, this algorithm makes a buy order in order to ride the upward market sentiment. As prices tend to have a habit of changing by the value of the range they are breaking from, I conservatively set the algorithm to take it's profit upon an upward movement of half the standard deviation (0.5).
The problem with this system is that there can be false triggers, either when the market is still overall ranging but just about manages to break the historical range, or sometimes when a market is about to have a major move to the downside it will move up first (not sure why).
In order to reduce false triggers I set the if statement to only make a buy order after the range had been broken by 1 standard deviation + 0.1 (where it had broken the range, and then some extra). I accidentally in the first iteration above used half a standard deviation + 0.1 for this (0.6), but got away with it as I had set the standard deviation to more days than the average (the more days in the standard deviation, the larger it's likely potential size). The standard deviation had initially been set to more days than the average to make it slightly larger, and so make the algorithm less sensitive.
Knowing that this wasn't a 100% accurate way to detect continuing upward price movement, I also ensured to implement a stoploss to cut my losses when the algorithm was wrong, although being careful to not set it so close that it could be accidentally triggered.
Overall it seems the algorithm in more volatile (and numerically large) stocks seems to get it's assumptions of upward movement right more often than it get's them wrong (and so produces a profit in the backtested data).
Hopefully that explanation helps, and having just realised it's 4:30 am I think I'll call it a night :P