Login / Join

Technical analysis by impressivePers2252 about Symbol BTC on 6/10/2024

https://sahmeto.com/message/3305368
،Technical،impressivePers2252

import pandas as pdimport matplotlib.pyplot as plt# Load data# For this example, we'll use a CSV file with 'Date' and 'Close' columns.# Adjust the file path as needed.data = pd.read_csv('path/to/your/data.csv')# Convert 'Date' column to datetimedata['Date'] = pd.to_datetime(data['Date'])# Set 'Date' column as the indexdata.set_index('Date', inplace=True)# Define the short-term and long-term moving averagesshort_window = 50long_window = 200# Calculate the short-term and long-term moving averagesdata['Short_MA'] = data['Close'].rolling(window=short_window, min_periods=1).mean()data['Long_MA'] = data['Close'].rolling(window=long_window, min_periods=1).mean()# Create signalsdata['Signal'] = 0data['Signal'][short_window:] = np.where(data['Short_MA'][short_window:] > data['Long_MA'][short_window:], 1, 0)# Generate trading ordersdata['Position'] = data['Signal'].diff()# Plotting the resultsplt.figure(figsize=(14, 7))# Plot the closing price and moving averagesplt.plot(data['Close'], label='Close Price', alpha=0.5)plt.plot(data['Short_MA'], label=f'Short {short_window}-Day MA', alpha=0.75)plt.plot(data['Long_MA'], label=f'Long {long_window}-Day MA', alpha=0.75)# Plot buy signalsplt.plot(data[data['Position'] == 1].index, data['Short_MA'][data['Position'] == 1], '^', markersize=10, color='g', lw=0, label='Buy Signal')# Plot sell signalsplt.plot(data[data['Position'] == -1].index, data['Short_MA'][data['Position'] == -1], 'v', markersize=10, color='r', lw=0, label='Sell Signal')# Add labels and legendplt.title('Moving Average Crossover Strategy')plt.xlabel('Date')plt.ylabel('Price')plt.legend()plt.show()

Translated from: English
Show Original Message
Signal Type: Neutral
Time Frame:
4 hours
Price at Publish Time:
$69,346.64
Share
Signals
Top Traders
Feed
Alerts