peymanchart
@t_peymanchart
What symbols does the trader recommend buying?
Purchase History
پیام های تریدر
Filter
Signal Type

import yfinance as yf import pandas as pd import talib import matplotlib.pyplot as plt # دانلود داده 6 ماه اخیر بیت کوین 1 ساعته data = yf.download("BTC-USD", period="6mo", interval="1h") # محاسبه EMA50 و EMA200 روزانه برای روند daily = data.resample('1D').agg({'Open':'first', 'High':'max', 'Low':'min', 'Close':'last'}) daily ['EMA50'] = talib.EMA(daily ['Close'], timeperiod=50) daily ['EMA200'] = talib.EMA(daily ['Close'], timeperiod=200) # تابع روند روزانه def get_trend(date): if date not in daily.index: return 0 row = daily.loc [date] if row ['EMA50'] > row ['EMA200']: return 1 elif row ['EMA50'] < row ['EMA200']: return -1 return 0 # اضافه کردن ستون روند به دیتای 1 ساعته data ['date'] = data.index.floor('D') data ['trend'] = data ['date'].apply(get_trend) # محاسبه EMA50 و RSI ساعتی data ['EMA50'] = talib.EMA(data ['Close'], timeperiod=50) data ['RSI'] = talib.RSI(data ['Close'], timeperiod=14) balance = 10000 position = 0 # 1=خرید، -1=فروش، 0=خالی entry_price = 0 stop_loss_pct = 0.01 risk_reward = 2 trades = [] for i in range(1, len(data)): row = data.iloc prev = data.iloc [i-1] if position == 0: if row ['trend'] == 1: # روند صعودی if prev ['RSI'] < 50 and row ['RSI'] >= 35 and abs(row ['Close'] - row ['EMA50'])/row ['EMA50'] < 0.01: position = 1 entry_price = row ['Close'] stop_loss = entry_price * (1 - stop_loss_pct) take_profit = entry_price + (entry_price - stop_loss)*risk_reward trades.append(('buy', row.name, entry_price)) elif row ['trend'] == -1: # روند نزولی if prev ['RSI'] > 50 and row ['RSI'] <= 65 and abs(row ['Close'] - row ['EMA50'])/row ['EMA50'] < 0.01: position = -1 entry_price = row ['Close'] stop_loss = entry_price * (1 + stop_loss_pct) take_profit = entry_price - (stop_loss - entry_price)*risk_reward trades.append(('sell', row.name, entry_price)) else: if position == 1: if row ['Low'] <= stop_loss: balance -= (entry_price - stop_loss) trades.append(('stop_loss', row.name, stop_loss)) position = 0 elif row ['High'] >= take_profit: balance += (take_profit - entry_price) trades.append(('take_profit', row.name, take_profit)) position = 0 elif position == -1: if row ['High'] >= stop_loss: balance -= (stop_loss - entry_price) trades.append(('stop_loss', row.name, stop_loss)) position = 0 elif row ['Low'] <= take_profit: balance += (entry_price - take_profit) trades.append(('take_profit', row.name, take_profit)) position = 0 print(f"Final balance: {balance}") print("Trades:") for t in trades: print(t) # نمودار ساده plt.figure(figsize=(15,7)) plt.plot(data.index, data ['Close'], label='Price') for t in trades: if t [0] == 'buy': plt.scatter(t [1], t [2], marker='^', color='green') elif t [0] == 'sell': plt.scatter(t [1], t [2], marker='v', color='red') plt.legend() plt.show()
Disclaimer
Any content and materials included in Sahmeto's website and official communication channels are a compilation of personal opinions and analyses and are not binding. They do not constitute any recommendation for buying, selling, entering or exiting the stock market and cryptocurrency market. Also, all news and analyses included in the website and channels are merely republished information from official and unofficial domestic and foreign sources, and it is obvious that users of the said content are responsible for following up and ensuring the authenticity and accuracy of the materials. Therefore, while disclaiming responsibility, it is declared that the responsibility for any decision-making, action, and potential profit and loss in the capital market and cryptocurrency market lies with the trader.