Ichimoku Pipeline

Hi, I am trying to do a simple pipeline for the Ichimoku cloud indicator. I have done the following, but I receive the following error: 'Latest' object has no attribute 'rolling'. If anyone knows what am I doing incorrectly or knows how to this Pipeline correctly, I would appreciate it.

def make_pipeline():

high_prices = USEquityPricing.high.latest
low_prices = USEquityPricing.low.latest

nine_period_high =  high_prices.rolling(window=9).max()
nine_period_low = low_prices.rolling(window=9).min()
tenkan_sen = (nine_period_high + nine_period_low) /2

period26_high = high_prices.rolling(window=26).max()
period26_low = low_prices.rolling(window=26).min()
kijun_sen = (period26_high + period26_low) / 2

senkou_span_a = ((tenkan_sen + kijun_sen) / 2).shift(26)
period52_high = high_prices.rolling(window=52).max()
period52_low = low_prices.rolling(window=52).min()
senkou_span_b = ((period52_high + period52_low) / 2).shift(26)

latest_close = USEquityPricing.close.latest
return pipeline(columns={
'Latest_close':latest_close,
})

5 responses

@Pedro,

There is Built in factor IchimokuKinkoHyo

# Built in factor IchimokuKinkoHyo
tenkan_sen, kijun_sen, senkou_span_a, senkou_span_b, chikou_span = factors.IchimokuKinkoHyo(inputs=[USEquityPricing.high, USEquityPricing.low, USEquityPricing.close], mask = STK_SET)
attach_pipeline(Pipeline({'tenkan_sen': tenkan_sen,
'kijun_sen': kijun_sen,
'senkou_span_a': senkou_span_a,
'senkou_span_b': senkou_span_b,
},
screen = STK_SET),
'pipe')



Hi Vladimir, what I am really trying to do is to get a list of all the securities that are above or below the Ichimoku cloud. I am doing it in the notebook. The code you provided works perfectly in the IDE, however, what I am trying to get is a list. In the IDE, it recorded the components of the cloud of the SPY, but I want a list of the securities above/below the cloud. Is there a way to change this code to scan the Q1500US?

I tried the below and worked fine, but I am trying to get the stocks with the most volume. I did the below, however, it continues to bring all the securities, not just the 5% that I am trying to get.

from quantopian.pipeline.factors import AverageDollarVolume

def make_pipeline():

from quantopian.pipeline.factors import SimpleMovingAverage, AverageDollarVolume

dollar_volume = AverageDollarVolume(window_length=10)
high_dollar_volume = dollar_volume.percentile_between(95,100)
top = high_dollar_volume
tenkan_sen, kijun_sen, senkou_span_a, senkou_span_b, chikou_span = factors.IchimokuKinkoHyo(inputs=[USEquityPricing.high, USEquityPricing.low, USEquityPricing.close], mask = top)
latest_close = USEquityPricing.close.latest

return Pipeline(columns={
'Latest_close':latest_close,
'top':top,
})


@Pedro,

Try something like this:

def initialize(context):