If you want the default to be the current time, why use an external variable?
If it is an extern, you can simply change the value to TimeCurrent() in init, then it will reset every time it is initialized. If you don't want it to reset when changing chart time-frame you will have to set other conditions as well.
extern datetime Next_News=0;
if(TimeCurrent() >= Next_News) ...
//---- input parameters
extern int Slippage = 50;
Hi, thanks guys. Maybe I need to be clearer. So when I run this, I almost always am setting a time very soon in the future. I never want it to actually use the current time, but when I go in to set the variable, I don't want to have to change date/month/hour etc. It's usually just minutes that I want to change. Maybe GumRai provided a solution that would do this, but I don't quite understand it. I am also not sure if it's possible, but I hope so.
An easier option may be to just add a number of minutes to the current time when the EA is initiated
extern int Plus_Minutes=5;
Trade_Time=TimeCurrent() + ((Plus_Minutes*60);
Of course this will be reset if you change time-frames or re-initialize for any other reason.
I don't like this as a solution.
My EA takes in 6 times, which is essential for its operation. Each time requires the date as well, so every time I run/test it I have to re-enter all six dates plus the specific times I want.
That's just not on.
So I thought of another solution.
I accept that the date can always be today's date. Get the times in string format (e.g. "13:25"), and then include this function in the program:
datetime TimeOnlyConvert(string usertime)
string datestring=IntegerToString(vyy)+"."+IntegerToString(vmm)+"."+IntegerToString(vdd)+" "+usertime;
Now for every time input (only the time) in text format, you can get an accurate datetime variable to use in the program.
Or much simpler:
datetime dtEvent = StrToTime("13:25"); // Returns the current date with the given time