Please help with one trade per day code

 

Hello Guys

I want my EA to open only one trade per day.I do not know what code to use.Please help me if you know.،Thanks aLot

 
Mojtaba Rahimi:

Hello Guys

I want my EA to open only one trade per day.I do not know what code to use.Please help me if you know.،Thanks aLot

It is possible when coded the way within the EA

 
You can use the daily candle open time.
 
  1. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              New candle - MQL4 programming forum #3 2014.04.04

    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum 2011.05.06

  2. For a new day just substitute date for time.
    void OnTick(){
       static datetime curDate=0; datetime preDate=curDate; curDate=date(); if(curDate != preDate) OnNewDay();
       ⋮
              Find bar of the same time one day ago - MQL4 programming forum 2017.10.06
  3. You could also use D1 timeframe, but then you have to deal with 4066/synchronization issue.

Reason: