Overall Statistics
Total Trades
566
Average Win
2.27%
Average Loss
-1.21%
Compounding Annual Return
3.790%
Drawdown
30.500%
Expectancy
0.138
Net Profit
50.608%
Sharpe Ratio
0.32
Loss Rate
60%
Win Rate
40%
Profit-Loss Ratio
1.88
Alpha
0.037
Beta
0.012
Annual Standard Deviation
0.117
Annual Variance
0.014
Information Ratio
-0.165
Tracking Error
0.212
Treynor Ratio
2.994
Total Fees
$1647.62
import numpy as np
class RSIUSDTRY(QCAlgorithm):
    '''Basic template algorithm simply initializes the date range and cash'''

    def Initialize(self):
        self.SetBenchmark("SPY")
        self.SetStartDate(2008,1, 1)  #Set Start Date
        self.SetEndDate(2019,1,1)    #Set End Date
        self.SetCash(50000)           #Set Strategy Cash
        self.AddEquity("GLD", Resolution.Hour)
  
        self.rsi = self.RSI("GLD", 7)

    def OnData(self, data):
        
        if not self.rsi.IsReady: 
            return
    
        if self.rsi.Current.Value < 30:
            self.Liquidate("GLD")
        
        if self.rsi.Current.Value > 70:
            self.SetHoldings("GLD",1.0)