Skip to content

Instantly share code, notes, and snippets.

@croosen
Created August 11, 2022 13:36
Show Gist options
  • Save croosen/83746bbce0dd1cac3a06105e8cc97d03 to your computer and use it in GitHub Desktop.
Save croosen/83746bbce0dd1cac3a06105e8cc97d03 to your computer and use it in GitHub Desktop.
Ichimoku Cloud in mplfinance
import mplfinance as mpf
ichimoku_cloud = [
mpf.make_addplot(df['tenkan_sen'], color = 'blue', width = 1),
mpf.make_addplot(df['kijun_sen'], color = 'red', width = 1),
mpf.make_addplot(df['senkou_span_a'], color = 'lightgreen', width = 0.5),
mpf.make_addplot(df['senkou_span_b'], color = 'lightcoral', width = 0.5),
mpf.make_addplot(df['chikou_span'], color = 'green', width = 1)
]
fill_up = dict(y1 = df['senkou_span_a'].values, y2 = df['senkou_span_b'].values, where = df['senkou_span_a'] >= df['senkou_span_b'], alpha = 0.5, color = 'honeydew')
fill_down = dict(y1 = df['senkou_span_a'].values, y2 = df['senkou_span_b'].values, where = df['senkou_span_a'] < df['senkou_span_b'], alpha = 0.5, color = 'mistyrose')
mpf.plot(
df,
type = 'candle',
addplot = ichimoku_cloud,
fill_between = [fill_up, fill_down]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment