Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-202.171
Tracking Error
0.093
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
""" 
Algo Overview:

Create Renko bars.
1) Trade in direction of last Renkobar.
2) close at next renko bar or at first reversal candle. 

Adding something for a direction bias could go a long way 
- volume could be used for reversals (see docs to add volume)

https://www.quantconnect.com/docs/v2/writing-algorithms/consolidating-data/consolidator-types/renko-consolidators/renko-consolidators

futures example: https://www.quantconnect.com/forum/discussion/6001/creating-renko-bars-from-futures-security-seems-broken/p1 
"""

# region imports
from AlgorithmImports import *
# endregion

FUTURES_CONTRACT = Futures.Metals.Gold
# FUTURES_CONTRACT = Futures.Metals.MicroGold

class MeasuredYellowJaguar(QCAlgorithm):

    def Initialize(self):
        # Debug
        self.SetStartDate(2023, 3, 1)  
        self.SetEndDate(2023, 3, 3)

        # self.SetStartDate(2023, 1, 1)  
        # self.SetEndDate(2023, 3, 7)

        # Opto 
        # self.SetStartDate(2018, 1, 1)  
        # self.SetEndDate(2022, 12, 1)

        # OOS1
        # self.SetStartDate(2022, 1, 1)  
        # self.SetEndDate(2023, 3, 1)

        # Long Set
        # self.SetStartDate(2015, 1, 1)  
        # self.SetEndDate(2023, 1, 1)

        self.SetCash(300000) 
        # self.equity = self.AddEquity(EQUITY, Resolution.Minute)

        # Setup Futures Contract
        self.gc = self.AddFuture(FUTURES_CONTRACT, Resolution.Minute,  dataNormalizationMode = DataNormalizationMode.Raw, dataMappingMode = DataMappingMode.LastTradingDay, contractDepthOffset = 0, extendedMarketHours=True)
        
        self.consolidator = RenkoConsolidator(5)
        # self.consolidator = TradeBarConsolidator(timedelta(minutes=60))
        self.consolidator.DataConsolidated += self.RenkoBarHandler
        self.SubscriptionManager.AddConsolidator(self.gc.Symbol, self.consolidator)



    def OnData(self, data: Slice):
        
        self.gcPrice = self.gc.Price

    def RenkoBarHandler(self, sender, bar):

        self.Debug(str(self.Time) + " RenkoBar ")