Overall Statistics
Total Trades
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-5.744%
Drawdown
25.500%
Expectancy
0
Net Profit
-5.794%
Sharpe Ratio
-0.171
Probabilistic Sharpe Ratio
9.758%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.002
Beta
-0.144
Annual Standard Deviation
0.182
Annual Variance
0.033
Information Ratio
-0.601
Tracking Error
0.386
Treynor Ratio
0.215
Total Fees
$0.00
Estimated Strategy Capacity
$740000.00
class DeterminedRedOrangeAnt(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 12, 1)  # Set Start Date
        self.SetEndDate(2020, 12, 1)
        self.SetCash(100000)  # Set Strategy Cash
        #EURUSD", "USDJPY", "GBPUSD", "AUDUSD"
        
        self.Data = {}

        for ticker in ["GBPUSD", "EURUSD", "USDJPY", "AUDUSD"]:
            symbol = self.AddForex(ticker, Resolution.Hour, Market.FXCM).Symbol
            self.Data[symbol] = SymbolData(self, symbol)
            
        self.SetWarmUp(25, Resolution.Hour)


    def OnData(self, data):
        
        if self.IsWarmingUp:
            return
        
        for symbol, symbolData in self.Data.items():
            if not (data.ContainsKey(symbol) and data[symbol] is not None and symbolData.IsReady):
                continue
            
            ADX = symbolData.adx.Current.Value
            RSI = symbolData.rsi.Current.Value
            
            # Condition to begin if ADX value is greater than 25    
            if (not ADX > 25):
                  return
    
            if not self.Portfolio[symbol].Invested:
                current_price = data[symbol].Close
                
                lbbclose = symbolData.closeWindow[20] # self.closeWindow[20]
                lbsclose = symbolData.closeWindow[10] # self.closeWindow[10]
                
                if RSI < 50 and current_price < lbbclose and current_price > lbsclose:
                    self.SetHoldings(symbol, 1)
                    #self.Log(f"{self.Time} Entered Long Position at {current_price}")
                        
                if RSI > 50 and current_price > lbbclose and current_price < lbsclose:
                    self.SetHoldings(symbol, -1)
                    #self.Log(f"{self.Time} Entered Short Position at {current_price}")
                        
                    
class SymbolData:
    def __init__(self, algorithm, symbol):
        self.adx = algorithm.ADX(symbol, 14, Resolution.Hour)
        self.rsi = algorithm.RSI(symbol, 14, Resolution.Hour)
        
        self.adxWindow = RollingWindow[IndicatorDataPoint](2)   #setting the Rolling Window for the fast SMA indicator, takes two values
        self.adx.Updated += self.AdxUpdated                    #Updating those two values
        
        self.rsiWindow = RollingWindow[IndicatorDataPoint](2)   #setting the Rolling Window for the slow SMA indicator, takes two values
        self.rsi.Updated += self.RsiUpdated                    #Updating those two values
        
        self.closeWindow = RollingWindow[float](21)
        
        # Add consolidator to track rolling close prices
        self.consolidator = QuoteBarConsolidator(1)
        self.consolidator.DataConsolidated += self.CloseUpdated
        algorithm.SubscriptionManager.AddConsolidator(symbol, self.consolidator)
        

    def AdxUpdated(self, sender, updated):
        '''Event holder to update the fast SMA Rolling Window values'''
        if self.adx.IsReady:
            self.adxWindow.Add(updated)

    def RsiUpdated(self, sender, updated):
        '''Event holder to update the slow SMA Rolling Window values'''
        if self.rsi.IsReady:
            self.rsiWindow.Add(updated)
            
            
    def CloseUpdated(self, sender, bar):
        '''Event holder to update the close Rolling Window values'''
        self.closeWindow.Add(bar.Close)
       
    @property 
    def IsReady(self):
        return self.adx.IsReady and self.rsi.IsReady and self.closeWindow.IsReady