Urgent Help needed in using Time Function in mt4

 

This is the OrderClose

2020.01.06 01:15:16.766 2019.11.04 18:34:48  Square UP ONLY ONE ORDER GBPUSD.uk+,M1: Order Close Time2019.11.04 18:34:48





The the line get the Order Close Time from the Chart highlighted above

I want to update this Order Close Time of 18:34 to all the StopTime Below

        extern string  Monday_StopTime   = "24:00";// End Trade Time

        string var1=TimeToStr(dtrmProfitLastTrade(),TIME_MINUTES);

        

        
        if(DayOfWeek()==1) {Monday_StopTime==var1;} 
        if(DayOfWeek()==2) {Tuesday_StopTime==var1;}
        if(DayOfWeek()==3) {Wednesday_StopTime==var1;}
        if(DayOfWeek()==4) {Thursday_StopTime==var1;}
        if(DayOfWeek()==5) {Friday_StopTime==var1;}


Basically i want to stop the EA after 10% Profit for that day and to stop trading for that day.

start over the next day.  Once the trades is closed on profit for that day no further trading. it should not next day only.

i want to update the extern String Monday_StopTime to var1 (Last Order Close time when taking that days profit)


var1 out is

2020.01.06 01:15:16.766 2019.11.04 18:34:48  Square UP ONLY ONE ORDER GBPUSD.uk+,M1: Last Order Close Time 18:34


Thanks in advance. I want to update this 18:34 to Monday_StopTime


please guide me with the code.





 

I am not sure what you are asking but

 if(DayOfWeek()==1) {Monday_StopTime==var1;} 

is wrong. It should be

 if(DayOfWeek()==1) {Monday_StopTime=var1;} 
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. And since (usually) trading is Monday (1) to Friday (5) your code can be replaced with StopTime=var1;
  3. Don't hard code numbers (1 … 5) Use proper enumerations MONDAY … FRIDAY
 
Keith Watford:

I am not sure what you are asking but

is wrong. It should be

I want to close all open trades on achieving daily profit of $10. For example it achieves daily profit on Monday which DayOfWeek(1) it should stop further trading on the same day. Start trading next day which Tuesday DayOfWeek(2). 

So I want update last order close time to Monday_StopTime which is DayOfWeek(1). It will wait DayofWeek(2) to start trading again.

Updating the closing time is want I am looking for. Thanks in advance
 
Vijay Akash T P:
I want to close all open trades on achieving daily profit of $10. For example it achieves daily profit on Monday which DayOfWeek(1) it should stop further trading on the same day. Start trading next day which Tuesday DayOfWeek(2). 

So I want update last order close time to Monday_StopTime which is DayOfWeek(1). It will wait DayofWeek(2) to start trading again.

Updating the closing time is want I am looking for. Thanks in advance

Not tested, but I think this is one possible way:


// Global variables (or static, if you place them in OnTick()
string lastClose = "";
int lastDOW = 0;

// Within your OnTick()
int currDOW = DayOfWeek();

if (lastDOW!=currDOW && lastClose!=
"")
   lastClose = "";

if (lastClose=="")
{
   // Do whatever necessary to open / close trades.
   // Just remember to set lastClose when you close due to a 10% profit.

   ...
}
 
Seng Joo Thio:

Not tested, but I think this is one possible way:

I found another way. I just updated trade allowed time with ClodeOrderTime(). As and when the daily target achieved I update last closeordertime to trade stop time. 
Reason: