epic-strategy

bySheda Tali

import pandas as pd import ta # ===================== # SETTINGS FOR $50 ACCOUNT # ===================== RISK_PERCENT = 0.01 # 1% risk FAST_EMA = 9 SLOW_EMA = 21 RSI_PERIOD = 14 ATR_PERIOD = 14 # ===================== # INDICATORS # ===================== def apply_strategy(df): df['ema_fast'] = ta.trend.ema_indicator(df['close'], window=FAST_EMA) df['ema_slow'] = ta.trend.ema_indicator(df['close'], window=SLOW_EMA) df['rsi'] = ta.momentum.rsi(df['close'], window=RSI_PERIOD) df['atr'] = ta.volatility.average_true_range( df['high'], df['low'], df['close'], window=ATR_PERIOD ) return df # ===================== # POSITION SIZE CALCULATION # ===================== def position_size(balance, stop_loss_distance): risk_amount = balance * RISK_PERCENT size = risk_amount / stop_loss_distance return size # ===================== # TRADE SIGNAL # ===================== def check_signal(df, balance): latest = df.iloc[-1] if latest['ema_fast'] > latest['ema_slow'] and latest['rsi'] < 70: entry = latest['close'] stop_loss = entry - latest['atr'] take_profit = entry + (latest['atr'] * 1.5) size = position_size(balance, entry - stop_loss) print("BUY SIGNAL") print("Position Size:", size) print("SL:", stop_loss) print("TP:", take_profit) elif latest['ema_fast'] < latest['ema_slow'] and latest['rsi'] > 30: entry = latest['close'] stop_loss = entry + latest['atr'] take_profit = entry - (latest['atr'] * 1.5) size = position_size(balance, stop_loss - entry) print("SELL SIGNAL") print("Position Size:", size) print("SL:", stop_loss) print("TP:", take_profit) # ===================== # RUN # ===================== df = pd.read_csv("market_data.csv") df = apply_strategy(df) account_balance = 50 check_signal(df, account_balance)

No preview

Comments (0)

No comments yet. Be the first!

System Requirements

System Requirement Document
📝

Requirements Not Generated Yet

The SRD will be automatically generated as you discuss your project with the Tech Lead Agent.

No completed page designs yet.

Completed design pages will appear here when they are ready to preview.

No user flows yet.

The User Flow Agent will generate per-persona navigation diagrams after SRD updates.

No completed page designs yet.

Completed design pages will appear here when they are ready to preview.

No user flows yet.

The User Flow Agent will generate per-persona navigation diagrams after SRD updates.