How to restrict code execution to certain hours of the day

Hello guys,
Here is a nice knowledge base article, showing how to restrict trades to certain hours.
But I am trying to limit code execution:

OpenTime 	= 094800;
if ( TimeNum() >= OpenTime )
	StaticVarSet("LongEntryPrice", currentPrice);
	StaticVarSet("LongPosHold", 1);

And getting an error:

Error 6. Condition in IF, WHILE, FOR statements has to be Numeric or Boolean type. You can not use array here, please use [] (array subscript operator) to access array elements

As I understand (TimeNum() >= OpenTime) returns array with times for each bar. But I only need the current bar TimeNum value..
How would I go about this?

Thank you

You need to checkout Lastvalue function here

so it will be something like this

1 Like

Thank you!
I've used LastValue() before, but I'd not guessed that it can work together with TimeNum() the way you've suggested.