From Strategy To Broker MP Synchronizer

From MultiCharts
Jump to navigation Jump to search

Definition

From Strategy To Broker MP Synchronizer signal is used to synchronize MultiCharts position and the broker position. This can be useful in cases when you auto trade in Asynchronous mode (AA mode) or combine manual trading and auto trading on the same instrument. To synchronize positions, MultiCharts will send a real order to broker using PlaceMarketOrder keyword.

On each strategy calculation, the signal compares chart position with broker position. If the difference between these two positions is detected, TimeOutMS timer starts counting down. If by the end of the specified period the positions don’t get equal, then PlaceMarketOrder will be sent by the auto trading system. This event will activate the next timer specified in LatencyMS input. LatencyMS determines how much time to wait before the next synchronization. If during the period specified for LatencyMS the PlaceMarketOrder is not filled, the synchronizing signal sends another order. If the broker position is bigger than chart position in MultiCharts, the signal will send a buy order. Conversely, MultiCharts will send a sell order. The price of the order will be equal to the difference between broker position and chart position.

By default, the IOG mode is enabled.

How to set timeouts

1) Use Print statement in your script to output computer time in ms and three market positions: (MarketPosition, MarketPosition_at_Broker, MarketPosition_at_Broker_for_The_Strategy);
2) Use Print statement in your script to output computer time in milliseconds and the fact of execution of PlaceMarketOrder command.

Default Inputs

TimeOutMS sets the first timeout (in ms) that must be expired before the first synchronizing order is generated, 1000 by default.
The TimeOutMS value shouldn’t be less than the difference between the value from Order and Position Tracker -> Orders tab -> Filled/Cancelled column and the last market position change printed out to the Output for MarketPosition_at_Broker. At the same time, this parameter shouldn’t be bigger than the interval between sending orders to the broker (otherwise, the Synchronizer can go into the resonance).

LatencyMS sets the second timeout (in ms) that must be expired before the second synchronizing order is generated, 1000 by default.
The LatencyMS value shouldn’t be less than the difference between the time of generating PlaceMarketOrder and its execution. However, this time value shouldn’t be too big, because it corresponds to the period when the Synchronizer stays inactive after sending the synchronizing order.

Note: The first timeout (TimeOutMS) will not immediately change the chart position.