Skip to content

Commit

Permalink
Create Ichimoku.py
Browse files Browse the repository at this point in the history
  • Loading branch information
geovedi authored Nov 8, 2023
1 parent b3b5181 commit 2776b42
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions indicators/Ichimoku.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pandas as pd
import numpy as np
import talib

def Ichimoku(dataframe, tenkan=9, kijun=26, senkou=52):
df = dataframe.copy()

tenkan_sen = (df['high'].rolling(window=tenkan).max() + df['low'].rolling(window=tenkan).min()) / 2
kijun_sen = (df['high'].rolling(window=kijun).max() + df['low'].rolling(window=kijun).min()) / 2
senkou_span_a = ((tenkan_sen + kijun_sen) / 2).shift(kijun)
senkou_span_b = ((df['high'].rolling(window=senkou).max() + df['low'].rolling(window=senkou).min()) / 2).shift(kijun)

chikou_span = df['close'].shift(-kijun)

return tenkan_sen, kijun_sen, senkou_span_a, senkou_span_b, chikou_span

# Usage
# Replace df with your pandas DataFrame containing columns ['high', 'low', 'open', 'close', 'volume']
#tenkan_sen, kijun_sen, senkou_span_a, senkou_span_b, chikou_span = Ichimoku(df, tenkan=9, kijun=26, senkou=52)

0 comments on commit 2776b42

Please sign in to comment.