Error: I'm afraid this is the first I've heard of a "article;_CCNA" flavoured Blosxom. Try dropping the "/+article;_CCNA" bit from the end of the URL.

Tue, 19 Dec 2006

Volume At Price

It is said that, through the course of the day, trading trends will revert to the level of highest volume.

The software at Ensign Software has a feature which will chart a nice bar graph of the volume-at-price distribution for visual traders.

However, for a quick and dirty indicator at a single level only, fit for automated trading, I wrote the following small class:

public class VolumeAtPrice {
	
	SortedList slVolumeAtPrice;
	public int LargestVolume = 0;
	public double PriceAtLargestVolume = 0;
	
	public VolumeAtPrice() {
		slVolumeAtPrice = new SortedList( 400 );
	}
	
	public void Add( Trade trade ) {
		if ( slVolumeAtPrice.ContainsKey( trade.Price ) ) {
			int ix = slVolumeAtPrice.IndexOfKey( trade.Price );
			int volume = (int) slVolumeAtPrice.GetByIndex( ix );
			volume += trade.Size;
			slVolumeAtPrice.SetByIndex( ix, volume );
			if ( volume > LargestVolume ) {
				LargestVolume = volume;
				PriceAtLargestVolume = trade.Price;
			}
		}
		else {
			slVolumeAtPrice.Add( trade.Price, trade.Size );
			if ( trade.Size > LargestVolume ) {
				LargestVolume = trade.Size;
				PriceAtLargestVolume = trade.Price;
			}
		}
	}
}

After updating with the latest Trade, examine PriceAtLargestVolume to see where the current highest volume trading level occurs. #