Skip to content

Commit

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

def Highest(dataframe, period=14, price="high"):
df = dataframe.copy()

# Select the price column based on the input parameter
price_column = df[price]

# Initialize the indicator values
highest_values = np.zeros(len(df))

for i in range(len(df)):
if i < period - 1:
highest_values[i] = 0.0
else:
price_slice = price_column[i - period + 1:i + 1]
highest_value = max(price_slice)
highest_values[i] = highest_value

df["Highest"] = highest_values
return df

# Example usage:
# Assuming you have a pandas DataFrame df with columns ["high", "low", "open", "close", "volume"]
# You can calculate SqHighest as follows:
# sq_highest_result = Highest(df, period=14, price="high")

0 comments on commit 9b8c6eb

Please sign in to comment.