指定

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 codes
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 codes
11
開発者 11
評価
(309)
プロジェクト
555
35%
仲裁
79
32% / 42%
期限切れ
201
36%
仕事中
12
開発者 12
評価
(77)
プロジェクト
243
74%
仲裁
7
100% / 0%
期限切れ
1
0%
パブリッシュした人: 1 article
13
開発者 13
評価
(2)
プロジェクト
3
0%
仲裁
1
100% / 0%
期限切れ
0
類似した注文
Hello, I am looking for an experienced MT5 (MetaTrader 5) developer to create a simple and reliable Forex trading EA. Broker: Skyriss Platform: MT5 Requirements: • EA should work only on Forex pairs (EURUSD, GBPUSD, USDJPY, USDCHF) • Around 1–2 trades per day is enough • Proper risk management with Stop Loss (SL) and Take Profit (TP) • Prefer low-risk trading with 0.01–0.03 lot depending on balance • No martingale or
Looking for an experienced MQL5 developer to optimise and backtest my Expert Advisor (EA). The full requirements and EA file will be shared once accepted. You should have solid experience with strategy testing in MetaTrader 5 and be comfortable working with custom EAs. If this sounds like something you can help with, feel free to reach out and we can get started Developers with no reviews and no projects will be
//+------------------------------------------------------------------+ //| XAU_Pro_Scalper.mq5 | //| Advanced Gold Trading Bot (Educational) | //+------------------------------------------------------------------+ #property version "1.00" #property strict #include <Trade/Trade.mqh> CTrade trade; input double RiskPercent = 1.0; input int StopLossPoints = 250; input int TakeProfitPoints = 700; input int FastEMA = 20;
hello, please take a moment to review my project. It is for Quanttower. it is very detailed in the instructions. Thank you, Just let me know if you can do it and the whats the cost and timeframe
Key Requirements: Source Account: Connect to a Master account using Investor (Read-only) Password. Destination Account: Execute trades on a Live Slave account with full trading access. Currency Focus: The system must handle Currency Pairs accurately, including symbol mapping (e.g., EURUSD to EURUSD.m) between different brokers. Stealth Features: Remove/Disable all trade comments. Assign custom Magic Numbers to the
I need a developer to start robot from scratch based on existing EA that is running live. I do not have the source file as my previous coder did not give it to me. What I do have is the investor password which is running the EA from the coder side but not from my end. I like someone to monitor the account and re create the same system for me
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

プロジェクト情報

予算
50 - 200 USD
締め切り
最低 7 最高 10 日