Gold_m1_ob_bot.

MQL5 Experts Forex

Spécifications

import MetaTrader5 as mt5
import pandas as pd
import time
from datetime import datetime

# ================== CONFIG ==================
SYMBOL = "XAUUSD"
TIMEFRAME = mt5.TIMEFRAME_M1
LOT = 0.01
MAX_OBS = 12                  # keeps signals frequent
ATR_PERIOD = 14
IMPULSE_FACTOR = 1.5          # strong candle = impulse
SESSION_START = 8             # GMT (London open)
SESSION_END = 20              # GMT (NY close)
MAX_SPREAD = 30               # points
# ===========================================

if not mt5.initialize():
    print("MT5 init failed")
    quit()

print("🚀 Gold M1 Order Block Bot started...")

ob_list = []  # list of dicts: {'type': 'bull'/'bear', 'low': , 'high': , 'tp_level': , 'mitigated': False}

def is_london_ny():
    hour = datetime.utcnow().hour
    return SESSION_START <= hour < SESSION_END

def get_data(bars=100):
    rates = mt5.copy_rates_from_pos(SYMBOL, TIMEFRAME, 0, bars)
    df = pd.DataFrame(rates)
    df['time'] = pd.to_datetime(df['time'], unit='s')
    df['atr'] = df['high'].rolling(ATR_PERIOD).max() - df['low'].rolling(ATR_PERIOD).min()
    return df

def detect_new_obs(df):
    global ob_list
    for i in range(3, len(df)-1):
        prev = df.iloc[i-1]
        curr = df.iloc[i]
        atr = curr['atr']

        # Bullish OB: bearish candle + strong bullish impulse
        if (prev['close'] < prev['open']) and (curr['close'] - curr['open'] > ATR_PERIOD * IMPULSE_FACTOR):
            ob = {'type': 'bull', 'low': prev['low'], 'high': prev['open'],
                  'tp_level': curr['high'], 'mitigated': False}
            ob_list.append(ob)

        # Bearish OB: bullish candle + strong bearish impulse
        elif (prev['close'] > prev['open']) and (curr['open'] - curr['close'] > ATR_PERIOD * IMPULSE_FACTOR):
            ob = {'type': 'bear', 'low': curr['open'], 'high': prev['high'],
                  'tp_level': curr['low'], 'mitigated': False}
            ob_list.append(ob)

    # Keep only latest unmitigated OBs
    ob_list = [ob for ob in ob_list[-MAX_OBS:] if not ob['mitigated']]

def check_mitigation_and_trade(df):
    global ob_list
    last = df.iloc[-1]
    tick = mt5.symbol_info_tick(SYMBOL)
    spread = (tick.ask - tick.bid) / mt5.symbol_info(SYMBOL).point

    if spread > MAX_SPREAD or not is_london_ny():
        return

    positions = mt5.positions_get(symbol=SYMBOL)
    if positions:
        return  # only one trade at a time

    for ob in ob_list:
        if ob['mitigated']:
            continue

        if ob['type'] == 'bull' and last['low'] <= ob['high'] and last['close'] > ob['low']:
            # BUY at Bullish OB mitigation
            sl = ob['low'] - 0.3 * last['atr']
            tp = ob['tp_level']
            request = {
                "action": mt5.TRADE_ACTION_DEAL,
                "symbol": SYMBOL,
                "volume": LOT,
                "type": mt5.ORDER_TYPE_BUY,
                "price": tick.ask,
                "sl": sl,
                "tp": tp,
                "deviation": 10,
                "magic": 123456,
                "comment": "OB_Bull_M1",
                "type_time": mt5.ORDER_TIME_GTC,
                "type_filling": mt5.ORDER_FILLING_IOC,
            }
            result = mt5.order_send(request)
            if result.retcode == mt5.TRADE_RETCODE_DONE:
                print(f"✅ BUY | TP set to impulse high {tp}")
                ob['mitigated'] = True

        elif ob['type'] == 'bear' and last['high'] >= ob['low'] and last['close'] < ob['high']:
            # SELL at Bearish OB mitigation
            sl = ob['high'] + 0.3 * last['atr']
            tp = ob['tp_level']
            request = {
                "action": mt5.TRADE_ACTION_DEAL,
                "symbol": SYMBOL,
                "volume": LOT,
                "type": mt5.ORDER_TYPE_SELL,
                "price": tick.bid,
                "sl": sl,
                "tp": tp,
                "deviation": 10,
                "magic": 123456,
                "comment": "OB_Bear_M1",
                "type_time": mt5.ORDER_TIME_GTC,
                "type_filling": mt5.ORDER_FILLING_IOC,
            }
            result = mt5.order_send(request)
            if result.retcode == mt5.TRADE_RETCODE_DONE:
                print(f"✅ SELL | TP set to impulse low {tp}")
                ob['mitigated'] = True

