Event recalculations
Last updated
Last updated
Functionality is supported with enabled Recalculation Interval in "Interval (For Events)" script properties.
With other recalculation intervals, when an event occurs and there is a position, the position is not tied to the bar. Therefore, no orders will be placed that close the position inside the position entry bar.
When trading, sometimes you need to make an additional recalculation. Most often, this is required when you need to place a stop-loss on an opened position within the current bar. It is also required when working with multiple (two or more) instruments, for example, in arbitrage trading. Where the specificity is the simultaneous entry into multidirectional positions.
Events can be configured in the agent's trading settings. Trading -> Autotrading Control Center -> Trade Settings
When one of the events occurs, a Single recalculation of the agent is performed. Events are understood as operations of a broker or exchange with an order during the execution of a transaction or general events related to the program
Order rejected
The broker (or exchange) rejected the application
Order filled
There were trades on the market that satisfied the entire requested volume in the order
Order canceled
On the recalculation of the agent, the script calculated that there was no signal, the request must be canceled. The program sends a command to the broker. This event is the result of a "Order Canceled" response from the broker.
Order quantity changed
In the Agent, on the main recalculation, the script calculated the change in the number of lots, which differs from the previous one.
Position opened
The signal was executed, the program received the numbers: Transaction, Order, Deals. All numbers are tied to the agent's signal through the portfolio number.
Position closed
The signal to close the position has been executed. The position opening portfolio number has the filled position closing portfolio number.
Trading is started
Received a status from the exchange that trading is open. Most often, the program uses the first deal of the market. The start of trading is determined by the first quote of the current day, since it is almost always faster than the trading status that the exchange sends for the instrument.
Trading is stopped
Received a status from the exchange that trading has been stopped.
Bar closed, not trades
The bar closed according to server time, but there are no new deals
In the editor, you can additionally use the "Event" block.
On this recalculation, if an event occurred, the block will return true, this value can be used in the algorithm. If many* events arrive at once in one agent, a single recalculation is performed.
*A lot at once - 5ms hardcode. If several events occur within 5ms, the recalculation call will be single.
In the block, you can select an event from the drop-down list. The block can be used in the editor many times, the block is connected to the source, it sends an event to the instrument.