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
Probabilistic 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
from collections import *

class MulitTimeFrameCharts(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 1, 3)    #Set Start Date
        self.SetEndDate(2019, 1, 4)      #Set End Date
        self.SetCash(10000)             #Set Strategy Cash
        
        self.forexPair = "EURUSD"
        self.AddForex(self.forexPair, Resolution.Minute, Market.Oanda)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage);
        
    
        self.Consolidate(self.forexPair,timedelta(minutes=5),self.fiveMinutesBarHandler)
        self.Consolidate(self.forexPair, timedelta(minutes=60),self.sixtyMinutesBarHandler)
      
       
        self.BarHistoryWindow = 5 
        #Set up EMA indicators for lookback periods 21, 13 and 8 for both five minutes and 60 minutes time frames
        self.longLookBackPeriod = 21
        self.mediumLookBackPeriod = 13
        self.shortLookBackPeriod = 8
        
        self.percentageOfPortfolioRiskedPerTrade = 0.005
        
        self.emaFiveMinsLong = ExponentialMovingAverage(self.longLookBackPeriod)
        self.RegisterIndicator(self.forexPair, self.emaFiveMinsLong ,timedelta(minutes=5))
        self.emaFiveMinsMedium = ExponentialMovingAverage(self.mediumLookBackPeriod)
        self.RegisterIndicator(self.forexPair, self.emaFiveMinsMedium ,timedelta(minutes=5))
        self.emaFiveMinsShort = ExponentialMovingAverage(self.shortLookBackPeriod)
        self.RegisterIndicator(self.forexPair, self.emaFiveMinsShort ,timedelta(minutes=5))
        
        self.emaSixtyMinsLong = ExponentialMovingAverage(self.longLookBackPeriod)
        self.RegisterIndicator(self.forexPair, self.emaSixtyMinsLong ,timedelta(minutes=60))
        self.emaSixtyMinsShort = ExponentialMovingAverage(self.shortLookBackPeriod)
        self.RegisterIndicator(self.forexPair, self.emaSixtyMinsShort ,timedelta(minutes=60))
        
    def fiveMinutesBarHandler(self,consolidated):
        self.Plot("5m","5mEMA21",self.emaFiveMinsLong.Current.Value)
        self.Plot("5m","5mEMA13", self.emaFiveMinsMedium.Current.Value)
        self.Plot("5m","5mEMA8", self.emaFiveMinsShort.Current.Value)
        self.Plot("5m","EURUSD", consolidated.Close)
    
    def sixtyMinutesBarHandler(self,consolidated):
        
        self.Plot("60m","EMA21",self.emaSixtyMinsLong.Current.Value)
        self.Plot("60m","EMA8", self.emaSixtyMinsShort.Current.Value)
        self.Plot("60m","EURUSD", consolidated.Close)