Stop trading for the whole week - page 2

 
Teddy Odafe #:

Do not start new topics with the same subject.

This is the 2nd time that you have been told. Next time you can expect a ban.

I have deleted your new topic.

 
Teddy Odafe #:
Your code.
Missing false.
if(TimeCurrent()>=waitUntil){ startTrade = true ;}
Simplified.
No false code needed.
startTrade = TimeCurrent()>=waitUntil;
 
William Roeder #:
Your code.
Missing false.
Simplified.
No false code needed.
I think some advance adjustment is needed...
Because it has not work:
See for example: 
If I add d startTrade over d code ..d ea will wait for timecurrent () to exceed or equal to waitUntil. And waitUntil can only occur if the ea is running. 
See below
 If(startTrade)
{ If( ma1>ma2) buy;
   If(ma1<ma2)sell; }
The above can only occur if d below occur.ie
If( eqty < accctbal - loss){
Closeall;
datetime Waituntil = Timecurrent () + 604800;
startTrade = Timecurrent () >= waitUntil; }

If you don't add the If(startTrade) to govern the codes, it continue to open new trade even if you have d waitUntil in closeall condition.
Please help me find a way around this. Thank you

 
Keith Watford #:

Do not start new topics with the same subject.

This is the 2nd time that you have been told. Next time you can expect a ban.

I have deleted your new topic.

Sorry, though can't remember when I said as first told... except for this one
 
William Roeder #:

Not tested, not compiled, just typed.

Not tested, not compiled, just typed.

See also

  1. Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
  2. Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
  3. date/time (2017)
  4. Find bar of the same time one day ago - MQL4 programming forum (2017)

Don't double post! You already had this thread open.
          General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)

Pretty complex ways I see here.  Not sure if a #defined value is required in your code. 


To start at the beginning of the 7th day

iTime(_Symbol, PERIOD_D1, 0) + PeriodSeconds(PERIOD_D1) * 7;

OR

iTime(_Symbol, PERIOD_D1, 0) + PeriodSeconds(PERIOD_W1) ;
 
Leon Clifton Gaines #: Pretty complex ways I see here . To start at the beginning of the 7th day iTime(_Symbol, PERIOD_D1, 0) + PeriodSeconds(PERIOD_D1) * 7;

You could also use D1/W1 timeframe, but then you have to deal with 4066 / synchronization issue; just as complex.

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 - MQL4 programming forum - Page 3 #26.4 (2019)

 
William Roeder #:

You could also use D1/W1 timeframe, but then you have to deal with 4066 / synchronization issue; just as complex.

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 - MQL4 programming forum - Page 3 #26.4 (2019)

I've never ever experienced what you mentioned on MT4.  What you linked to is referring to referencing historical data.  We are not referencing historical data,  We arent even referencing the current bars data, except for Time. Data is loaded from current bar first and backwards.   We are just using the value of PERIOD_D1 to calculate the number of seconds we need to add to the current bar time to calculate a FUTURE date value. 


  I use this all the time.  Here's the pseudocode

 

datetime restriction_lift_date;



bool isTradeRestricion(){

if (Time[0] >= restriction_lift_date) {return false; else return true;}

}





void AddTradeRestriction(period, periodMultiplier)

{

restsriction_lift_date = iTime(_Symbol, period, 0) + PeriodSeconds(period) * periodMultiplier;

}

 
Leon Clifton Gaines #: I've never ever experienced what you mentioned on MT4.

Make a script that will read D1 data. Stop the terminal. Delete the D1 history files. Start the terminal. Run the script on any other timeframe.

Just because you haven't seen it doesn't mean it doesn't occur. Other charts stop updating ten (10) minutes after last access.

 
Leon Clifton Gaines #:

I've never ever experienced what you mentioned on MT4.  What you linked to is referring to referencing historical data.  We are not referencing historical data,  We arent even referencing the current bars data, except for Time. Data is loaded from current bar first and backwards.   We are just using the value of PERIOD_D1 to calculate the number of seconds we need to add to the current bar time to calculate a FUTURE date value. 


  I use this all the time.  Here's the pseudocode


datetime restriction_lift_date;


bool isTradeRestricion(){

if (Time[0] >= restriction_lift_date) {return false; else return true;}

}



void AddTradeRestriction(period, periodMultiplier)

{

restsriction_lift_date = iTime(_Symbol, period, 0) + PeriodSeconds(period) * periodMultiplier;

}

Good day Leon, I am delighted have your assistance. I have been try to make use of the solution which seem great but still having little challenges. 
Please can I see one of d bot you use this on. Please and please 
Thank you as I await you.

 
Your code
bool isTradeRestricion(){
   if (Time[0] >= restriction_lift_date) {return false; else return true;}
}
Simplified
bool isTradeRestricion(){
   return Time[0] < restriction_lift_date;
}
          Increase Order after stoploss - MQL4 programming forum #1.3 (2017)
Reason: