Trouble with Time

Good day, I’m attempting to apply a condition within a script which displays as a ShowBar. Spent quite a few hours with ScriptBot and don’t get any output.
The basic script is:

// Get the current time
CurrentTime = TIME();
// Define the time range
StartTime = 18; // 6 PM in 24-hour format
EndTime = 3; // 3 AM in 24-hour format

// Check if the current time is between 6 PM and 3 AM
IsInTimeRange = (CurrentTime >= StartTime OR CurrentTime <= EndTime);

The data is intraday from OANDA.
I’ve tried plotting the current time but no output.

Can anyone see what the issue with this might be?

Thank you
Steve

Hi Steve,

You have to take the script bot outputs with a grain of salt.
I am 99% sure there is no TIME() function. If the script manager doesn’t show you it in the little popup search window, it generally doesn’t exist.
Also, check Optuma Scripting Functions Table.

You can use BARDATE() instead. BarDate and StringDate Functions.

It will return a floating point number of [bardate].[FractionOfDay]

so if you do something like this it should work

//Get dateTime
BD = BARDATE();

//use BD MOD 1  to get the decimal on its own
CurrentTime = MOD(BD, 1);


// Define the time range
StartTime = 18/24; // 6pm in fraction of a day
EndTime = 3/24; // 3 AM in fraction of a day

// Check if the current time is between 6 PM and 3 AM
IsInTimeRange = (CurrentTime >= StartTime OR CurrentTime <= EndTime);

IsInTimeRange; 

I don’t have intraday data, so I can’t test it but that should get you on the right track.

Thank you Angus. Yes as with any new tool ScripterBot will take some getting used to. How gullible I am :-). Many thanks.

Steve