FIXED TIME

MQL5 Experts

Job finished

Execution time 2 minutes
Feedback from employee
Excellent customer. Clear specifications and fast payment. Thank you.

Specification

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;
}


Responded

1
Developer 1
Rating
(556)
Projects
848
61%
Arbitration
33
27% / 45%
Overdue
24
3%
Free
Published: 1 code
2
Developer 2
Rating
(36)
Projects
45
47%
Arbitration
5
40% / 60%
Overdue
9
20%
Free
Published: 1 code
3
Developer 3
Rating
(369)
Projects
457
55%
Arbitration
24
54% / 17%
Overdue
31
7%
Working
4
Developer 4
Rating
(78)
Projects
246
74%
Arbitration
7
100% / 0%
Overdue
1
0%
Free
Published: 1 article
5
Developer 5
Rating
(17)
Projects
21
19%
Arbitration
5
40% / 40%
Overdue
0
Free
6
Developer 6
Rating
(23)
Projects
29
14%
Arbitration
3
0% / 67%
Overdue
3
10%
Working
7
Developer 7
Rating
(7)
Projects
9
0%
Arbitration
1
0% / 100%
Overdue
2
22%
Free
8
Developer 8
Rating
(50)
Projects
64
20%
Arbitration
11
27% / 55%
Overdue
5
8%
Free
9
Developer 9
Rating
(6)
Projects
6
33%
Arbitration
4
0% / 100%
Overdue
0
Free
10
Developer 10
Rating
(574)
Projects
945
47%
Arbitration
309
58% / 27%
Overdue
125
13%
Free
11
Developer 11
Rating
Projects
0
0%
Arbitration
1
0% / 100%
Overdue
0
Free
Similar orders
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
Order for an EA. Trade signals from 1 Buffer Needed is an EA which runs from one of my indicators. Indicator has 2 Buffers, we use only 1 of them. To use are the datas from Datawindow of the indicator buffers. BUFFER 1 in Datawindow = CCI-iRSI If value (of Buffer1) Candle = > 0 = LONG signal If value (of Buffer1) AT END of Candle = < 0 = Short signal If value (of BUffer1) AT END of Candle = 0 = the current signal
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

Project information

Budget
30+ USD
Deadline
to 1 day(s)