subtract three minutes to the current time
how can I subtract 3 minutes to the current time?
I'm doing some tests with writing on my data files, but I have some problems....This is my code:
string var2= TimeToString(var1,TIME_DATE|TIME_MINUTES);
datetime time_alert;
extern bool Audible_Alerts = true;
double myPoint;
void myAlert(string type, string message)
{
int handle;
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | RSIlevel "+Symbol()+","+Period()+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
else if(type == "RsiLevel")
{
handle = FileOpen("RSIlevel.txt", FILE_TXT|FILE_READ|FILE_WRITE|FILE_SHARE_READ|FILE_SHARE_WRITE, ';');
if(handle != INVALID_HANDLE)
{
FileSeek (handle, 0, SEEK_END);
FileWrite(handle, type+ "|" +Symbol()+ "," +var2+ "|"+message);
FileClose(handle);
}
}
}
The problem is that even by varying the seconds value to be subtracted from TimeCurrent, the final risltato is wrong. I do not understand why.
I think the mistake is to refresh, the first compilation of the code, the time is right, in the following signals, the time remains the same as the first.
tips to solve?
I should have solved including the variables within the function, confirmed to me that it's all written politely well?
{
datetime var1= TimeCurrent() - 120;
string var2= TimeToString(var1,TIME_DATE|TIME_MINUTES);
int handle;
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | RSIlevel "+Symbol()+","+Period()+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
else if(type == "RsiLevel")
{
handle = FileOpen("RSIlevel.txt", FILE_TXT|FILE_READ|FILE_WRITE|FILE_SHARE_READ|FILE_SHARE_WRITE, ';');
if(handle != INVALID_HANDLE)
{
FileSeek (handle, 0, SEEK_END);
FileWrite(handle, type+ "|" +Symbol()+ ","+Period()+ ","+var2+ "|"+message);
FileClose(handle);
}
}
}
I should have solved including the variables within the function, confirmed to me that it's all written politely well?
Inspired by the code in the documents, so I can go back to the current time:
how can I subtract 3 minutes to the current time?
I tried to write the code so it does not work