EA trade only once day

Hong Tien Le
288
How To Make EA Trade Only Once A Day , Please Help Me
If My EA Open Trading Method Execution Is Correct And I Want It To Only Execute Once In That Day And Not Allow My EA To Open Other Trades And Not Fixed Time To Open Trades Of The Day
Can Someone Tell Me How I Should Do It , Thanks A Lot
Vladimir Karputov
Moderator
301933
Hong Tien Le :
How To Make EA Trade Only Once A Day , Please Help Me
If My EA Open Trading Method Execution Is Correct And I Want It To Only Execute Once In That Day And Not Allow My EA To Open Other Trades And Not Fixed Time To Open Trades Of The Day
Can Someone Tell Me How I Should Do It , Thanks A Lot

Control the process of execution of a trade order: if a trade order is executed, then remember the opening time of the current daily bar.

Next time, before issuing a trade order, compare the saved time and the open time of the current daily bar.

Hong Tien Le
288
Hong Tien Le  
Vladimir Karputov #:

Control the process of execution of a trade order: if a trade order is executed, then remember the opening time of the current daily bar.

Next time, before issuing a trade order, compare the saved time and the open time of the current daily bar.

what function should i use to limit ea .'s daily transactions

Vladimir Karputov
Moderator
301933
Hong Tien Le #:

what function should i use to limit ea .'s daily transactions

Code:

iTime(Symbol(),PERIOD_D1,0)
R4tna C
60
R4tna C  
Hong Tien Le:
How To Make EA Trade Only Once A Day , Please Help Me
If My EA Open Trading Method Execution Is Correct And I Want It To Only Execute Once In That Day And Not Allow My EA To Open Other Trades And Not Fixed Time To Open Trades Of The Day
Can Someone Tell Me How I Should Do It , Thanks A Lot

You could compare the date of the last trade with the current date - if they differ only execute another trade. Here is an example function (MQL5) to give you an idea

   //+------------------------------------------------------------------+
   //|                                                                  |
   //+------------------------------------------------------------------+
   bool tradeAgain(datetime lastTradeTime)
     {
   
      MqlDateTime lastTradeTimeStruc, TimeNowStruc;
      TimeToStruct(lastTradeTime, lastTradeTimeStruc);
      TimeToStruct(TimeCurrent(), TimeNowStruc); 
      bool tradeNow = false;
      if(lastTradeTimeStruc.day < TimeNowStruc.day)
        {
         tradeNow = true;
        }
   
   
      PrintFormat("DEBUG: Last Trade Time = %s %s | Curr Time = %s %s | Should I trade? %s",
                  TimeToString(lastTradeTime, TIME_DATE), TimeToString(lastTradeTime, TIME_SECONDS),
                  TimeToString(TimeCurrent(), TIME_DATE), TimeToString(TimeCurrent(), TIME_SECONDS),
                  string(tradeNow)
                 );
   
   
   
      return(tradeNow);
     }
   //+------------------------------------------------------------------+
William Roeder
27511
William Roeder  
  1. Hong Tien Le: How To Make EA Trade Only Once A Day , Please Help Me

    Checking for a new day just like checking for a new bar.

    static datetime currDay=0; datetime prevDay=currDay; currDay=date();
    if(currDay != prevDay) OnNewDay();
              date/time (2017)
              Find bar of the same time one day ago - MQL4 programming forum (2017)

  2. Vladimir Karputov #: Code:
    iTime(Symbol(),PERIOD_D1,0)

    You could also use D1 timeframe, but then you have to deal with 4066 / synchronization issue.

    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 (2019)

    On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
              Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
              Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
              Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
              Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
              SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)

Hong Tien Le
288
Hong Tien Le  
William Roeder # :
  1. Kiểm tra một ngày mới cũng giống như kiểm tra một mới thanh.

               day / time (20 17 ) Tìm thanh cùng thời gian một ngày trước - Diễn đàn MQL4 (20 17 )
              

  2. Bạn cũng có thể sử dụng khung thời gian D1, nhưng sau đó bạn phải đối mặt với vấn đề đồng bộ hóa 4066 /.

    Trên MT4: Ngoại trừ khi hiện đồ thị được tham chiếu (các) ký hiệu / cụ thể TF, bạn phải xử lý lỗi 4066/4073 trước khi truy cập vào các đèn báo giá trị / chỉ . Lịch sử tải xuống trong MQL4 EA - Lịch Forex - Diễn đàn lập trình MQL4 - Trang 3 # 26.4 (20 19 )
              

    Trên MT5: Ngoại trừ khi biểu đồ hiện tại là cặp / TF cụ thể đó, bạn phải đồng bộ hóa đầu dữ liệu từ Máy chủ trước khi truy cập vào các đèn / chỉ báo giá trị. Error 4806 when use CopyBuffer () - Chuyên gia cố vấn và tự động giao dịch - Diễn đàn lập trình MQL5 # 10 (20 20 ) Có phải thần bí không ?! Nó là! - Rút tiền - Chỉ báo kỹ thuật - Diễn đàn MQL5 (20 19 ) Truy cập thời gian và chỉ báo / Truy cập dữ liệu - Tham khảo về thuật toán / tự động giao dịch ngôn ngữ cho MetaTrader 5 Đồng bộ hóa dữ liệu máy chủ với cuối dữ liệu - Ký hiệu - Chung - Diễn đàn MQL5 # 2 (20 18
              
              
              
               ) SymbolInfoInteger không hoạt động - Symbols - Chung - Diễn đàn lập trình MQL5 (20 19 )
              

I can give you an example, hope you can help me

  - My ea opens the first transaction of the day at 10 o'clock and closes at 11 o'clock

- use the signal I programmed for ea to trade and close the deviation with take profit

- after my ea completes that first trade gap and after that if there is any other trade signal the ea will not open any more that day

what i mean is to only allow ea to trade 1 order only on the first signal and then stop and start another trade the next day

William Roeder
27511
William Roeder  
Hong Tien Le #: I can give you an example, hope you can help me

Help you with what? You didn't ask a question.

Hong Tien Le #: what i mean is to only allow ea to trade 1 order only on the first signal and then stop and start another trade the next day

Remember the current date when you open. Do not open if the current date is still the same. Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)