
In order to optimize the robot based on the "start and end trading time" parameters, you need to:
1. Add the necessary fields of the StrategyParameterInt type.

The StrategyParameterTimeOfDay parameter is not suitable for optimization. It can only be used in the tester and real trading.
2. Create these parameters in the robot's constructor.

3. In the candle completion event.

1. Create a variable of type int, passing it the start time of the new candle hour.
2. Create a condition. If the start time or end time from the parameters does not match the start time of the new candle hour, then proceed to the position closing method and exit the event.
4. Position closing method:

1. Check that the position does not have a status of "closing" or active orders to close.
2. Close at the market price.
The ClosePosition() method is an additional method for closing a position if necessary.
Link to the robot on GitHub: https://github.com/AlexWan/OsEngine
If you have any difficulties or questions, please write to the support chat. Link