15
min

Basic Sample Strategies for the Pembe Editor

A basic list of example strategies for the Pembe editor

This article lists some sample strategies that can be easily applied in the backtesting area. You just have to copy everything after the first line into the editor. The 'class' should not be copied. The Pembe editor generates these automatically and puts a class in the first line. The strategy can then be tested on historical data. The strategies are simple sample strategies, for active live trading these should be optimized if possible. For more details please have a look at: https://pembe.webflow.io/blog/how-the-pembe-strategie-editor-works


### SimpleMovingAverage ###

### 10-50 SMA ###

class MaCrossStrategy(bt.Strategy):


### copy this into the Pembe Editor ###

    def __init__(self):
        ma_fast = bt.ind.SMA(period=10)
        ma_slow = bt.ind.SMA(period=50)
       self.crossover = bt.ind.CrossOver(ma_fast, ma_slow)


   def next(self):

        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()

### ExponentialMovingAverage ###

### 5-8-13 EMA ###

class MaCrossStrategy(bt.Strategy):

### copy this into the Pembe Editor ###

    def __init__(self):
        ma_fast = bt.ind.EMA(period=5)
        ma_mid = bt.ind.EMA(period=8)
        ma_slow = bt.ind.EMA(period=13
        self.crossover = bt.ind.CrossOver(ma_fast, ma_slow, ma_mid)

    def next(self):

        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()

### TripleExponentialMovingAverage ###

### 5-8-13 TEMA ###

class MaCrossStrategy(bt.Strategy):

### copy this into the Pembe Editor ###

   def __init__(self):
        ma_fast = bt.ind.TEMA(period=5)
        ma_mid = bt.ind.TEMA(period=8)
        ma_slow = bt.ind.TEMA(period=13)
        self.crossover = bt.ind.CrossOver(ma_fast, ma_slow, ma_mid)

    def next(self):
        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()


### SmoothedMovingAverage ###

### 5-8-13 SMMA ###

class MaCrossStrategy(bt.Strategy):

### copy this into the Pembe Editor ###

    def __init__(self):
        ma_fast = bt.ind.SMMA(period=5)
        ma_mid = bt.ind.SMMA(period=8)
        ma_slow = bt.ind.SMMA(period=13)
        self.crossover = bt.ind.CrossOver(ma_fast, ma_slow, ma_mid)

    def next(self):
        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()

### HullMovingAverage ###

### 5-8-13 HMA ###

class MaCrossStrategy(bt.Strategy):

### copy this into the Pembe Editor ###

    def __init__(self):
        ma_fast = bt.ind.HMA(period=5)
        ma_mid = bt.ind.HMA(period=8)
        ma_slow = bt.ind.HMA(period=13)
        self.crossover = bt.ind.CrossOver(ma_fast, ma_slow, ma_mid)

    def next(self):
        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()


### DoubleExponentialMovingAverage ###

### 5-8-13 DEMA ###

class MaCrossStrategy(bt.Strategy):

### copy this into the Pembe Editor ###

    def __init__(self):
        ma_fast = bt.ind.DEMA(period=5)
        ma_mid = bt.ind.DEMA(period=8)
        ma_slow = bt.ind.DEMA(period=13)
        self.crossover = bt.ind.CrossOver(ma_fast, ma_slow, ma_mid)

    def next(self):
        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()

### DicksonMovingAverage ###

### 5-8-13 DMA ###


class MaCrossStrategy(bt.Strategy):

### copy this into the Pembe Editor ###

    def __init__(self):
        ma_fast = bt.ind.DMA(period=5)
        ma_mid = bt.ind.DMA(period=8)
        ma_slow = bt.ind.DMA(period=13)
        self.crossover = bt.ind.CrossOver(ma_fast, ma_slow, ma_mid)

    def next(self):
        if not self.position:
            if self.crossover > 0:
                self.buy()
        elif self.crossover < 0:
            self.close()



Source:
Foto from charlesdeluvio at Unsplash

Joshua Denefleh

CQO & Co-Founder

Strong background in financial markets, graduate from University Mannheim in B.Sc. Economics, KIT Karlsruhe University. Experience in quantitative methods, programming algo /w python