Spécifications
"""
Fast Multi-Pair RSI Trading Bot
Supports:
- BTCUSDT
- XAUUSD
- GBPUSD
Opens fast buy or sell trades based on RSI signals
Closes trades after 5, 10, or 15 minutes
"""
import asyncio
import time
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import pandas as pd
import numpy as np
# ===== RSI calculation ===== #
def compute_rsi(close: pd.Series, period: int = 14) -> pd.Series:
delta = close.diff()
gain = delta.clip(lower=0)
loss = -delta.clip(upper=0)
avg_gain = gain.ewm(alpha=1 / period, adjust=False).mean()
avg_loss = loss.ewm(alpha=1 / period, adjust=False).mean()
rs = avg_gain / avg_loss
return 100 - (100 / (1 + rs))
# ===== Position structure ===== #
@dataclass
class Position:
id: str
symbol: str
side: str
entry_price: float
size: float
opened_at: float
duration_min: int
# ===== Config ===== #
@dataclass
class BotConfig:
symbols: List[str] = field(default_factory=lambda: ["BTCUSDT", "XAUUSD", "GBPUSD"])
rsi_period: int = 14
rsi_oversold: int = 30
rsi_overbought: int = 70
durations_min: List[int] = field(default_factory=lambda: [5, 10, 15])
account_equity: float = 2000.0
risk_pct: float = 0.5
lot_size: Optional[float] = None
paper: bool = True
# ===== Trading Bot ===== #
class MultiPairRSIBot:
def __init__(self, cfg: BotConfig):
self.cfg = cfg
self.data: Dict[str, pd.DataFrame] = {sym: pd.DataFrame() for sym in cfg.symbols}
self.positions: Dict[str, Dict[str, Position]] = {sym: {} for sym in cfg.symbols}
self._id = 0
# ========== Fake 1-minute feed for PAPER mode ========== #
def get_fake_ohlcv(self, symbol):
now = int(time.time()) * 1000
df = self.data[symbol]
last_close = df["close"].iloc[-1] if not df.empty else 1000 + np.random.rand() * 10
change = np.random.normal(0, 0.0008)
close = last_close * (1 + change)
high = max(last_close, close)
low = min(last_close, close)
return (now, last_close, high, low, close, 0)
# ========== Append new candle ========== #
def append_candle(self, symbol, ohlc):
ts, o, h, l, c, v = ohlc
row = {"timestamp": pd.to_datetime(ts, unit="ms"),
"open": o, "high": h, "low": l, "close": c, "volume": v}
self.data[symbol] = pd.concat([self.data[symbol], pd.DataFrame([row])], ignore_index=True)
if len(self.data[symbol]) > 2000:
self.data[symbol] = self.data[symbol].iloc[-2000:]
# ========== Timeframe aggregation ========== #
def to_tf(self, symbol, minutes):
df = self.data[symbol]
if df.empty:
return pd.DataFrame()
df["bucket"] = df["timestamp"].dt.floor(f"{minutes}T")
out = df.groupby("bucket").agg({
"open": "first",
"high": "max",
"low": "min",
"close": "last",
"volume": "sum"
}).reset_index().rename(columns={"bucket": "timestamp"})
return out
# ========== Position sizing ========== #
def get_size(self, price):
if self.cfg.lot_size:
return self.cfg.lot_size
risk_amount = self.cfg.account_equity * (self.cfg.risk_pct / 100)
return round(risk_amount / price, 4)
# ========== Check RSI signals and enter trades ========== #
async def process_signals(self, symbol):
for dur in self.cfg.durations_min:
df = self.to_tf(symbol, dur)
if len(df) < self.cfg.rsi_period + 2:
continue
df["rsi"] = compute_rsi(df["close"], self.cfg.rsi_period)
prev = df["rsi"].iloc[-2]
last = df["rsi"].iloc[-1]
price = df["close"].iloc[-1]
# BUY: RSI cross up
if prev <= self.cfg.rsi_oversold and last > prev:
size = self.get_size(price)
await self.open_position(symbol, "buy", price, size, dur)
# SELL: RSI cross down
if prev >= self.cfg.rsi_overbought and last < prev:
size = self.get_size(price)
await self.open_position(symbol, "sell", price, size, dur)
# ========== Open position ========== #
async def open_position(self, symbol, side, price, size, duration):
self._id += 1
pid = f"{symbol}_{self._id}"
print(f"[{symbol}] OPEN {side.upper()} @ {price:.2f} | {duration}m | size {size}")
pos = Position(
id=pid,
symbol=symbol,
side=side,
entry_price=price,
size=size,
opened_at=time.time(),
duration_min=duration
)
self.positions[symbol][pid] = pos
# ========== Close expired trades ========== #
async def close_expired(self, symbol):
now = time.time()
to_close = []
for pid, pos in self.positions[symbol].items():
if (now - pos.opened_at) / 60 >= pos.duration_min:
to_close.append(pid)
for pid in to_close:
await self.close_position(symbol, pid)
# ========== Close position ========== #
async def close_position(self, symbol, pid):
pos = self.positions[symbol][pid]
last_price = self.data[symbol]["close"].iloc[-1]
pnl = (last_price - pos.entry_price) * pos.size if pos.side == "buy" else (pos.entry_price - last_price) * pos.size
print(f"[{symbol}] CLOSE {pos.side.upper()} @ {last_price:.2f} | PnL = {pnl:.3f}")
self.cfg.account_equity += pnl
del self.positions[symbol][pid]
# ========== Main loop ========== #
async def start(self):
print("Starting multi-pair RSI bot...")
print("Symbols:", self.cfg.symbols)
while True:
try:
for symbol in self.cfg.symbols:
# new candle
ohlcv = self.get_fake_ohlcv(symbol)
self.append_candle(symbol, ohlcv)
# signal scan
await self.process_signals(symbol)
# manage trades
await self.close_expired(symbol)
except Exception as e:
print("Error:", e)
await asyncio.sleep(1)
# ========== Launch Example ========== #
async def main():
cfg = BotConfig(
symbols=["BTCUSDT", "XAUUSD", "GBPUSD"],
account_equity=3000.0,
paper=True,
lot_size=None
)
bot = MultiPairRSIBot(cfg)
task = asyncio.create_task(bot.start())
await asyncio.sleep(60 * 5) # run 5 minutes demo
task.cancel()
if __name__ == "__main__":
asyncio.run(main())
Répondu
1
Évaluation
Projets
979
46%
Arbitrage
32
38%
/
34%
En retard
96
10%
Travail
Publié : 6 codes
2
Évaluation
Projets
22
9%
Arbitrage
4
50%
/
50%
En retard
1
5%
Chargé
3
Évaluation
Projets
33
15%
Arbitrage
13
8%
/
69%
En retard
0
Occupé
4
Évaluation
Projets
4
0%
Arbitrage
2
50%
/
50%
En retard
2
50%
Gratuit
5
Évaluation
Projets
11
0%
Arbitrage
6
33%
/
67%
En retard
2
18%
Gratuit
6
Évaluation
Projets
34
24%
Arbitrage
4
0%
/
50%
En retard
2
6%
Travail
7
Évaluation
Projets
2
0%
Arbitrage
2
0%
/
0%
En retard
0
Travail
8
Évaluation
Projets
2
0%
Arbitrage
0
En retard
0
Gratuit
9
Évaluation
Projets
18
6%
Arbitrage
8
38%
/
38%
En retard
2
11%
Travail
10
Évaluation
Projets
620
33%
Arbitrage
36
39%
/
53%
En retard
11
2%
Occupé
11
Évaluation
Projets
11
9%
Arbitrage
3
33%
/
33%
En retard
4
36%
Chargé
12
Évaluation
Projets
3
33%
Arbitrage
2
0%
/
100%
En retard
0
Gratuit
13
Évaluation
Projets
3338
67%
Arbitrage
77
48%
/
14%
En retard
342
10%
Gratuit
Publié : 1 code
14
Évaluation
Projets
3
0%
Arbitrage
0
En retard
0
Gratuit
15
Évaluation
Projets
0
0%
Arbitrage
1
0%
/
100%
En retard
0
Gratuit
16
Évaluation
Projets
1
100%
Arbitrage
0
En retard
0
Gratuit
17
Évaluation
Projets
254
30%
Arbitrage
0
En retard
3
1%
Gratuit
Publié : 2 codes
18
Évaluation
Projets
29
21%
Arbitrage
20
10%
/
50%
En retard
8
28%
Travail
19
Évaluation
Projets
3
0%
Arbitrage
1
0%
/
100%
En retard
0
Travail
20
Évaluation
Projets
470
39%
Arbitrage
102
40%
/
24%
En retard
78
17%
Occupé
Publié : 2 codes
21
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
22
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
23
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
Commandes similaires
Create an automated trading robot that can execute trades on my behalf without requiring manual intervention.The robot should be able to monitor market conditions, execute trades, manage risk, optimize performance
Expect Advisor base on RSI
36+ USD
1.RSI strategy for gold , use RSI to identify overbought (above 70)and oversold (below 30) conditions. .Implement entry signals when RSI crosses these thresholds. 2.Risk management , set a maximum percentage of account equity per trade 1-2 % . Implement stop loss and take profit levels to limit loses and lock in gains. .Apply a maximum draw down limit to prevent significant losses. 3. Trade execution , ensure proper
Cherrys trading bot
300+ USD
//+------------------------------------------------------------------+ //| XAUUSD Ultimate Institutional EA | //| Features: | //| - True swing-based market structure | //| - BOS sniper entries on M5 | //| - Liquidity sweep filter | //| - Partial TP + breakeven | //| - Visual BOS, swings, liquidity
MT5 Expert Advisor Developer | Structure & Risk Systems
300 - 700 USD
I will develop a custom MetaTrader 5 Expert Advisor based on the client’s provided trading rules. The EA will include proper entry and exit logic, stop loss and take profit handling and stable risk management. The code will be clean, non-repainting, MT5 compliant, and delivered with full source files. "Risk Disclosure : Trading in financial markets involves risk, and results depend on market conditions, broker
I need a professional developer to build a Telegram-to-MetaTrader trade copier system. Project overview: - A Telegram bot will read trade signals from a Telegram channel - Trades will be automatically executed on MT4 and/or MT5 accounts - The system must support copying trades to multiple MetaTrader accounts - Execution should work even when the user is offline Functional requirements: - Structured signal format
I need a MetaTrader 5 Expert Advisor (EA) built based on a clear, rule-based strategy for XAUUSD on the M5 timeframe. Indicators used: EMA 50 (Exponential, Close) EMA 200 (Exponential, Close) RSI (14) Stochastic Oscillator (14,3,3) BUY rules: Price above EMA 50 and EMA 200 RSI between 10 and 25 Stochastic crosses upward from below 20 Bullish candle close SELL rules: Price below EMA 50 and EMA 200 RSI between 80 and
Expert Advisor (EA) Development Specification
30 - 100 USD
Platform: MT5 | Instrument: XAUUSD | Broker: IC Markets (ECN) Style: High-speed scalping / short-term momentum | Timeframes: M1 & M5 | Operation: Fully automated, 24/5 Overview We seek an experienced MQL5 developer to build a fast, reliable EA for live trading. The EA must: Detect symbol specifications automatically (digits, tick size, contract size) Operate continuously without manual intervention Follow logical
Convert the indicator available in trade view named "Support resistance diagonal" by Pikusov to use in MT5 platform. Also need get some alerts in mobile (any social media app/ MT5) if crossing the support/ resistance lines
Need Web Trade Copier System
50+ USD
Hello great developers, I need a very fast and hardworking deliver who know both back end and front end of trade copier system. I need a web based trade copier application, i already create the website aspect, only need the copier to be included. I actually have a limited time, and no room for unprofessional developers, kindly send your applications if you can actually get it done in the space of 2 days and my budget
EA Development mentor
30 - 40 USD
am looking for a Mentor that has verifiable experience trading forex and commodities. Somebody who has a couple years experience in failures and successes. I am not a beginner. I have modest success already with discretionary trading. I have had an EA created that is very promising. It has extensive testing with very good results. The idea would be to work together advancing the existing EA and build additional EA's
Informations sur le projet
Budget
50+ USD