VolumePlus.cs // Copyright (C) 2002-2005 Competo Solutions, Inc.
// All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.

using System;

using Trader.Data;

namespace Trader.Study
{
        /// <summary>
        /// Represents a SMA over volume.
        /// </summary>
        public class VolumePlus : Indicator
        {
                private SMA sma;
                private int period;

                /// <summary>
                /// ctor.
                /// </summary>
                public VolumePlus() : base("Volume+") {
                        this.period = 5;
                        base.Position = ChartPosition.Volume;
                        this.sma = new SMA(5);
                        this.NeedQuotes = true;
                }

                /// <summary>
                /// Gets or sets the period.
                /// </summary>
                [IndicatorParameter]
                public int Period {
                        get {
                                return this.period;
                        }
                        set {
                                this.period = value;
                                this.sma.Period = value;
                        }
                }

                /// <summary>
                /// Calculates the SMA of volume at index.
                /// </summary>
                /// <param name="index"></param>
                /// <param name="series"></param>
                public override double Calculate(int index, Quotes quotes) {
                        return this.sma.Calculate(index, quotes.Volumes);
                }

        }
}