Overall Statistics
namespace QuantConnect 
{   
    /*
    *   Basic Template Algorithm
    *
    *   The underlying QCAlgorithm class has many methods which enable you to use QuantConnect.
    *   We have explained some of these here, but the full base class can be found at:
    *   https://github.com/QuantConnect/Lean/tree/master/Algorithm
    */
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	private Security _eurusd;
    	
    
    	private RelativeStrengthIndex _rsi14;
    	
        public override void Initialize() 
        {
        	SetBrokerageModel(BrokerageName.OandaBrokerage);
        	
        	// backtest parameters
            SetStartDate(2016, 1, 1);         
            SetEndDate(DateTime.Now);
            
            // cash allocation
            SetCash(10000);
            
            // request specific equities
            // including forex. Options and futures in beta.
            _eurusd = AddCfd("EURUSD", Resolution.Minute, Market.Oanda);
           
            
         
            _rsi14 = RSI(_eurusd.Symbol, 14);
        }

        /* 
        *	New data arrives here.
        *	The "Slice" data represents a slice of time, it has all the data you need for a moment.	
        */ 
        public override void OnData(Slice data) 
        {
        	// slice has lots of useful information
        	TradeBars bars = data.Bars;
        	Splits splits = data.Splits;
        	Dividends dividends = data.Dividends;
        	
        	if (_eurusd.Holdings.HoldStock)
        	{
        		ExitLogic();
        	}
        	else
        	{
        		EntryLogic();
        	}
        }
        
   
        
        private void ExitLogic()
        {
        	if (_rsi14 == 50)
        	{
        		Liquidate(_eurusd.Symbol);
        	}
        }
        
        private void EntryLogic()
        {
        
        
        		if (_rsi14 > 70)
        		{
        			SetHoldings(_eurusd.Symbol, 1);
        		}
   
     
        		if (_rsi14 < 30)
        		{
        			SetHoldings(_eurusd.Symbol, -1);
        		}
        	
        }
    }
}