Overall Statistics
using System;
using System.Collections.Generic;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

using QuantConnect.Orders.Fees;


using QuantConnect.Algorithm;
using QuantConnect;
using QuantConnect.Data.Consolidators;
using QuantConnect.Indicators;

namespace QuantConnect
{
	/// <summary>
	/// Basic template algorithm simply initializes the date range and cash
	/// </summary>
	public class OpenCloseCross : QCAlgorithm
	{
		//Configure which securities you'd like to use:
		public Symbol _eurusd;

		//Risk in dollars per trade ($ or the quote currency of the assets)
		public decimal RiskPerTrade = 50;

		//Sets the profit to loss ratio we want to hit before we exit
		public decimal TargetProfitLossRatio = 0.1m;

		private int _signalResolutionPeriod = 240;
		private int _tradeBarResolution = 5;

		//Global Consolidators

		//Symbol Specific Objects
		
		//EURUSD
		private TradeBarConsolidator _eurusdTradeBarConsolidator;
		private TradeBarConsolidator _eurusdSignalConsolidator;
		private RollingWindow<TradeBar> _eurusdSignalHistory;
		private RelativeStrengthIndex _eurusdRSI;

		//Risk in dollars per trade ($ or the quote currency of the assets)
		//public decimal RiskPerTrade = 50;

		//Sets the profit to loss ratio we want to hit before we exit
		//public decimal TargetProfitLossRatio = 0.1m;

		//Cap the investment maximum size ($).
		public decimal MaximumTradeSize = 10000;

		private Resolution _dataResolution = Resolution.Minute;
		

				
		private int _rsiPeriod = 14;

		public override void Initialize()
		{

			SetStartDate(2016, 02, 01);
			SetEndDate(DateTime.Now);
			SetCash(100000);


			//EURUSD
			_eurusd = QuantConnect.Symbol.Create("EURUSD", SecurityType.Forex, Market.Oanda);
			AddSecurity(SecurityType.Forex, _eurusd, _dataResolution);
			Securities[_eurusd].FeeModel = new ConstantFeeModel(0.04m);
			_eurusdSignalConsolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(_signalResolutionPeriod));
			_eurusdSignalConsolidator.DataConsolidated += _eurusdSignalConsolidator_DataConsolidated;
			_eurusdTradeBarConsolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(_tradeBarResolution));
			_eurusdTradeBarConsolidator.DataConsolidated += _eurusdTradeBarConsolidator_DataConsolidated;
			_eurusdRSI = new RelativeStrengthIndex(_rsiPeriod);

			SubscriptionManager.AddConsolidator(_eurusd, _eurusdSignalConsolidator);
			SubscriptionManager.AddConsolidator(_eurusd, _eurusdTradeBarConsolidator);
			_eurusdSignalHistory = new RollingWindow<TradeBar>(2);
			RegisterIndicator(_eurusd, _eurusdRSI, _eurusdTradeBarConsolidator, x => x.Value);



			SetWarmUp(200);
				
		}
			

		private void _eurusdTradeBarConsolidator_DataConsolidated(object sender, TradeBar data)
		{
			if (IsWarmingUp) return;
			// Exit Signal Logic
		}

		private void _eurusdSignalConsolidator_DataConsolidated(object sender, TradeBar data)
		{
			if (IsWarmingUp) return;
			Symbol symbol = data.Symbol;
			var timeSpan = data.EndTime.Subtract(data.Time);
			if (timeSpan.TotalMinutes != _signalResolutionPeriod)
			{
				Log("_eurusdSignalConsolidator_DataConsolidated Got Invalid Time Delta");
				return;
			}
			_eurusdSignalHistory.Add(data);
			if (_eurusdSignalHistory.IsReady)
			{
				//Entry Signal Processing Logic
			}
		}



	}
}