Overall Statistics
Total Trades
59
Average Win
2.30%
Average Loss
-0.91%
Compounding Annual Return
-2.682%
Drawdown
17.700%
Expectancy
-0.513
Net Profit
-7.837%
Sharpe Ratio
-0.239
Probabilistic Sharpe Ratio
0.825%
Loss Rate
86%
Win Rate
14%
Profit-Loss Ratio
2.53
Alpha
-0.017
Beta
-0.011
Annual Standard Deviation
0.078
Annual Variance
0.006
Information Ratio
-0.687
Tracking Error
0.221
Treynor Ratio
1.638
Total Fees
$0.00
class OptimizedCalibratedAutosequencers(QCAlgorithm):

    def Initialize(self):
        
        ticker = 'GBPUSD'
        
        self.SetStartDate(2018, 1, 1)
        self.SetEndDate(2021,1,1) 
        self.SetCash(100000)  
        self.AddForex(ticker, Resolution.Daily)
        
        
                                # INDICATOR CODE #
        ########################################################################
        
        res = Resolution.Daily
        
        self.fast = self.SMA(ticker, 50, res)
        self.slow = self.SMA(ticker, 200, res)
        self.true_range = self.ATR(ticker, 14, res)
        
    def OnData(self, data):
        
        ticker = 'GBPUSD'
        
        position_price = self.Portfolio[ticker].AveragePrice
        price = float(self.Securities[ticker].Price)
        fast_cv = self.fast.Current.Value
        slow_cv = self.slow.Current.Value
        atr = self.true_range.Current.Value
        
        
        
                                # EXECUTION CODE #
        ########################################################################
        
        #BUY CODE
        if self.Portfolio[ticker].Quantity == 0: 
            if fast_cv > slow_cv: 
                self.SetHoldings(ticker , 1.0)
                
        if self.Portfolio[ticker].Quantity > 0:
            if price < position_price - 3*atr:                  # if short and price goes above (price when opened trade + 3*ATR )
                self.Liquidate()                                #      or if (fast SMA crosses above slow SMA)
            elif fast_cv < slow_cv:                             # CLOSE TRADE
                self.Liquidate()
        
        ########################################################################     
                
        #SELL CODE       
        if self.Portfolio[ticker].Quantity == 0:
            if fast_cv < slow_cv: 
                self.SetHoldings(ticker , -1.0)
         
               
        if self.Portfolio[ticker].Quantity < 0:                 # if short and price goes above (price when opened trade + 3*ATR )
            if price > position_price + 3*atr:                  #     or if (fast SMA crosses above slow SMA)
                self.Liquidate()                                # CLOSE TRADE
            elif fast_cv > slow_cv:
                self.Liquidate()
                
                
                
                
                # need to fix this code to get a higher win rate