while True:
    df = get_data(100)
    detect_new_obs(df)
    check_mitigation_and_trade(df)
    time.sleep(10)  # check every 10 seconds on M1

Répondu

1
Développeur 1
Évaluation
(104)
Projets
169
24%
Arbitrage
23
9% / 78%
En retard
16
9%
Travail
2
Développeur 2
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
3
Développeur 3
Évaluation
(378)
Projets
486
24%
Arbitrage
59
54% / 25%
En retard
55
11%
Chargé
4
Développeur 4
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
5
Développeur 5
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
6
Développeur 6
Évaluation
(255)
Projets
262
30%
Arbitrage
0
En retard
3
1%
Gratuit
Publié : 2 codes
7
Développeur 7
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
Commandes similaires
I need any highly profitable robot which can trade small account like 50-100USD and any currency pair(s) The robot should avoid trading around news time and have good risk management. It should use any strategy which is profitable and not those unacceptable by brokers. Demo versions will be required before selection
I need a high-speed Expert Advisor (EA) for MT5 designed specifically for XAUUSD (Gold) scalping. The bot should focus on fast entries and quick profits with high efficiency. Main requirements: 1. Symbol: XAUUSD (Gold only). 2. Platform: MetaTrader 5. 3. Strategy type: Scalping (fast trades, quick profit). 4. The bot should open trades frequently based on fast market movements. 5. Small Take Profit (quick profit
A perfect indicator 30 - 80 USD
Merge nearby zones yes/no Alert on/off Label on/off Show only current relevant zones near price yes/no Distance filter from current price Zone transparency Colors Preferred Output on Chart: I want the indicator to show only: the strongest nearby support zones under price the strongest nearby resistance zones above price major higher timeframe zones clean chart view I do not want excessive clutter. Entry Assistance
Criei um Robô para a venda alta precisão que automatiza a estratégia de correção média de Larry Williams. Possui filtros de tendência seletiva, controle de lote por risco percentual e execução rápida. Compatível com contas Hedge e Netting. Configuração simples e otimizada para mercados de alta volatilidade. *55(16) 993786056
SMC ORDER BLOCK 30 - 60 USD
I want already build FULLY AUTOMATED order block MT5 XAUUSD HTF H4 ENTRY LTF M15 - Show result on live account. m15 ob entry in the direction of h4 ob bias the developper to provide source code in the end
Project Title: Custom XAUUSD Support & Resistance Indicator Platform Required: MT5 preferred. If possible, also provide TradingView Pine Script version later. Main Goal: I want a custom indicator made specifically for XAUUSD (Gold) only. The indicator should automatically detect and draw strong support and resistance zones where price has a high probability of reacting, rejecting, or reversing. It must update
1. IF price forms: - Higher highs + higher lows → TREND = BUY - Lower highs + lower lows → TREND = SELL ELSE → NO TRADE 2. IF: - Trend = BUY - Price retraces to support zone - Bullish engulfing candle forms - TDI green crosses above red (optional) THEN: - Execute BUY 3. IF: - Trend = SELL - Price retraces to resistance - Bearish engulfing forms - TDI confirms THEN: - Execute SELL 4. Risk per trade = 1% of account Lot
I need a high frequency trading robot for gold in one or 5 minute timeframe the robot should have spread filter where it should only open trades below a set spread should have news filter to allow trading during fundal news or not the robot should have input in number of minutes to close all open trades and remove pending orders before fundamental news as part of news filter. It should also have the number of minutes
Hello, I am looking for a professional trading system including: 1- Trading Bot (Expert Advisor): - Good profit performance - High security and strong risk management - Works efficiently during high market volatility (news and strong movements) - Works on all pairs (Forex + Gold) 2- Signal Indicator: - Provides clear Buy and Sell signals - Includes Take Profit and Stop Loss - No repaint (signals must not change or

Informations sur le projet

Budget
30+ USD

Client

Commandes passées1
Nombre d'arbitrages0