The FLATBEFORE instruction in ProBuilder language is used to manage trading operations by automatically closing all open positions and canceling all pending orders before a specified time. This function is particularly useful for traders who want to ensure that no positions are held open or orders are pending past a certain time of the day, typically to avoid trading during periods of low liquidity or high volatility.
Defparam FlatBefore = HHMMSS
Where HHMMSS represents the time of day in hours, minutes, and seconds (24-hour format). This time is based on the user’s local time zone.
To ensure that all positions are closed and no new orders are placed before 7:30 AM, you would use the following code:
Defparam FlatBefore = 073000
This line of code should be placed at the beginning of your trading strategy script to ensure that it is evaluated before any trading or order placement logic is executed.
Using FLATBEFORE is an effective way to add a time-based control layer to your automated trading strategy, ensuring that your trading rules align with your risk management preferences.