Notebook
In [ ]:
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 [ ]:
class OHLC4(CustomFactor):
 #Defining OHLC4


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

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

OHLC4_factor = OHLC4()
In [1]:
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_factor, window_length=5)
    
    #Bolinger band Width:
    
    upper_band = basis + 2*(basis.std())
    lower_band = basis - 2*(basis.std())
    
    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={
            'BBW': BBW_consolidation,
            
        },
        screen = Q500US()
    )
    
    return pipe

#Run the pipeline to view output securities:
result = run_pipeline(make_pipeline(), '2019-05-24', '2019-05-24', chunksize=252)
NameErrorTraceback (most recent call last)
<ipython-input-1-91a28f6d4c9d> in <module>()
     37 
     38 #Run the pipeline to view output securities:
---> 39 result = run_pipeline(make_pipeline(), '2019-05-24', '2019-05-24', chunksize=252)

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

NameError: name 'result' is not defined