Notebook
In [14]:
from quantopian.pipeline.factors import AverageDollarVolume, RSI, SimpleMovingAverage
from quantopian.pipeline.filters import Q500US, QTradableStocksUS, Q1500US
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.research import run_pipeline
import talib
import numpy as np
from quantopian.pipeline import Pipeline
In [22]:
class OHLC4():
 #Defining OHLC4


    inputs = [USEquityPricing.high, USEquityPricing.close, USEquityPricing.open, USEquityPricing.low]

    def compute(self, today, assets, out, high, close, open, low):
        
        out[:] = (high + close + open + low)/4

OHLC4_factor = OHLC4()
In [2]:
def make_pipeline():

    #Factors and corresponding filters for BB Width (-+2 stdev of SMA(OHLC4,5)) of under 0.01

    #Defining OHLC4
    
    # O = USEquityPricing.open.latest  
    # H = USEquityPricing.high.latest  
    # L = USEquityPricing.low.latest  
    # C = USEquityPricing.open.latest

    # OHLC4 = ( O + H + L + C )/ 4     
    
    #Moving average for last 5 days:
    
    #basis = SimpleMovingAverage(inputs=OHLC4(), window_length=5)
    
    #Bolinger band Width:
    
    #upper_band = basis + 2*(basis.std())
    #lower_band = basis - 2*(basis.std())
    
    bb = BollingerBands(OHLC4_factor(), window_length=2, k=2)
    
    
    return Pipeline(columns={  
        'bb_upper' : bb.upper,  
        'bb_middle' : bb.middle,  
        'bb_lower' : bb.lower,  
    })
    
    
    #BBW_5 = (upper_band - lower_band)/basis

    #BBW_consolidation = BBW_5 < 0.01

    #Construct the pipeline that incorporates factors and filters from above:
    pipe = Pipeline(
        columns={
            'bb_upper' : bb.upper,  
            'bb_middle' : bb.middle,  
            'bb_lower' : bb.lower
        },
        screen = Q500US()
    )
    
    return pipe

#Run the pipeline to view output securities:
result = run_pipeline(make_pipeline(), '2019-05-24', '2019-05-24')
NameErrorTraceback (most recent call last)
<ipython-input-2-0cfd9cbb3708> in <module>()
     48 
     49 #Run the pipeline to view output securities:
---> 50 result = run_pipeline(make_pipeline(), '2019-05-24', '2019-05-24')

NameError: name 'run_pipeline' is not defined
In [3]:
result
NameErrorTraceback (most recent call last)
<ipython-input-3-0ac921c19f1a> in <module>()
----> 1 result

NameError: name 'result' is not defined