Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
namespace QuantConnect.Algorithm.CSharp
{ 
    public class PastClose : QCAlgorithm
    {
    	private Symbol _spy;
        private RollingWindow<PSarState> _psarWindow;
        private ParabolicStopAndReverse _psar;
        
        public override void Initialize()
        {
            SetStartDate(2016, 01, 01);  //Set Start Date
            SetEndDate(2016, 12, 31);    //Set End Date
            SetCash(100000);             //Set Strategy Cash

            var equity = AddEquity("SPY", Resolution.Daily);
            _spy = equity.Symbol;
            _psar = PSAR(_spy, afStart: 0.002m, afIncrement: 0.002m, afMax: 0.20m);
            _psarWindow = new RollingWindow<PSarState>(2);
        }

        public void OnData(TradeBars data)
        {
        	_psarWindow.Add(new PSarState(_psar));
        	if(!_psarWindow.IsReady) return;
        	
        	Plot("PSAR", "0", _psarWindow[0].Value);
        	Plot("PSAR", "1", _psarWindow[1].Value);
        }
    }
    
    // class to hold the current state of a Parabolic Stop And Reverse instance
    public class PSarState
    {
    	public decimal Value;
        public PSarState(ParabolicStopAndReverse psar)
        {
            Value = psar.Current.Value;
        }
    }
}