The following sample is a user defined method created in a separate file used for a custom strategy. This method returns true or false depending if the current bar time is in a valid user define trade time.
1. Tools-->Edit NinjaScript-->Strategy... select UserDefinedMethods
2. From within the NinjaScript Editor, right click and select the menu "Save As..."
3. Enter the name "ValidTradeTime" and press "OK"
4. Add the following code in the NinjaScript Editor
5. From within the NinjaScript Editor, right click and select the menu "Compile"
You have now created the user defined method "ValidTradeTime" that can be used within any custom strategy.
6. From within a custom strategy you can call this user defined method as per the image below.