Overall Statistics
Total Trades
107
Average Win
0.53%
Average Loss
-0.56%
Compounding Annual Return
77.649%
Drawdown
2.600%
Expectancy
0.148
Net Profit
5.167%
Sharpe Ratio
3.659
Probabilistic Sharpe Ratio
76.458%
Loss Rate
42%
Win Rate
58%
Profit-Loss Ratio
0.96
Alpha
0.425
Beta
-0.459
Annual Standard Deviation
0.142
Annual Variance
0.02
Information Ratio
3.108
Tracking Error
0.235
Treynor Ratio
-1.134
Total Fees
$197.95
Estimated Strategy Capacity
$680000000.00
Lowest Capacity Asset
ES 1S1
# RSI and Unrealized Profit Percent Scalping

# ----------------------------------------
BAR = 5; RSI = 5; SL = 0.005; TP =  0.005;
# ----------------------------------------

class  UnrealizedProfitPercentScalping(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2015, 1, 1)
        self.SetEndDate(2015, 2, 1)
        self.SetCash(100000)  
        self.future = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute).Symbol
        self.rsi = self.RSI(self.future, 5, MovingAverageType.Simple, Resolution.Minute)
        consolidator = TradeBarConsolidator(timedelta(minutes = BAR))
        self.SubscriptionManager.AddConsolidator(self.future, consolidator)
        self.RegisterIndicator(self.future, self.rsi, consolidator)
        self.SetWarmUp(2*RSI, Resolution.Minute)
        self.enter_price = 0


    def OnData(self, data):
        if self.IsWarmingUp or not self.rsi.IsReady: return
    
        rsi = self.rsi.Current.Value
        price =  self.Securities[self.future].Price
        pnl = self.Securities[self.future].Holdings.UnrealizedProfitPercent
    
        if self.Time.hour >= 9 and self.Time.hour <= 14:
            if not self.Portfolio.Invested: 
                if self.rsi.Current.Value <= 10:
                    self.MarketOrder(self.future, 1)
                    self.enter_price = price
                    
                elif self.rsi.Current.Value >= 90:
                    self.MarketOrder(self.future, -1)
                    self.enter_price = price

            elif self.Portfolio.Invested:
                if self.enter_price > 0:
                    if pnl < - SL:
                        self.Liquidate(self.future, "Stop Loss")
                        self.enter_price = 0  
                        
                    elif pnl >= TP:
                        self.Liquidate(self.future, "Take Profit")
                        self.enter_price = 0