Overall Statistics
Total Trades
26
Average Win
0.01%
Average Loss
-0.01%
Compounding Annual Return
-21.553%
Drawdown
0.200%
Expectancy
-0.916
Net Profit
-0.199%
Sharpe Ratio
-20.351
Probabilistic Sharpe Ratio
0%
Loss Rate
96%
Win Rate
4%
Profit-Loss Ratio
1.09
Alpha
-0.264
Beta
-0.092
Annual Standard Deviation
0.009
Annual Variance
0
Information Ratio
6.636
Tracking Error
0.106
Treynor Ratio
1.982
Total Fees
$0.00
Estimated Strategy Capacity
$220000.00
Lowest Capacity Asset
USDCUSDT 18N
# Rolling Window Fractal Indicator (Binance)

from AlgorithmImports import *

CRYPTO = "USDCUSDT";  BAR = 60;

class BlackpantherFractal(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2022, 5, 1)
        self.SetEndDate(2022, 5, 3) 
        self.SetCash("USDT", 1000) 
        self.crypto = self.AddCrypto(CRYPTO, Resolution.Minute, Market.Binance).Symbol
        self.SetSecurityInitializer(lambda s: s.SetLeverage(1))
        self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin)
        self.Consolidate(self.crypto, timedelta(minutes = BAR), self.CustomBarHandler)
        self.window = RollingWindow[TradeBar](3)
        self.consolidator = TradeBarConsolidator(timedelta(minutes=BAR))        
        self.SubscriptionManager.AddConsolidator(self.crypto, self.consolidator)
        self.SetWarmUp(BAR, Resolution.Minute)
        

    def CustomBarHandler(self, bar):
        if self.IsWarmingUp: return
        self.window.Add(bar) 
        if not self.window.IsReady: return
    
        H = [self.window[i].High for i in range(3)]
        L = [self.window[i].Low for i in range(3)]
        C = [self.window[i].Close for i in range(3)]
        curr_price = self.Securities[self.crypto].Price
        
        if not self.Portfolio[self.crypto].IsLong:
            if ( curr_price <= L[1] <= L[2]):
                self.SetHoldings(self.crypto,1)
                
        elif not self.Portfolio[self.crypto].IsShort:        
            if ( curr_price >= H[1] >=  H[2]):
                self.SetHoldings(self.crypto,-1)