Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions "Add Binary Bot code
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Bot Options Binary — تجربة على Quotex (educational only)
# يستخدم مكتبة غير رسمية للتواصل مع المنصة (تحذير: تجريب فقط)
# pip install quotexpy

from quotexpy import Quotex
import time, math

# ----- إعدادات -----
EMAIL = "[email protected]"
PASSWORD = "your_password"
SYMBOL = "EURUSD" # الأصل المالي
TIMEFRAME = 60 # مدة الصفقة بالدقائق
RISK_PERCENT = 1.0 # نسبة المخاطرة لكل صفقة %
MAX_TRADES = 2 # أقصى عدد صفقات مفتوحة في نفس الوقت

RSI_PERIOD = 14
SMA_PERIOD = 50

# ----- اتّصال بالمنصة -----
client = Quotex(email=EMAIL, password=PASSWORD)
connected, msg = client.connect()
if not connected:
print("❌ فشل الاتصال:", msg)
exit()

# ----- دوال تحليل -----
def calc_rsi(closes, period=RSI_PERIOD):
gains = []
losses = []
for i in range(1, len(closes)):
diff = closes[i] - closes[i-1]
if diff >= 0:
gains.append(diff)
losses.append(0)
else:
gains.append(0)
losses.append(abs(diff))
avg_gain = sum(gains[-period:]) / period
avg_loss = sum(losses[-period:]) / period
if avg_loss == 0: return 100
rs = avg_gain / avg_loss
return 100 - (100 / (1 + rs))

def calc_sma(closes, period=SMA_PERIOD):
if len(closes) < period:
return sum(closes) / len(closes)
return sum(closes[-period:]) / period

# ----- تنفيذ صفقة -----
def open_trade(direction, amount):
result = client.buy_simple(SYMBOL, amount, direction, TIMEFRAME)
print(f"✅ فتح صفقة {direction} بمبلغ {amount}")
return result

def count_trades_open():
trades = client.get_open_trades()
return len([t for t in trades if t["symbol"] == SYMBOL])

# ----- الحلقة الرئيسية -----
while True:
# تأكّد عدد الصفقات المفتوحة أقل من الحد
if count_trades_open() >= MAX_TRADES:
time.sleep(5)
continue

candles = client.get_candles(symbol=SYMBOL, timeframe=TIMEFRAME, limit=100)
closes = [c["close"] for c in candles]

rsi = calc_rsi(closes)
sma = calc_sma(closes)

last = candles[-1]
direction = None
if last["close"] > last["open"] and last["close"] > sma and rsi < 30:
direction = "call"
elif last["close"] < last["open"] and last["close"] < sma and rsi > 70:
direction = "put"

if direction:
balance = client.get_balance()
amount = balance * (RISK_PERCENT / 100.0)
amount = max(amount, 1.0) # حد أدنى $1
open_trade(direction, amount)

time.sleep(TIMEFRAME * 60) # انتظار حتى انتهاء مدة الصفقة