Search
Products
Community
Markets
News
Brokers
More
IN
Get started
Community
/
Ideas
/
waqar
AXS / TetherUS PERPETUAL CONTRACT
waqar
By w44629
Follow
Follow
Oct 4, 2023
0
Oct 4, 2023
import pandas as pd
import numpy as np
# Sample historical price data (replace with your own data)
data = {
'timestamp': ['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05'],
'price': [100, 110, 120, 130, 140]
}
# Create a DataFrame from the data
df = pd.DataFrame(data)
df['timestamp'] = pd.to_datetime(df['timestamp'])
df.set_index('timestamp', inplace=True)
# Define the period for the SMA
sma_period = 3 # You can adjust this to your preferred period
# Calculate the SMA
df['SMA'] = df['price'].rolling(window=sma_period).mean()
# Print the DataFrame with SMA values
print(df)
Trend Analysis
w44629
Follow
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the
Terms of Use
.