Overall Statistics
import numpy as np

### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class BasicTemplateAlgorithm(QCAlgorithm):
    '''Basic template algorithm simply initializes the date range and cash'''

    def Initialize(self):
        self.SetStartDate(2015,1, 1)  #Set Start Date
        self.SetEndDate(2017,12,31)    #Set End Date
        self.SetCash(1000)           #Set Strategy Cash
        self.AddForex("EURUSD", Resolution.Daily, Market.Oanda)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage)
        self.sma_20 = self.SMA("EURUSD", 20, Resolution.Daily)
        self.sma_50 = self.SMA("EURUSD", 50, Resolution.Daily)
        self.SetWarmUp(50)
        
    def OnData(self, data):
        if self.Portfolio["EURUSD"].Invested==False and self.sma_20.Current.Value > self.sma_50.Current.Value:
            self.MarketOrder("EURUSD", 1000)
            
        if self.sma_50.Current.Value > self.sma_20.Current.Value:
            self.Liquidate()