FIXED TIME

MQL5 エキスパート

仕事が完了した

実行時間2 分
開発者からのフィードバック
Excellent customer. Clear specifications and fast payment. Thank you.

指定

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


応答済み

1
開発者 1
評価
(556)
プロジェクト
849
61%
仲裁
33
27% / 45%
期限切れ
24
3%
暇
パブリッシュした人: 1 code
2
開発者 2
評価
(36)
プロジェクト
45
47%
仲裁
5
40% / 60%
期限切れ
9
20%
暇
パブリッシュした人: 1 code
3
開発者 3
評価
(369)
プロジェクト
457
55%
仲裁
24
54% / 17%
期限切れ
31
7%
仕事中
4
開発者 4
評価
(78)
プロジェクト
246
74%
仲裁
7
100% / 0%
期限切れ
1
0%
暇
パブリッシュした人: 1 article
5
開発者 5
評価
(17)
プロジェクト
21
19%
仲裁
5
40% / 40%
期限切れ
0
暇
6
開発者 6
評価
(23)
プロジェクト
29
14%
仲裁
3
0% / 67%
期限切れ
3
10%
仕事中
7
開発者 7
評価
(7)
プロジェクト
9
0%
仲裁
1
0% / 100%
期限切れ
2
22%
暇
8
開発者 8
評価
(50)
プロジェクト
64
20%
仲裁
11
27% / 55%
期限切れ
5
8%
暇
9
開発者 9
評価
(6)
プロジェクト
6
33%
仲裁
4
0% / 100%
期限切れ
0
暇
10
開発者 10
評価
(574)
プロジェクト
945
47%
仲裁
309
58% / 27%
期限切れ
125
13%
暇
11
開発者 11
評価
プロジェクト
0
0%
仲裁
1
0% / 100%
期限切れ
0
暇
類似した注文
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

プロジェクト情報

予算
30+ USD
締め切り
最高 1 日