Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
import numpy as np

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        # Set the cash we'd like to use for our backtest
        # This is ignored in live trading 
        self.SetCash(5000)
        
        # Start and end dates for the backtest.
        # These are ignored in live trading.
        self.SetStartDate(2017,1,1)
        self.SetEndDate(2017,6,1)
        
        # Add assets you'd like to see
        self.AddForex("EURUSD", Resolution.Minute), 
        self.AddForex("GBPUSD", Resolution.Minute),
        self.AddForex("EURGBP", Resolution.Minute)
        
        self.slow = self.EMA('EURUSD', 6, Resolution.Daily)
        self.fast = self.EMA('EURUSD', 15, Resolution.Daily)
        
        stockPlot = Chart('Trade Plot')
        # On the Trade Plotter Chart we want 3 series: trades and price:
        stockPlot.AddSeries(Series('Slow', SeriesType.Line, 0))
        stockPlot.AddSeries(Series('Fast', SeriesType.Line, 0))
        self.AddChart(stockPlot)
        

    def OnData(self, data):
        self.Plot('Trade Plot', 'Slow', self.slow.Current.Value)
        self.Plot('Trade Plot', 'Fast', self.fast.Current.Value)
        
        holdings = self.Portfolio["EURUSD"].Quantity 
        
        if holdings <= 0:
            if self.fast.Current.Value > self.slow.Current.Value:
                # The Securities property is a dictionary of Security objects. 
                # Each asset (equity, forex pair etc) in your algorithm has a security object. 
                # All the models for a security live on these objects: e.g. Securities["IBM"].
                # FeeModel or Securities["IBM"].Price.
                # Portfolio is a dictionary of SecurityHolding classes. 
                # These classes track the individual portfolio items profit and 
                # losses, fees and quantity held. e.g. Portfolio["IBM"].LastTradeProfit.
                self.Log("BUY  >> {0}".format(self.Securities["EURUSD"].Price))
                self.SetHoldings("SPY", 1.0)