For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Bitcoin trading strategy



  • Hi Daniel, Happy new Year! How can I backtest the bitcoin trading strategy of Alain Glücksman? Thank you



  • @Levent-Yilmaz 1. Can you post the description of the strategy and the rules, or psuedo-code?
    2. Do you have bitcoin historical data?
    3. What timeframe does the system work on? eg. 5 minute bars, daily, or some other type of chart?





  • class BollingerBandsW(bt.Indicator):
        alias = ('BBW',)
        lines = ('bbw',)
        params = (('period', 20), ('devfactor', 2.0), ('movav', MovAv.Simple),)
    
        plotinfo = dict(subplot=True,
                        bbw=dict(_name='bbw', color='green', ls='--', _skipnan=True), )
    
        def __init__(self):
            self.boll = bt.indicators.BollingerBands(self.datas[0], period=self.params.period, devfactor=self.params.devfactor)
            self.lines.bbw = (self.boll.top - self.boll.bot) / self.boll.mid
    
    


  • 
    class VolatilityLevel(bt.Indicator):
        alias = ('VolatilityLevelIndex',)
    
        lines = ('bbw', 'VLI_fast', 'VLI_top', 'VLI_slow',)
    
        params = (
            ('period', 20),
            ('devfactor', 2.0),
            ('movav', MovAv.Simple),
            ('fast_period', 20),
            ('slow_period', 100),
        )
    
        plotinfo = dict(subplot=True,
                        bbw=dict(_name='bbw', color='green', ls='--', _skipnan=True),
                        VLI_fast=dict(_name='VLI_fast', color='red', ls='--', _skipnan=True),
                        VLI_top=dict(_name='VLI_top', color='lightred', ls='--', _skipnan=True),
                        VLI_slow=dict(_name='VLI_slow', color='blue', ls='--', _skipnan=True),
        )
    
        def __init__(self):
            self.lines.bbw = BollingerBandsW(self.data, period=self.params.period, devfactor=self.params.devfactor)
            self.lines.VLI_fast = self.p.movav(self.lines.bbw, period=self.p.fast_period)
            self.lines.VLI_slow = self.p.movav(self.lines.bbw, period=self.p.slow_period)
            std = bt.ind.StdDev(self.lines.bbw, period=self.p.slow_period)
    
            self.lines.VLI_top = self.lines.VLI_slow + 2 * std
    
    

    enjoy


Log in to reply
 

});