FLATBEFORE

Category: ProBacktest

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.

Syntax:

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.

Example:

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.

Additional Information:

  • This instruction is crucial for strategies that need to be constrained to specific trading hours, such as avoiding overnight risk or trading only during specific market hours.
  • It is important to note that the FLATBEFORE parameter does not pause the strategy; it only prevents the execution of trades and cancels orders before the specified time. The strategy will continue to run and can execute trades again after the specified time.

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.

Related Instructions:

  • FLATAFTER probacktest
  • Logo Logo
    Loading...