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(2017,1, 1)  #Set Start Date
        self.SetEndDate(2017,2, 15)    #Set End Date
        self.SetCash(5000)           #Set Strategy Cash
        self.AddForex("EURGBP", Resolution.Hour, Market.Oanda)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage) 
    
        self.numATRs = 1.5;
        length = 5;
        
        self.atr = self.ATR("EURGBP", length, MovingAverageType.Simple, Resolution.Hour)
        self.AutomaticIndicatorWarmUp = True
        
        self.past_bar = None
        
    def OnData(self, data):
        if self.IsWarmingUp or not self.atr.IsReady or not data.ContainsKey('EURGBP'): 
            return
        bar = data['EURGBP']
        
        if self.past_bar is None:
            self.past_bar = bar
            return
        
        close = bar.Close
        low = self.past_bar.Low
        self.past_bar = bar
        
        condition = low <= close - self.atr.Current.Value * self.numATRs
        self.Log(str(condition))