Overall Statistics Total Trades195Average Win11.67%Average Loss-3.44%Compounding Annual Return20.366%Drawdown47.500%Expectancy0.360Net Profit140.245%Sharpe Ratio0.57Loss Rate69%Win Rate31%Profit-Loss Ratio3.40Alpha0.333Beta-6.548Annual Standard Deviation0.4Annual Variance0.16Information Ratio0.53Tracking Error0.4Treynor Ratio-0.035Total Fees\$0.00
```import numpy as np
from datetime import datetime
import decimal

### <summary>
### Basic EMA algorithm simply buys above EMA and sells below EMA.
### </summary>
class BasicEMAAlgorithm(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''

def Initialize(self):
'''Initializes cash and max trade size. Sets target currencies to run on.'''

self.SetStartDate(2013,10, 7)  #Set Start Date
#self.SetEndDate(2016,6,11)    #Set End Date

self.SetCash(1000)           #Set Strategy Cash

self.SetBrokerageModel(BrokerageName.OandaBrokerage)

self.ema = {}

self.currenciesToUse = {"AUDUSD"}

for cur in self.currenciesToUse:
self.ema[cur] = self.EMA(cur, 30, Resolution.Daily)

self.__previous = datetime.min

def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.

Arguments:
data: Slice object keyed by symbol containing the stock data
'''
# only once per day
if self.__previous.date() == self.Time.date():
return

self.__previous = self.Time

# Grab our universe, is there an easier way?
#for universe in self.UniverseManager.Values:
#    self.Debug(self.UniverseManager.Values)
#    if universe is UserDefinedUniverse:
#        break
self.Debug(self.UniverseManager.Keys[0])

symbols = self.UniverseManager["QC-UNIVERSE-USERDEFINED-OANDA-FOREX 8G"].Members.Keys

for symbol in symbols:

self.symStr = str(symbol)

holdings = self.Portfolio[self.symStr].Quantity

if holdings == 0:

# initiate new position

# Price above EMA, so buy

# Price below EMA, so sell