Overall Statistics
Total Trades
11218
Average Win
0.07%
Average Loss
-0.07%
Compounding Annual Return
-36.110%
Drawdown
54.300%
Expectancy
-0.192
Net Profit
-54.153%
Sharpe Ratio
-7.01
Loss Rate
60%
Win Rate
40%
Profit-Loss Ratio
1.00
Alpha
-0.311
Beta
0.022
Annual Standard Deviation
0.044
Annual Variance
0.002
Information Ratio
-3.934
Tracking Error
0.1
Treynor Ratio
-14.229
Total Fees
$0.00
namespace QuantConnect 
{   
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	private  List<string>  tickers = new List<string>();
    	private Dictionary<string, BollingerBands> signalDict = new Dictionary<string, BollingerBands>();
    	private BollingerBands bands;
    	
    	public Resolution resolution = Resolution.Hour;
    	
        public override void Initialize() 
        {
			 tickers.Add("EURUSD");
        	// tickers.Add("GBPUSD");
        	// tickers.Add("USDJPY"); 
        	// tickers.Add("AUDUSD");
        	// tickers.Add("EURJPY"); 
        	// tickers.Add("USDCAD");
        	// tickers.Add("EURGBP"); 
        	// tickers.Add("USDCHF");
        	// tickers.Add("USDMXN"); 
        	// tickers.Add("NZDUSD"); 
        	// tickers.Add("EURCHF"); 
        	// tickers.Add("USDRUB"); 
        	// tickers.Add("USDZAR"); 
        	// tickers.Add("USDSGD"); 
        	// tickers.Add("USDTRY"); 
        	// tickers.Add("EURSEK"); 
        	// tickers.Add("GBPJPY"); 
        	// tickers.Add("EURAUD"); 
        	// tickers.Add("EURNOK"); 
        	// tickers.Add("USDINR"); 
        	// tickers.Add("USDPLN"); 
        	// tickers.Add("USDCNY");
        	
        	SetStartDate(2016, 1, 1);
        	SetCash(25000);
        	SetBrokerageModel(BrokerageName.OandaBrokerage, AccountType.Cash);
        	
        	foreach (String ticker in tickers){
            	AddForex(ticker, resolution, Market.Oanda);
            	signalDict[ticker] = BB(ticker, 20, 1, MovingAverageType.Simple);
            }
			
        }

        public void OnData(QuoteBars data) 
        {
			foreach(String fxPair in tickers){
				if(data.ContainsKey(fxPair) == false){
            		Log("not there");
            		break;
            	}
            	// Log("========");
            	// Log("Pre: " +Portfolio[fxPair].Quantity);
            	SetHoldings(fxPair, 0);
            	// Log("Post: " +Portfolio[fxPair].Quantity);
            	// Log("========");
            	
            	bands = signalDict[fxPair];
            	if (!bands.IsReady) break;
            	
            	decimal close = data[fxPair].Close;
            	decimal open = data[fxPair].Open;
            	
            	if(close > bands.UpperBand && (Portfolio[fxPair].Quantity == 0)){
            		SetHoldings(fxPair, 0.95m);
            	}
            	if(close < bands.LowerBand && (Portfolio[fxPair].Quantity == 0)){
            		SetHoldings(fxPair, -0.95m);
            	}
            	
			}
        }
    }
}