How to launch orders immediatly and not waiting for the end of the bar?

FAQs - Category: Backtest

By default, ProRealTime executes trading orders only at the close of each bar because it reads and processes the strategy code once per completed bar. This behavior can create delays in order execution, preventing real-time reactions to price movements. The main reasons for this issue are:

  1. ProRealTime’s Code Execution Logic – The platform evaluates the strategy only once per bar, meaning orders are executed at the next bar’s open by default.
  2. Market Orders vs. Pending Orders – If using market orders, they will be executed at the next available bar open, causing a delay.
  3. No Intrabar Execution – Standard strategies do not track price movements within a single bar, limiting precision.

Solution

To execute orders immediately without waiting for the bar to close, you can use two effective approaches:

1. Use Pending Orders at a Predefined Price

Instead of placing market orders, use STOP or LIMIT orders to enter trades as soon as price conditions are met:

<code class="!whitespace-pre language-pseudocode">BUY 1 CONTRACT AT 1500 STOP
SELLSHORT 1 CONTRACT AT 1490 STOP

  • STOP orders trigger when the price reaches the specified level.
  • LIMIT orders ensure you don’t buy above or sell below a set price.
  • These orders remain active within the bar and get executed as soon as the conditions are met.

2. Use the TIMEFRAME Instruction for Intrabar Execution

Another way to get faster execution is to use a lower timeframe inside a strategy running on a higher timeframe. This method allows you to execute orders intrabar without waiting the bar to close:

TIMEFRAME(1 hour) // define the strategy indicator
ma = average[20]
TIMEFRAME(default) // Executes trades within the current bar on the current inferior timeframe
IF close crosses over ma THEN
BUY 1 CONTRACT AT MARKET
ENDIF
  • This technique allows order execution inside the bar, using real-time price variations from a lower timeframe while keeping analysis based on a higher timeframe.
Back to FAQs
Logo Logo
Loading...