FIXED TIME

MQL5 Asesores Expertos

Trabajo finalizado

Plazo de ejecución 2 minutos
Comentario del Ejecutor
Excellent customer. Clear specifications and fast payment. Thank you.

Tarea técnica

I want an EA that closes open positions at a fixed time.

for example.

I have an open buy trade on EURUSD, and i want it to close at say 4am, regardless of if it is in profit or not. if it has not hit my tp or sl by 4am i want the EA to close it.

I had AI write a code for me, but i have errors and i dont know how to fix it.

#property strict

// Define the exit time (hours and minutes)
int exitHour = 16;
int exitMinute = 0;

// Timer interval (in seconds) - Adjust as needed
int timerInterval = 60; // Check every minute

// Function to check if current time matches exit time
bool IsExitTime() {
  time_t currentTime = TimeCurrent();
  tm someTime;
  gmtime(&currentTime, &someTime); // Assuming you have gmtime defined
  return (someTime.tm_hour == exitHour && someTime.tm_min == exitMinute);
}

int OnTimer() {
  // Flag to prevent multiple executions within the timer interval
  static bool alreadyExecuted = false;

  // Check for first execution or exit time reached
  if (!alreadyExecuted && IsExitTime()) {
    alreadyExecuted = true;

    // Loop through all open positions
    int totalPositions = PositionsTotal();
    for (int i = 0; i < totalPositions; i++) {
      // Get position information
      position_info position = PositionGet(i);
      if (position.magic == EMPTY) continue; // Skip positions without magic number

      // Close the position
      double lots = position.lot;
      int result = OrderClose(position.ticket, lots, position.bid ? position.bid : position.ask, 0, "");
      if (result != RET_OK) {
        Print("Error closing position:", GetLastError());
      }
    }
  }

  return 0;
}


Han respondido

1
Desarrollador 1
Evaluación
(556)
Proyectos
849
61%
Arbitraje
33
27% / 45%
Caducado
24
3%
Libre
Ha publicado: 1 ejemplo
2
Desarrollador 2
Evaluación
(36)
Proyectos
45
47%
Arbitraje
5
40% / 60%
Caducado
9
20%
Libre
Ha publicado: 1 ejemplo
3
Desarrollador 3
Evaluación
(369)
Proyectos
457
55%
Arbitraje
24
54% / 17%
Caducado
31
7%
Trabaja
4
Desarrollador 4
Evaluación
(78)
Proyectos
246
74%
Arbitraje
7
100% / 0%
Caducado
1
0%
Libre
Ha publicado: 1 artículo
5
Desarrollador 5
Evaluación
(17)
Proyectos
21
19%
Arbitraje
5
40% / 40%
Caducado
0
Libre
6
Desarrollador 6
Evaluación
(23)
Proyectos
29
14%
Arbitraje
3
0% / 67%
Caducado
3
10%
Trabaja
7
Desarrollador 7
Evaluación
(7)
Proyectos
9
0%
Arbitraje
1
0% / 100%
Caducado
2
22%
Libre
8
Desarrollador 8
Evaluación
(50)
Proyectos
64
20%
Arbitraje
11
27% / 55%
Caducado
5
8%
Libre
9
Desarrollador 9
Evaluación
(6)
Proyectos
6
33%
Arbitraje
4
0% / 100%
Caducado
0
Libre
10
Desarrollador 10
Evaluación
(574)
Proyectos
945
47%
Arbitraje
309
58% / 27%
Caducado
125
13%
Libre
11
Desarrollador 11
Evaluación
Proyectos
0
0%
Arbitraje
1
0% / 100%
Caducado
0
Libre
Solicitudes similares
I need a professional XAUUSD signal indicator for MetaTrader 5, written entirely in MQL5 (.mq5). IMPORTANT: This is NOT an auto-trading EA. It must never open, close or modify trades. It only analyzes XAUUSD and generates signals + MT5 push notifications. 1. Multi-timeframe analysis: H4 → H1 → M30 → M15 → M10 → M5 → M1. 2. Detect market structure: - Swing High / Swing Low - BOS - MSS - CHOCH - Bullish/Bearish HTF
I would like to create a tradingview robot that will sync with tradovate. My strategy is as follows: Chart Setup - MES on left and MNQ on right. The MES chart has quarter levels on it. The MNQ has the volume indicator. Trading Session is from 9:30AM EST - 11:00AM EST If most recent price action has crossed *up* a quarter level on MES, I look for *sells* on MNQ. My trigger for a sell is a bearish engulfing candlestick
Hi, I would like to commission an Expert Advisor (EA) for MetaTrader 5 (MT5) based on the Smart Money Concepts (LuxAlgo) indicator, which is available in the MQL5 Market. Below are the detailed specifications for the EA: 1. General Parameters & Symbol Trading Asset: Gold (XAUUSD) Timeframe: 5-Minute (M5) Indicator Integration: Integration with "Smart Money Concepts (LuxAlgo - Smart Money Concepts)" via
We are looking for an experienced MQL5 developer who also has real trading experience to build our existing trading strategy into a fully automated MT5 Expert Advisor (EA). We already have our entry and exit trading rules documented . We are not looking for someone to invent a strategy for us. We need someone who understands trading well enough to understand our rules, discuss them with us in normal trading terms
Hello, I need an MQL5 Expert Advisor for MT5 on XAUUSD (H1) using a 1.0 lot size where every $1 movement matters. The logic must work as follows: When any active trade reaches $20.0 in profit, close that specific trade immediately and open a new opposite trade automatically. When an active trade reaches a loss of $4.0, DO NOT close the existing trade; instead, keep it open and immediately open a new opposite trade
I'm looking to purchase a profitable trading robot (EA) for MetaTrader. Requirements: Backtest Requirements: Verified backtest results covering exactly 2 years of historical data (no more, no less) Data must be from a reputable source with tick-level accuracy (99% modeling quality preferred) Please include key metrics: total net profit, profit factor, maximum drawdown, win rate, and Sharpe ratio Strategy Explanation
Surebot 100+ USD
I want a sure bot that will be able to plat a good and nice trade thst i will benefit from and that i all use to make it in life
i have indicator for Trading View, also copy for NT, i need someone to improve and check the NT version (indicator is simple is volume density koncept)…. when i put same settings on TV version and NT version i have diffrerent results, but this can be because diffrent market data or fact that TV sending tick info in blocks , not tick by tick like NT8 on both. I(ndicator base on counting volume) so besied that is it
MT5 Expert — Custom Manual Fibonacci Automation & Cycle Synchronization Project Overview I am looking for an experienced MT5 / MQL5 Expert developer to build a fully customized Expert based on my own chart cycle/engine and manual Fibonacci workflow. This is not an auto-trading robot . The Expert is designed to assist my manual trading workflow by automating the repetitive chart and Fibonacci process while keeping the
Hi, I am looking for a profitable MT5 EA,If you are interested in this job, grateful if you could provide a brief description of the strategy and one week demo trial , Thank you

Información sobre el proyecto

Presupuesto
30+ USD
Plazo límite de ejecución
a 1 día(s)