CEESCALPTOR

指定

import MetaTrader5 as mt5
import datetime
import time

# Configure your trading symbols and parameters
TRADING_SYMBOLS = ["EURUSD", "USDJPY"]
TRADE_VOLUME = 0.1
STOP_LOSS = 50  # in points
TAKE_PROFIT = 100  # in points

# Initialize connection to MetaTrader 5
if not mt5.initialize():
    print("Initialize() failed:", mt5.last_error())
    quit()

def get_current_symbols():
    now = datetime.datetime.now()
    # If it's Saturday or Sunday between 9am and 9pm, only trade EUR/USD and USD/JPY
    if now.weekday() == 5 or now.weekday() == 6:  # Saturday = 5, Sunday = 6
        if 9 <= now.hour < 21:
            return ["EURUSD", "USDJPY"]
    return TRADING_SYMBOLS

def get_position(symbol):
    positions = mt5.positions_get(symbol=symbol)
    return positions[0] if positions else None

def close_position(position):
    order_type = mt5.ORDER_TYPE_SELL if position.type == mt5.ORDER_TYPE_BUY else mt5.ORDER_TYPE_BUY
    close_request = {
        "action": mt5.TRADE_ACTION_DEAL,
        "symbol": position.symbol,
        "volume": position.volume,
        "type": order_type,
        "position": position.ticket,
        "price": mt5.symbol_info_tick(position.symbol).bid if order_type == mt5.ORDER_TYPE_BUY else mt5.symbol_info_tick(position.symbol).ask,
        "deviation": 20,
        "magic": 123456,
        "comment": "Auto close loss",
        "type_time": mt5.ORDER_TIME_GTC,
        "type_filling": mt5.ORDER_FILLING_IOC,
    }
    result = mt5.order_send(close_request)
    return result

def open_trade(symbol, order_type):
    price = mt5.symbol_info_tick(symbol).ask if order_type == mt5.ORDER_TYPE_BUY else mt5.symbol_info_tick(symbol).bid
    sl = price - STOP_LOSS * 0.0001 if order_type == mt5.ORDER_TYPE_BUY else price + STOP_LOSS * 0.0001
    tp = price + TAKE_PROFIT * 0.0001 if order_type == mt5.ORDER_TYPE_BUY else price - TAKE_PROFIT * 0.0001

    request = {
        "action": mt5.TRADE_ACTION_DEAL,
        "symbol": symbol,
        "volume": TRADE_VOLUME,
        "type": order_type,
        "price": price,
        "sl": sl,
        "tp": tp,
        "deviation": 20,
        "magic": 123456,
        "comment": "Auto trade",
        "type_time": mt5.ORDER_TIME_GTC,
        "type_filling": mt5.ORDER_FILLING_IOC,
    }

    result = mt5.order_send(request)
    return result

def simple_strategy(symbol):
    # Simple logic: open buy if price is above 50-MA
    rates = mt5.copy_rates_from_pos(symbol, mt5.TIMEFRAME_M5, 0, 100)
    if rates is None or len(rates) < 50:
        return

    closes = [bar.close for bar in rates]
    ma50 = sum(closes[-50:]) / 50
    last_close = closes[-1]

    position = get_position(symbol)

    if position:
        # Close if loss is more than X points
        profit = position.profit
        if profit < -10:  # Close if loss is more than $10
            print(f"Closing loss on {symbol}")
            close_position(position)
    else:
        if last_close > ma50:
            print(f"Opening BUY trade for {symbol}")
            open_trade(symbol, mt5.ORDER_TYPE_BUY)
        elif last_close < ma50:
            print(f"Opening SELL trade for {symbol}")
            open_trade(symbol, mt5.ORDER_TYPE_SELL)

def main_loop():
    try:
        while True:
            symbols = get_current_symbols()
            for symbol in symbols:
                simple_strategy(symbol)
            time.sleep(60)  # Wait 1 minute before checking again
    except KeyboardInterrupt:
        print("Bot stopped by user.")
    finally:
        mt5.shutdown()

if __name__ == "__main__":
    main_loop()

反馈

