Overall Statistics
Total Trades
8918
Average Win
0.98%
Average Loss
-0.01%
Compounding Annual Return
-25.595%
Drawdown
25.700%
Expectancy
-0.683
Net Profit
-24.380%
Sharpe Ratio
-3.793
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
107.72
Alpha
-0.203
Beta
-0.039
Annual Standard Deviation
0.054
Annual Variance
0.003
Information Ratio
-1.367
Tracking Error
0.145
Treynor Ratio
5.261
Total Fees
$2628.40
namespace QuantConnect 
{   
    
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	public string pair1 = "EURUSD";
    	RollingWindow<double> window;
    	RollingWindow<double> diffWindow;
    	const int WL = 200;

		SimpleMovingAverage sm;
		StandardDeviation dev;
    	
        public override void Initialize() 
        {
        	SetStartDate(2015,01,01);
            SetEndDate(2015, 12, 12);         
            
            SetBrokerageModel(BrokerageName.FxcmBrokerage);
            //SetBrokerageModel(BrokerageName.OandaBrokerage);
            
            SetCash(10000);
            
            //Broken
            //AddForex(pair1, Resolution.Hour, Market.Oanda);
            //Uncomment for working FXCM data
            AddForex(pair1, Resolution.Hour, Market.FXCM, leverage:10.0M);
            Securities[pair1].SetLeverage(10.0M);
 
            sm = SMA(pair1,WL);
            dev = STD(pair1,WL);
            
            window = new RollingWindow<double>(WL);
            diffWindow = new RollingWindow<double>(WL);
           
        }

        
	    public void OnData(TradeBars data) {
	    	if(data[pair1].Close < 0.01M) return;
	    	SetHoldings(pair1, 1);
	    	
	    	if(data[pair1].Close > sm + dev)
	    		SetHoldings(pair1, 1);
	    	else if (data[pair1].Close < -(sm + dev))
	    		SetHoldings(pair1, -1);
	    	else SetHoldings(pair1,0);
	    	
	    	Log("dev: " + dev);
	    	Log("mean: " + sm);
			Log("current: " + data[pair1].Close);
			Console.WriteLine("current2: " + data[pair1].Close);
	    	
        }
        
	  
    }
}