Termos de Referência
"""
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())
Respondido
1
Classificação
Projetos
994
47%
Arbitragem
33
36%
/
36%
Expirado
98
10%
Livre
Publicou: 6 códigos
2
Classificação
Projetos
23
9%
Arbitragem
6
33%
/
50%
Expirado
1
4%
Ocupado
3
Classificação
Projetos
50
28%
Arbitragem
14
21%
/
64%
Expirado
1
2%
Trabalhando
4
Classificação
Projetos
5
0%
Arbitragem
3
33%
/
67%
Expirado
2
40%
Livre
5
Classificação
Projetos
11
0%
Arbitragem
7
29%
/
71%
Expirado
2
18%
Trabalhando
6
Classificação
Projetos
35
23%
Arbitragem
4
0%
/
50%
Expirado
2
6%
Trabalhando
7
Classificação
Projetos
2
0%
Arbitragem
2
0%
/
50%
Expirado
0
Livre
8
Classificação
Projetos
2
0%
Arbitragem
0
Expirado
0
Livre
9
Classificação
Projetos
20
10%
Arbitragem
8
38%
/
38%
Expirado
3
15%
Trabalhando
10
Classificação
Projetos
657
32%
Arbitragem
41
41%
/
46%
Expirado
11
2%
Ocupado
11
Classificação
Projetos
19
11%
Arbitragem
4
50%
/
25%
Expirado
4
21%
Trabalhando
12
Classificação
Projetos
3
33%
Arbitragem
2
0%
/
100%
Expirado
0
Livre
13
Classificação
Projetos
3379
68%
Arbitragem
77
48%
/
14%
Expirado
342
10%
Livre
Publicou: 1 código
14
Classificação
Projetos
3
0%
Arbitragem
0
Expirado
0
Livre
15
Classificação
Projetos
0
0%
Arbitragem
1
0%
/
100%
Expirado
0
Livre
16
Classificação
Projetos
1
100%
Arbitragem
0
Expirado
0
Livre
17
Classificação
Projetos
264
30%
Arbitragem
0
Expirado
3
1%
Livre
Publicou: 2 códigos
18
Classificação
Projetos
29
21%
Arbitragem
20
10%
/
50%
Expirado
8
28%
Carregado
19
Classificação
Projetos
9
0%
Arbitragem
2
0%
/
50%
Expirado
1
11%
Trabalhando
20
Classificação
Projetos
477
40%
Arbitragem
105
40%
/
24%
Expirado
81
17%
Carregado
Publicou: 2 códigos
21
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
22
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
23
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
Pedidos semelhantes
Greetings I need MT5 developer that has expertise in developing a custom indicator for mt5 boom and crash based on my exact details and requirements which would be discuss later. Kindly bid for this project if it is something you can handle for me
Prop Firm Expert needs to change logic (Minor) .
30 - 50 USD
Trailing Stop Loss Based on Thresholds needs to be implemented . Live Behavior Based implementation . Entry Logic needs minor adjustment . Delete Unwanted Code . Live Chart Optimization . Two of the most liquid Symbols
Prepare expert for Live Chart . Trailing Stop Loss Based on Thresholds needs to be implemented . Live Behavior Based implementation . Logic needs to be changed/upgraded . Couple of parameters to be deleted . Other Filters like news and sessions already coded . Only one symbol to prepare for live , the other one is already optimized . Do ask me to provide you with screen shots of current live scenario
AI Trading MQL5: Maximizing Profit from a $10 Investment Achieving significant profits from a small initial capital like $10 in AI trading with MQL5 requires a highly strategic and disciplined approach. While the potential for exponential growth exists, it's crucial to manage expectations and understand the inherent risks. **Key Strategies for Small Capital AI Trading:** 1. **Low-Risk, High-Probability
Expert NinjaTrader Programmer Needed
60 - 100 USD
I’m looking for an experienced NinjaTrader developer to complete an existing custom indicator. The project is already partially built and is well organized, completely functional, and well documented. The former developer experienced some personal difficulties and unfortunately cannot continue. Key Requirement (Read Carefully): You MUST have direct, hands-on experience with NinjaTrader and NinjaScript (C#) . This is
Combination of RSI and Moving averages
30 - 300 USD
I need a professional developer to help me create an EA using RSI and Moving averages.The strategies are well organised and everything is in order. I will send all the details in the inbox
Powerful
30 - 100 USD
I really want a powerful developed EA that can generate a minimum of 10% every month without martingale, greed or any dangerous strategy for sale. Developer must provide the mql5 file or the raw file for modification etc
I already have a fully developed MT5 Expert Advisor with all required prop firm features, including: Risk management Daily loss & max drawdown limits Spread & slippage filters News filter Trade management system The EA structure is complete. 👉 What I need is a professional developer to replace ONLY the entry logic with a high-quality, rule-based trading strategy. 🚨 STRICT REQUIREMENT (READ CAREFULLY): I am NOT
Hello, I’m looking for an experienced developer who can help convert an existing cTrader indicator into a fully functional Quantower indicator . I already have the complete source code for the cTrader indicator (written in C#) , and I would like the same logic, behavior, and visual output to be accurately replicated in Quantower
Signalfeed for Clients (Please help)
30 - 100 USD
You can control via Telegram: /start - enable bot, begin trading, /stop - end trading, disable bot /status - trade status Bot requirements: • Automated trading throughout the day until 00:00 UTC (Moscow time) (I do not want to trade or turn the bot on 100 times a day). • Auto shutdown of the bot in Telegram at 00:00 UTC (Moscow time) and manual restart when convenient. • Market analysis 24/5 using 20 EMA, RSI, and
Informações sobre o projeto
Orçamento
50+ USD