1
开发者 1
等级
(393)
项目
547
40%
仲裁
30
57% / 3%
逾期
57
10%
工作中
发布者: 11 代码
2
开发者 2
等级
(272)
项目
401
27%
仲裁
39
41% / 49%
逾期
1
0%
空闲
3
开发者 3
等级
(326)
项目
507
19%
仲裁
33
42% / 30%
逾期
34
7%
繁忙
4
开发者 4
等级
(18)
项目
22
9%
仲裁
6
33% / 50%
逾期
1
5%
工作中
5
开发者 5
等级
(250)
项目
460
26%
仲裁
140
20% / 59%
逾期
100
22%
工作中
6
开发者 6
等级
(14)
项目
14
21%
仲裁
0
逾期
0
工作中
7
开发者 7
等级
项目
2
0%
仲裁
4
25% / 50%
逾期
1
50%
空闲
8
开发者 8
等级
(4)
项目
3
33%
仲裁
2
0% / 100%
逾期
0
空闲
9
开发者 9
等级
(8)
项目
9
22%
仲裁
0
逾期
0
空闲
10
开发者 10
等级
(32)
项目
35
34%
仲裁
5
0% / 80%
逾期
0
工作中
发布者: 2 代码
11
开发者 11
等级
(309)
项目
555
35%
仲裁
79
32% / 42%
逾期
201
36%
工作中
12
开发者 12
等级
(77)
项目
243
74%
仲裁
7
100% / 0%
逾期
1
0%
空闲
发布者: 1 文章
13
开发者 13
等级
(2)
项目
3
0%
仲裁
1
100% / 0%
逾期
0
空闲
相似订单
Project Overview: I am looking for a highly experienced MetaTrader 4 (MQL4) developer to build a sophisticated automated trading system. This is not a standard grid bot; it requires complex trade management, dynamic exposure rebalancing, and a custom "Salami" liquidation module for partial loss mitigation . Key Features to Implement: Virtual Grid & Dynamic Trend: Price-action-based grid triggers without pending
We are looking for a professional developer or trader who already has a proven profitable EA or strategy based mainly on price action logic. Important requirements: No Martingale No Grid No Micro-scalping Avoid heavy indicator-based strategies Strategy should be based mainly on price behavior / market structure We are not looking for aggressive systems that promise unrealistic returns. Our focus is on stable
I run an ea it makes good profits bit that one bad grid blows up the account. I want an EA which runs parallel to it which can intelligently close bad trades or grids. It shouldn't close recoverable trades but close very bad entries and grids. It can even close with hedging. The goal recover max and also not blow up the account
I am looking for an expert MQL5 developer to build a high-precision Hedging System between two different MT5 brokers running on the same local PC. Core Objective: Execute opposite (inverse) trades between a Master and Slave account (e.g., Master BUY = Slave SELL, Master SELL = Slave BUY). The Challenge: Standard "Trade Copiers" are insufficient as they cannot prevent single-legged exposure when using manual trading
I want robot that can help me trade and make some money so that I can be able to learn from it while I'm still in depot account now.Is how it gonna help me with some money
Hello, I have two requests: First: Feature Modification Request Currently, the EA places only one pending order at a time. I want to modify this to place two opposite pending orders (Buy Stop and Sell Stop) simultaneously, with the distance between them aligned with the existing Breakeven and Trailing Stop settings in the bot. How it should work: The EA places a Buy Stop above current price and a Sell Stop
Hello, I need a professional MT5 Expert Advisor for currency trading. PAIRS: EURUSD, GBPUSD, USDJPY, USDCHF TIMEFRAME: M15 STRATEGY: - EMA 8 cross EMA 21 (entry signal) - EMA 50 for trend filter - RSI 14 confirmation (Buy > 52, Sell < 48) - No trade if RSI > 75 or < 25 SESSION: London + New York only 07:00 to 17:00 GMT No weekend trading TRADE MANAGEMENT: - Lot size: 0.06 - Take Profit: $15 per trade - Stop Loss: $8
I need a MetaTrader 5 Expert Advisor (EA) for Forex trading. Account size: $1000 Requirements: 1. The EA should work only on Forex pairs. 2. Automatic Buy and Sell trades. 3. Lot size starting from 0.04. 4. Stop Loss and Take Profit settings. 5. Only one trade at a time. 6. Works on pairs like EURUSD, GBPUSD, USDJPY etc. 7. Risk management suitable for a $1000 account. 8. Easy settings for lot size, SL, TP and risk
I want to design an EA that can identify key Supports and Resistances. This should be able to work on any timeframe from 1 minute to 1 hour (i.e 1 minute, 5 minutes, 15 minutes and 1 hour time frames.) The EA should be able to determine a Fibonacci retracement from a support and the next resistance point in an uptrend and vice versa (i.e the EA should be able to determine a Fibonacci retracement from a resistance and
Product Requirements Document (PRD) Project Title: Liquidity Sniper Semi-EA (Fibonacci & SMC Based) Platform: MetaTrader 5 (MQL5) Target Asset: XAUUSD (High Volatility) / M5 Timeframe 1. EA Operating Concept (Semi-Automated) Human-Machine Collaboration: The trader manually draws a standard Fibonacci Retracement object on the M15 chart to define the market structure (setting the 1.0 and 0.0 anchor points). EA's Role

项目信息

预算
50 - 200 USD
截止日期
 7  10 天