Overall Statistics
Total Trades
10
Average Win
1.41%
Average Loss
0%
Compounding Annual Return
9.049%
Drawdown
2.300%
Expectancy
0
Net Profit
7.226%
Sharpe Ratio
2.132
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.031
Beta
2.814
Annual Standard Deviation
0.041
Annual Variance
0.002
Information Ratio
1.646
Tracking Error
0.041
Treynor Ratio
0.031
Total Fees
$10.00
### Simple RSI Strategy intended to provide a minimal algorithm example copied from BackTest Rookies
### one indicator attempting to use ADX and DM+ DM-
### </summary>
class RSIAlgorithm(QCAlgorithm):

    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
        
        # Set our main strategy parameters
        self.SetStartDate(2018,1, 1)   # Set Start Date
        self.SetEndDate(2018,10,20)      # Set End Date
        self.SetCash(10000)            # Set Strategy Cash
        
        RSI_Period    = 14                # RSI Look back period 
        self.RSI_OB   = 60                # RSI Overbought level
        self.RSI_OS   = 40                # RSI Oversold level
        self.Allocate = 0.25              # Percentage of captital to allocate
        self.TH       = 29                # threshold line for ADX
        self.tcker    = "AAPL"
        
        
        # Find more symbols here: http://quantconnect.com/data
        self.AddEquity(self.tcker, Resolution.Daily)
        
        self.RSI_Ind = self.RSI(self.tcker, RSI_Period)
        self.ADX_Ind = self.ADX(self.tcker, 14, Resolution.Daily)
        
        
        # Ensure that the Indicator has enough data before trading,. 
        self.SetWarmUp(RSI_Period)
        
    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.

        Arguments:
            data: Slice object keyed by symbol containing the stock data
        '''
        self.diplus = self.ADX_Ind.PositiveDirectionalIndex.Current.Value
        self.diminus = self.ADX_Ind.NegativeDirectionalIndex.Current.Value
        self.adx = self.ADX_Ind.Current.Value
        self.close = data[self.tcker].Close
        self.high = data[self.tcker].High
        self.low = data[self.tcker].Low
        
        self.Debug("{} Close: {} ADX: {} DIPLUS: {} DIMINUS: {}".format(self.tcker, self.close, self.adx, self.diplus, self.diminus))
        # Check if we are in the market
        if not self.Portfolio.Invested:
            # If not, we check the RSI Indicator
            if self.RSI_Ind.Current.Value < self.RSI_OS: # and self.diplus > self.TH:
                # Buy Apple
                self.SetHoldings(self.tcker, self.Allocate)
                
        else:
            if self.RSI_Ind.Current.Value > self.RSI_OB: #and self.ADX_Ind.NegativeDirectionalIndex > self.TH:
                # Sell Apple 
                self.Liquidate(self.tcker)