Auto Trading: Difference between revisions
No edit summary |
|||
(46 intermediate revisions by 10 users not shown) | |||
Line 10: | Line 10: | ||
With Order Confirmation selected, each time that one or more orders are generated, a '''New Order''' dialog box displaying the orders will appear in the center of the desktop. To confirm order transmission, click '''Transmit Orders''', and to prevent order transmission, click '''Ignore Orders'''. | With Order Confirmation selected, each time that one or more orders are generated, a '''New Order''' dialog box displaying the orders will appear in the center of the desktop. To confirm order transmission, click '''Transmit Orders''', and to prevent order transmission, click '''Ignore Orders'''. | ||
* When more than one order is displayed in the '''New Order''' dialog box, it is not possible to transmit one order and ignore another; | * When more than one order is displayed in the '''New Order''' dialog box, it is not possible to transmit one order and ignore another; either all of the orders are transmitted, or all of the orders are ignored. | ||
* If neither '''Transmit Orders''' or '''Ignore Orders''' is selected before a new Market order or set of Market orders is generated, or before a new bar is started, the previous order or set of orders is ignored and not sent to the execution gateway. | * If neither '''Transmit Orders''' or '''Ignore Orders''' is selected before a new Market order or set of Market orders is generated, or before a new bar is started, the previous order or set of orders is ignored and not sent to the execution gateway. | ||
<br><div style="background-color: #E3FBE5;">Note: Order transmission confirmation affects only the transmission of the strategy order to the execution gateway; once the order has been transmitted, execution of the order by the broker is subject to market conditions.</div> | <br><div style="background-color: #E3FBE5;">Note: Order transmission confirmation affects only the transmission of the strategy order to the execution gateway; once the order has been transmitted, execution of the order by the broker is subject to market conditions.</div> | ||
<br> | <br> | ||
Line 33: | Line 19: | ||
=== Optimize Order Flow === | === Optimize Order Flow === | ||
If One-Cancel-Others group is emulated in MultiCharts the situation when more than one order is filled is possible | If One-Cancel-Others group is emulated in MultiCharts the situation when more than one order is filled is possible. | ||
One Cancels Other (OCO) orders are the price orders sent in a group. When any of OCO orders is filled or partially filled, the system cancels or reduces size of other orders in this OCO-group. | One Cancels Other (OCO) orders are the price orders sent in a group. When any of OCO orders is filled or partially filled, the system cancels or reduces size of other orders in this OCO-group. | ||
Line 62: | Line 48: | ||
<br> | <br> | ||
=== Cancel Market Orders | === Cancel Expired Market Orders After X Seconds === | ||
Market orders that were not filled within the specified time (30 seconds by default) will be canceled. | |||
<div style="background-color: #E5F6FF;">'''Example''': | <div style="background-color: #E5F6FF;">'''Example''': Default 30 second timeout is set;<br>12:00:00 Strategy Calculation at close of bar # 51 - place market order to buy at open of next bar;<br>12:00:01 Strategy Calculation at open of bar # 52 - market order to buy is placed at broker;<br>12:00:10 Strategy Calculation at close of bar # 52 - no market order to buy at open of next bar should be placed;<br> Default 30 second countdown starts:<br>12:00:40 - market order is cancelled.</div> | ||
<br> | <br> | ||
Line 74: | Line 60: | ||
<br> | <br> | ||
=== Stop auto | === Stop auto trading if final status of an order is not received === | ||
There is a possibility of a situation when broker's API loses the order and does not send the status for it at all or sends it with a big delay. | There is a possibility of a situation when broker's API loses the order and does not send the status for it at all or sends it with a big delay. | ||
MultiCharts waits for the order status for 60 seconds by default (60 seconds between MultiCharts asking for the order status and receiving or not receiving the order status). If no feedback is provided for the order within 60 seconds by the broker - this order is considered to be cancelled/no longer present at the broker. In such situation the message '''“Didn’t receive final status for order”''' appears in the Order and Position Tracker window Logs tab. If the order was cancelled but the order generation conditions are still valid in the code – the signal generates the order and sends it to the broker again while the order generation conditions are met in the code. If the previous order (lost by the API/not sent to MC) is still active – an overfill is possible. | MultiCharts waits for the order status for 60 seconds by default (60 seconds between MultiCharts asking for the order status and receiving or not receiving the order status). If no feedback is provided for the order within 60 seconds by the broker - this order is considered to be cancelled/no longer present at the broker. In such situation the message '''“Didn’t receive final status for order”''' appears in the Order and Position Tracker window Logs tab. If the order was cancelled but the order generation conditions are still valid in the code – the signal generates the order and sends it to the broker again while the order generation conditions are met in the code. If the previous order (lost by the API/not sent to MC) is still active – an overfill is possible. | ||
When this option is enabled the auto | When this option is enabled the auto trading will be automatically turned off once the final status for an order sent by this strategy is not received. This option does not manage the open position/active orders. By default this option is disabled. | ||
<br> | <br> | ||
=== Stop auto | === Stop auto trading after X rejected orders === | ||
When enabled the auto | When enabled the auto trading will be automatically turned off after the specified number of the strategy orders is rejected. By default this option is disabled. | ||
<br> | <br> | ||
=== | === Price Order Emulation === | ||
It is possible to switch between native and emulated Stop, Limit and Stop-Limit orders in both auto trading and manual trading. This feature requires realtime data subscription on your broker account. When a Stop/Limit order is emulated - once the Stop/Limit price level is reached by the corresponding Ask/Bid or Trade prices, a market/limit order is sent to the broker correspondingly. When a Stop-Limit order is emulated - once the Stop price level is reached by the corresponding Ask/Bid or Trade prices, a Limit order is sent to the broker. In case Stop, Limit and/or Stop-Limit order emulation is enabled - the emulated OCO group is used, disregard the broker profile/auto trading broker plugin settings. | |||
When | |||
In case Stop and/or Stop-Limit order emulation is enabled - the emulated OCO group is used, disregard the broker profile/ | |||
To enable the Stop, Limit or Stop-Limit order emulation for automated trading select '''Emulate locally using Bid/Ask''' or '''Emulate locally using Trade''' from the dropdown list next to the corresponding order type. Leave the settings to '''Use native''' if using price order emulation is undesirable. | |||
In order to apply the changes one needs to disconnect the broker profile and reconnect it. | |||
<br> | <br> | ||
=== | === Self-Adaptive Trading === | ||
Check the Enable box to run periodic re-optimization of the strategy on new data. | |||
See the [[Self-Adaptive Trading]] page for more info. | |||
=== Unfilled Strategy Order Replacement === | === Unfilled Strategy Order Replacement === | ||
With the help of these options one can have unexecuted entry/exit price orders converted into market orders when the specified timeout is exceeded or upon bar close. | With the help of these options one can have unexecuted entry/exit price orders converted into market orders when the specified timeout is exceeded or upon bar close. | ||
The timer is launched depending on the option “Get | The timer is launched depending on the option “Get Real-Time Data from” and the mode of auto trading. | ||
* when set to “Broker”, the timer starts when the price at the broker touches the order’s price; | In '''SA''' mode: | ||
* when set to “Chart”, the timer starts when the order price is hit on a chart. | * when set to “Broker”, the timer starts when the '''price at the broker''' touches the order’s price; | ||
* when set to “Chart”, the timer starts when the order price is hit '''on a chart'''. | |||
Operation of these options depends on the [[Signal Settings#Intra-Bar Order Generation|Intra-Bar Order Generation (IOG)]]: | Operation of these options depends on the [[Signal Settings#Intra-Bar Order Generation|Intra-Bar Order Generation (IOG)]]: | ||
# IOG disabled - if the timer has started but the bar closed faster than timeout exceeded, then the price order is converted into a market order without waiting for the timeout to exceed; | # IOG disabled - if the timer has started but the bar closed faster than timeout exceeded, then the price order is converted into a market order without waiting for the timeout to exceed; | ||
#IOG enabled - each new tick is considered to be bar close. If the order’s price is touched and new tick comes in – the price order will be converted into market order at once without waiting for the timeout to exceed. | #IOG enabled - each new tick is considered to be bar close. If the order’s price is touched and new tick comes in – the price order will be converted into market order at once without waiting for the timeout to exceed. | ||
<div style="background-color: #E3FBE5;">'''Note''': If the order price is not hit at broker/chart then the order will not be converted.</div> | <div style="background-color: #E3FBE5;">'''Note''': If the order price is not hit at broker/chart then the order will not be converted.</div> | ||
<br> | |||
In '''AA''' mode conversion will start when an order is filled on a chart. | |||
The conversion algorithm is the following: | |||
# The Auto trading engine system receives an order filling event on the chart. | |||
#* If an identical order is now placed on the broker, the timer for conversion is launched. | |||
#* If this order is not placed on the broker yet, MultiCharts remembers that on this bar it is necessary to convert this particular order. | |||
# The Auto Trading engine places an order that needs conversion. The timer for conversion is launched. | |||
=== Partially Filled Orders Replacement === | |||
When these options are enabled the unfilled part of partially filled price order will be cancelled and the remainder will be converted into a market order when the specified timeout is exceeded, or upon bar close. The timer is launched on the first partial fill event. | |||
<div style="background-color: #E3FBE5;">'''Note''': When timeout is set to 0, the order will be cancelled and replaced with a market order once partial fill event occurs.</div> | |||
<br> | <br> | ||
Line 121: | Line 117: | ||
# When Market Position Changes. | # When Market Position Changes. | ||
# When an Order is Filled. | # When an Order is Filled. | ||
# When an Order is Rejected. | |||
<div style="background-color: #E3FBE5;">'''Note 2''': If strategy generates '''both entry and exit orders at the same time when there is no market position opened''', only the entry order will be sent. When the market position is opened, the exit orders will be placed intrabar even without enabled [[Signal Settings#Intra-Bar Order Generation|Intra-Bar Order Generation (IOG)]], no matter if this feature is used or not.</div> | <div style="background-color: #E3FBE5;">'''Note 2''': If strategy generates '''both entry and exit orders at the same time when there is no market position opened''', only the entry order will be sent. When the market position is opened, the exit orders will be placed intrabar even without enabled [[Signal Settings#Intra-Bar Order Generation|Intra-Bar Order Generation (IOG)]], no matter if this feature is used or not.</div> | ||
<br> | <br> | ||
Line 127: | Line 123: | ||
=== Get Real-Time Data from === | === Get Real-Time Data from === | ||
This option affects special orders monitoring and defining the moment to convert price orders into market ones. | This option affects special orders monitoring and defining the moment to convert price orders into market ones. | ||
<div style="background-color: #E3FBE5;">'''Note''': Special trailing stop order ('' | <div style="background-color: #E3FBE5;">'''Note''': Special trailing stop order (''SetDollarTrailing'') will be calculated based on the distance from the entry price order to the real-time price. The entry price is defined by the broker. In MC this price is the real price of order fill. It doesn't depend on trading mode or the source of real time.<br>''i_OpenEquity'', ''OpenPositionProfit'' keywords are not affected by this option, they are always calculated from chart prices.</div> | ||
<div style="background-color: #E5F6FF;">'''Example''': | <div style="background-color: #E5F6FF;">'''Example''': | ||
Auto trading mode is Async. (see [[Understanding Automated Trade Execution]]), Get Real-Time from Chart is selected, there is an executed entry and a trailing stop is sent. The trailing order price is calculated based on the entry order fill price at the broker and the real-time price from the chart.</div> | |||
# From Broker: Asks and Bids are taken from the connected broker. | # From Broker: Asks and Bids are taken from the connected broker.<div style="background-color: #E3FBE5;">'''Note''': '''From Broker''' option is not available for asynchronous mode [AA]</div> | ||
# From Chart: depends on the BackTesting Mode:<BR> | # From Chart: depends on the BackTesting Mode:<BR> | ||
::a) If it is Classic Backtesting, then the data is taken from the data series 1;<BR> | ::a) If it is Classic Backtesting, then the data is taken from the data series 1;<BR> | ||
Line 140: | Line 136: | ||
=== Mode Selection === | === Mode Selection === | ||
* In '''synchronous''' mode '''[SA]''' one can see the same open market position and active orders on the chart as at broker. All orders generated by historical calculation during are wiped out from the chart when auto execution is turned on. Executed order is displayed only if it has been executed at broker and the final status of the order has been received by MultiCharts. To use synchronous mode for auto trading select '''Entries/Exits are based on the execution confirmation by the broker (Sync)'''<br> <div style="background-color: #E3FBE5;">'''Note''': Chart market position and broker market position are in synch only if no more than one chart is auto trading without any manual orders on a particular symbol connected a particular broker account, assuming that at the moment the automation was turned the broker market position was flat or, if it was not flat at broker, assigned manually on start of auto trading in MC to match it (see [[#Assign_the_Initial_Market_Position_at_the_Broker_Settings|Assign the Initial Market Position at the Broker Settings]]). If more than 1 chart is auto trading in [SA] mode and/or manual trading is used as the same time on the same symbol at broker, chart can easily get out of synch. To learn more, see [[Trading from Multiple Charts on One Instrument]].</div><br> | * In '''synchronous''' mode '''[SA]''' one can see the same open market position and active orders on the chart as at broker. All orders generated by historical calculation during Backtesting are wiped out from the chart when auto execution is turned on. Executed order is displayed only if it has been executed at broker and the final status of the order has been received by MultiCharts. To use synchronous mode for auto trading select '''Entries/Exits are based on the execution confirmation by the broker (Sync)'''<br> <div style="background-color: #E3FBE5;">'''Note''': Chart market position and broker market position are in synch only if no more than one chart is auto trading without any manual orders on a particular symbol connected to a particular broker account, assuming that at the moment the automation was turned the broker market position was flat or, if it was not flat at broker, assigned manually on start of auto trading in MC to match it (see [[#Assign_the_Initial_Market_Position_at_the_Broker_Settings|Assign the Initial Market Position at the Broker Settings]]). If more than 1 chart is auto trading in [SA] mode and/or manual trading is used as the same time on the same symbol at broker, chart can easily get out of synch. To learn more, see [[Trading from Multiple Charts on One Instrument]].</div><br> | ||
* In ''' asynchronous ''' mode ''' [AA] ''' the strategy on the chart starts auto trading based on the historically calculated orders and open position, displaying all generated by the script orders on chart even if an order was not executed at broker. In AA strategy on chart acts separately from broker.<br>To use asynchronous mode for auto trading select '''Entries/Exits are independent of the execution status at the broker (Async)''' | * In ''' asynchronous ''' mode ''' [AA] ''' the strategy on the chart starts auto trading based on the historically calculated orders and open position, displaying all generated by the script orders on chart even if an order was not executed at broker. In AA strategy on chart acts separately from broker.<br>To use asynchronous mode for auto trading select '''Entries/Exits are independent of the execution status at the broker (Async)''' | ||
Line 146: | Line 142: | ||
====Understanding Strategy Calculation in Different Modes==== | ====Understanding Strategy Calculation in Different Modes==== | ||
There are 3 separate market positions when strategy is auto | There are 3 separate market positions when strategy is auto trading in MultiCharts: | ||
# '''Broker position'''. This is '''net position for a traded security at your broker account''' that takes into consideration all trades. It can be seen on [[Order and Position Tracker#Open Positions Tab| Open Positions tab of Order and Position Tracker]]. | # '''Broker position'''. This is '''net position for a traded security at your broker account''' that takes into consideration all trades. It can be seen on [[Order and Position Tracker#Open Positions Tab| Open Positions tab of Order and Position Tracker]]. | ||
# '''Auto | # '''Auto trading engine position'''. This is '''inner position of the strategy on a specific chart''' calculated by the software. It can be seen on [[Order and Position Tracker#Strategy Positions tab| Strategy Positions tab of Order and Position Tracker]]. | ||
# '''Chart position'''. This is the '''position generated by orders visually executed on chart'''. It has nothing to do with open position horizontal drawing shown when you open [[Chart Trading]] panel. | # '''Chart position'''. This is the '''position generated by orders visually executed on chart'''. It has nothing to do with open position horizontal drawing shown when you open [[Chart Trading]] panel. | ||
When you auto trade '''in SA (sync. mode) the 2 and 3 are the same''', what | When you auto trade '''in SA (sync. mode) the 2 and 3 are the same''', what you see on the chart is synchronized with auto trading engine. When '''you use AA (async. mode), you may have to deal with 3 different positions''': what you have on broker, what you see on chart, what MC thinks it is. | ||
====Market Position Checking Keywords==== | ====Market Position Checking Keywords==== | ||
# [[MarketPosition_at_Broker]]. Returns '''broker position'''. | # [[MarketPosition_at_Broker]]. Returns '''broker position'''. | ||
# [[MarketPosition_at_Broker_for_The_Strategy]]. Returns MC '''auto | # [[MarketPosition_at_Broker_for_The_Strategy]]. Returns MC '''auto trading engine position'''. | ||
# [[MarketPosition]]. Returns '''chart position''' (only direction). | # [[MarketPosition]]. Returns '''chart position''' (only direction). | ||
<br> | <br> | ||
===Assign | ===Assign Initial Market Position to Strategy=== | ||
When auto trading is turned on, a strategy starts working with a specific market position.<br> | |||
Depending on the mode of auto trading, this position can vary. In [SA] mode it is always flat on chart when you turn it on, but in [AA] mode it can be short, flat or long, depending on backtesting trades (to learn more see [[#Mode_Selection|Mode Selection]]).<br> | |||
This option allows to control the initial market position for the strategy to start calculation and order generation with when you turn on auto trading. | |||
The available options are: | |||
* | :* '''Flat ''' - the initial position will be flat.<br> <div style="background-color: #E3FBE5;">'''Example''': According to your backtesting, the current position is 1 contract long and your real broker position is 1 contract short. With this option you will have +1 on your chart, flat for auto trading engine within the software and -1 short at broker, when the automation is turned on. </div> | ||
:* '''From Chart''' - the initial position will be the same as the position on the chart. | |||
:* '''From Broker''' - the initial position will be the same as the actual position at the broker when automation is enabled. | |||
:* '''Always show dialog window''' - to get the dialog every time the automation is enabled, no matter what the strategy position is at that moment.<br> <div style="background-color: #E3FBE5;">'''Note''': It is extremely important for [SA] mode, because it is always flat when automation is turned on in [SA].</div> | |||
:* '''Show dialog window only if market position on chart is different from broker''' - to get the dialog when the chart and broker positions do not match. | |||
=== Set TIF for order types === | |||
* | Select the '''Time in Force (TIF)''' for each order type: | ||
* Market | |||
* Limit | |||
* Stop | |||
* Stop-Limit | |||
< | |||
These controls work as a dropdown list with all TIFs supported in MultiCharts: | |||
* Default (corresponds to the value from the broker plugin settings) | |||
* DAY | |||
* GTC | |||
* GTD (includes the additional control to select the number of days) | |||
* IOC | |||
* FOK | |||
* AON | |||
The list depends on what TIFs are supported by the broker. | |||
The selected TIF values will be used to send orders into the broker plugin. | |||
If the selected TIF is not supported by a broker profile, the value from the [https://www.multicharts.com/trading-software/index.php?title=Auto_Trading#Select_Broker_Plug-in broker plugin settings] will be taken. | |||
<div style="background-color: #E3FBE5;">'''Notes''': | |||
# Some brokers may change TIF on their end – MultiCharts doest not regulate it. | |||
# The described behaviour is ''not applicable'' to backtesting. | |||
</div> | |||
===Select Broker Plug-in=== | ===Select Broker Plug-in=== | ||
Line 218: | Line 235: | ||
* Any strategy parameters are changed | * Any strategy parameters are changed | ||
* Any Auto Trading parameters are changed | * Any Auto Trading parameters are changed | ||
* Connectivity between MultiCharts and the execution gateway has been lost and the disconnection time exceeded the specified acceptable level. | * Connectivity between MultiCharts and the execution gateway has been lost and the disconnection time (of the broker profile) exceeded the specified acceptable level. | ||
* [[Auto_Trading#Stop_auto-trading_if_final_status_of_an_order_is_not_received|"Stop auto trading if final status of an order is not received"]] option has come into effect | |||
* [[Auto_Trading#Stop_auto-trading_after_X_rejected_orders|"Stop auto trading after X rejected orders"]] option has come into effect | |||
* You have got a [[Fail-Watch and Trading System Warnings]] alert | |||
<br> | |||
=== Pending Order Cancellation upon Termination of Auto Trading === | === Pending Order Cancellation upon Termination of Auto Trading === | ||
Latest revision as of 15:55, 7 June 2024
Auto Trading tab
Require Order Confirmation
It is possible to manually confirm or reject strategy order transmission to the order execution gateway. Order Confirmation is set in the Auto Trading tab of the Strategy Properties window: Require Order Confirmation
To learn more, see Setting Up Auto Trading in MultiCharts
With Order Confirmation selected, each time that one or more orders are generated, a New Order dialog box displaying the orders will appear in the center of the desktop. To confirm order transmission, click Transmit Orders, and to prevent order transmission, click Ignore Orders.
- When more than one order is displayed in the New Order dialog box, it is not possible to transmit one order and ignore another; either all of the orders are transmitted, or all of the orders are ignored.
- If neither Transmit Orders or Ignore Orders is selected before a new Market order or set of Market orders is generated, or before a new bar is started, the previous order or set of orders is ignored and not sent to the execution gateway.
Optimize Order Flow
If One-Cancel-Others group is emulated in MultiCharts the situation when more than one order is filled is possible. One Cancels Other (OCO) orders are the price orders sent in a group. When any of OCO orders is filled or partially filled, the system cancels or reduces size of other orders in this OCO-group.
There are two types of OCO-groups in MultiCharts: Native and Simulated.
Native OCO-group is used when the broker’s API supports OCO-groups. In this case all OCO orders are sent to the broker directly and unfilled OCO orders will be cancelled by the broker. (Native OCO-group is supported by Interactive Brokers only).
Simulated OCO-group means that all OCO orders will be sent to the broker, but once one of them is filled, other orders from this OCO group will be cancelled by MultiCharts. In this case, when one of the OCO orders is filled, MultiCharts will send a command to cancel or reduce size of the second OCO order to the broker.
In case of high market volatility there may be not enough time to cancel the order and therefore both orders may be filled. Both orders also may be filled in the unlikely event of crash or connection loss.
Optimize Order Flow optimizes the process of sending orders to broker in order to avoid overfill.
- MC sends 1 stop order and 1 limit order with the prices most likely to be filled.
- When one of these 2 orders is filled, the other is cancelled.
- MC sends 1 stop order and 1 limit order with the prices most likely to be filled (among the rest 2 stops and 2 limits).
- When one of these 2 orders is filled, the other is cancelled.
- MC sends the last 2 orders: 1 stop order and 1 limit order.
- When one of these 2 orders is filled, the other is cancelled.
Cancel Expired Market Orders After X Seconds
Market orders that were not filled within the specified time (30 seconds by default) will be canceled.
12:00:00 Strategy Calculation at close of bar # 51 - place market order to buy at open of next bar;
12:00:01 Strategy Calculation at open of bar # 52 - market order to buy is placed at broker;
12:00:10 Strategy Calculation at close of bar # 52 - no market order to buy at open of next bar should be placed;
Default 30 second countdown starts:
12:00:40 - market order is cancelled.
Audio Alert
If the feature is turned on, it triggers a sound alert when an order placed by a strategy from the chart is filled. Once the box is checked, the File field becomes active and allows you to locate a sound file to play when an order is filled. To select the file, click the "..." button. It is possible to specify if the sound file should be played once or repeated by selecting one of these options below the File field. After the file is specified, one can try it by clicking the Test button.
Stop auto trading if final status of an order is not received
There is a possibility of a situation when broker's API loses the order and does not send the status for it at all or sends it with a big delay. MultiCharts waits for the order status for 60 seconds by default (60 seconds between MultiCharts asking for the order status and receiving or not receiving the order status). If no feedback is provided for the order within 60 seconds by the broker - this order is considered to be cancelled/no longer present at the broker. In such situation the message “Didn’t receive final status for order” appears in the Order and Position Tracker window Logs tab. If the order was cancelled but the order generation conditions are still valid in the code – the signal generates the order and sends it to the broker again while the order generation conditions are met in the code. If the previous order (lost by the API/not sent to MC) is still active – an overfill is possible.
When this option is enabled the auto trading will be automatically turned off once the final status for an order sent by this strategy is not received. This option does not manage the open position/active orders. By default this option is disabled.
Stop auto trading after X rejected orders
When enabled the auto trading will be automatically turned off after the specified number of the strategy orders is rejected. By default this option is disabled.
Price Order Emulation
It is possible to switch between native and emulated Stop, Limit and Stop-Limit orders in both auto trading and manual trading. This feature requires realtime data subscription on your broker account. When a Stop/Limit order is emulated - once the Stop/Limit price level is reached by the corresponding Ask/Bid or Trade prices, a market/limit order is sent to the broker correspondingly. When a Stop-Limit order is emulated - once the Stop price level is reached by the corresponding Ask/Bid or Trade prices, a Limit order is sent to the broker. In case Stop, Limit and/or Stop-Limit order emulation is enabled - the emulated OCO group is used, disregard the broker profile/auto trading broker plugin settings.
To enable the Stop, Limit or Stop-Limit order emulation for automated trading select Emulate locally using Bid/Ask or Emulate locally using Trade from the dropdown list next to the corresponding order type. Leave the settings to Use native if using price order emulation is undesirable.
In order to apply the changes one needs to disconnect the broker profile and reconnect it.
Self-Adaptive Trading
Check the Enable box to run periodic re-optimization of the strategy on new data. See the Self-Adaptive Trading page for more info.
Unfilled Strategy Order Replacement
With the help of these options one can have unexecuted entry/exit price orders converted into market orders when the specified timeout is exceeded or upon bar close. The timer is launched depending on the option “Get Real-Time Data from” and the mode of auto trading. In SA mode:
- when set to “Broker”, the timer starts when the price at the broker touches the order’s price;
- when set to “Chart”, the timer starts when the order price is hit on a chart.
Operation of these options depends on the Intra-Bar Order Generation (IOG):
- IOG disabled - if the timer has started but the bar closed faster than timeout exceeded, then the price order is converted into a market order without waiting for the timeout to exceed;
- IOG enabled - each new tick is considered to be bar close. If the order’s price is touched and new tick comes in – the price order will be converted into market order at once without waiting for the timeout to exceed.
In AA mode conversion will start when an order is filled on a chart.
The conversion algorithm is the following:
- The Auto trading engine system receives an order filling event on the chart.
- If an identical order is now placed on the broker, the timer for conversion is launched.
- If this order is not placed on the broker yet, MultiCharts remembers that on this bar it is necessary to convert this particular order.
- The Auto Trading engine places an order that needs conversion. The timer for conversion is launched.
Partially Filled Orders Replacement
When these options are enabled the unfilled part of partially filled price order will be cancelled and the remainder will be converted into a market order when the specified timeout is exceeded, or upon bar close. The timer is launched on the first partial fill event.
Recalculate on Broker Events
The option can be used to force the strategy to be recalculated after a certain event during live trading. One can check the following events:
- When Market Position Changes.
- When an Order is Filled.
- When an Order is Rejected.
Get Real-Time Data from
This option affects special orders monitoring and defining the moment to convert price orders into market ones.
i_OpenEquity, OpenPositionProfit keywords are not affected by this option, they are always calculated from chart prices.
- From Broker: Asks and Bids are taken from the connected broker.Note: From Broker option is not available for asynchronous mode [AA]
- From Chart: depends on the BackTesting Mode:
- a) If it is Classic Backtesting, then the data is taken from the data series 1;
- b) If it is Extended Backtesting (see Precise Backtesting), then the data is taken from the Ask and Bid subseries.
- a) If it is Classic Backtesting, then the data is taken from the data series 1;
Mode Selection
- In synchronous mode [SA] one can see the same open market position and active orders on the chart as at broker. All orders generated by historical calculation during Backtesting are wiped out from the chart when auto execution is turned on. Executed order is displayed only if it has been executed at broker and the final status of the order has been received by MultiCharts. To use synchronous mode for auto trading select Entries/Exits are based on the execution confirmation by the broker (Sync)
Note: Chart market position and broker market position are in synch only if no more than one chart is auto trading without any manual orders on a particular symbol connected to a particular broker account, assuming that at the moment the automation was turned the broker market position was flat or, if it was not flat at broker, assigned manually on start of auto trading in MC to match it (see Assign the Initial Market Position at the Broker Settings). If more than 1 chart is auto trading in [SA] mode and/or manual trading is used as the same time on the same symbol at broker, chart can easily get out of synch. To learn more, see Trading from Multiple Charts on One Instrument.
- In asynchronous mode [AA] the strategy on the chart starts auto trading based on the historically calculated orders and open position, displaying all generated by the script orders on chart even if an order was not executed at broker. In AA strategy on chart acts separately from broker.
To use asynchronous mode for auto trading select Entries/Exits are independent of the execution status at the broker (Async)
Understanding Strategy Calculation in Different Modes
There are 3 separate market positions when strategy is auto trading in MultiCharts:
- Broker position. This is net position for a traded security at your broker account that takes into consideration all trades. It can be seen on Open Positions tab of Order and Position Tracker.
- Auto trading engine position. This is inner position of the strategy on a specific chart calculated by the software. It can be seen on Strategy Positions tab of Order and Position Tracker.
- Chart position. This is the position generated by orders visually executed on chart. It has nothing to do with open position horizontal drawing shown when you open Chart Trading panel.
When you auto trade in SA (sync. mode) the 2 and 3 are the same, what you see on the chart is synchronized with auto trading engine. When you use AA (async. mode), you may have to deal with 3 different positions: what you have on broker, what you see on chart, what MC thinks it is.
Market Position Checking Keywords
- MarketPosition_at_Broker. Returns broker position.
- MarketPosition_at_Broker_for_The_Strategy. Returns MC auto trading engine position.
- MarketPosition. Returns chart position (only direction).
Assign Initial Market Position to Strategy
When auto trading is turned on, a strategy starts working with a specific market position.
Depending on the mode of auto trading, this position can vary. In [SA] mode it is always flat on chart when you turn it on, but in [AA] mode it can be short, flat or long, depending on backtesting trades (to learn more see Mode Selection).
This option allows to control the initial market position for the strategy to start calculation and order generation with when you turn on auto trading.
The available options are:
- Flat - the initial position will be flat.
Example: According to your backtesting, the current position is 1 contract long and your real broker position is 1 contract short. With this option you will have +1 on your chart, flat for auto trading engine within the software and -1 short at broker, when the automation is turned on. - From Chart - the initial position will be the same as the position on the chart.
- From Broker - the initial position will be the same as the actual position at the broker when automation is enabled.
- Always show dialog window - to get the dialog every time the automation is enabled, no matter what the strategy position is at that moment.
Note: It is extremely important for [SA] mode, because it is always flat when automation is turned on in [SA]. - Show dialog window only if market position on chart is different from broker - to get the dialog when the chart and broker positions do not match.
- Flat - the initial position will be flat.
Set TIF for order types
Select the Time in Force (TIF) for each order type:
- Market
- Limit
- Stop
- Stop-Limit
These controls work as a dropdown list with all TIFs supported in MultiCharts:
- Default (corresponds to the value from the broker plugin settings)
- DAY
- GTC
- GTD (includes the additional control to select the number of days)
- IOC
- FOK
- AON
The list depends on what TIFs are supported by the broker. The selected TIF values will be used to send orders into the broker plugin. If the selected TIF is not supported by a broker profile, the value from the broker plugin settings will be taken.
- Some brokers may change TIF on their end – MultiCharts doest not regulate it.
- The described behaviour is not applicable to backtesting.
Select Broker Plug-in
Each chart has a Broker Plug-in selected for it by default when it is created. Broker Plug-ins are similar to Broker Profiles. All information about broker plug-in configuration is stored in a corresponding Broker Profile.
If the instrument on the chart is provided by a data vendor that is not a broker, then the default plug-in for automated trading will be the same as the first existing Broker Profile on the Trade Bar.
To change a Broker Plug-in for a particular chart, click the arrow in the Broker Plug-in field to get a drop-down list and choose the required one.
Settings of the Plug-in can be adjusted and become different from the corresponding Broker Profile settings. Not all the settings are the same, to learn more about particular Broker Plug-ins, see here Broker Plug-ins.
Distinguished Features of Auto Trading
Auto Trading Status Switch
The Auto Trading Status Switch is a button on the chart that lets the user turn on auto trading quickly. The button will be labeled either SA or AA depending on whether the user selected synchronous auto trading or asynchronous auto trading mode for the strategy.
By default, the location of this button is on the top left corner of the chart. However, it is possible to move it to a different location by doing the following:
- Select Format from the main menu.
- Select Window.
- In the Format Window dialogue box, select the Status Line tab.
- In the list box, find Automate Order Execution Switch.
- Click on Move Up or Move Down to change the order and the location. To remove it from the chart, deselect it.
Automatic Termination of Auto Trading
Auto Trading is stopped automatically if any of the following occurs:
- Any changes are made to the symbol chart or charts, to which the strategy is applied: chart reload, adding, removing, changing any of the symbols or their request parameters that result in the strategy's recalculation (not to be confused with receiving historical data).
- Any of the strategy signals are turned on or off
- Any of the strategy signal inputs are changed
- Any of the strategy signals are recompiled
- Any signals are removed from or added to the strategy
- Any strategy parameters are changed
- Any Auto Trading parameters are changed
- Connectivity between MultiCharts and the execution gateway has been lost and the disconnection time (of the broker profile) exceeded the specified acceptable level.
- "Stop auto trading if final status of an order is not received" option has come into effect
- "Stop auto trading after X rejected orders" option has come into effect
- You have got a Fail-Watch and Trading System Warnings alert
Pending Order Cancellation upon Termination of Auto Trading
If any orders are pending when Auto Trading is terminated, an Auto Trading Warning – Do you want to cancel the order? window appears.
A list of pending orders is displayed in the window.
To cancel some or all of the pending orders, select the check boxes to the left of the orders that are to be canceled, and clear the check boxes to the left of the orders that are not to be canceled, and click Cancel Order(s) .
To not cancel any of the pending orders, click Do Not Cancel Order(s) .
Closing of Open Positions upon Termination of Auto Trading
If any positions are open when Auto Trading is terminated, an Auto Trading Warning – Do you want to close position? window appears. A list of open positions is displayed in the window.
To close open positions, click Close Position.
To leave the positions open, click Do Not Close Position.
Auto Trading the Same Symbol from Multiple Charts
If the same symbol is traded from multiple charts, market position for each chart is tracked separately. For detailed review of such situation, please read Trading from Multiple Charts on One Instrument.
Tracking Market Position from the Broker During Auto Trading
In auto trading, there can be a de-synchronization between the market position of the strategy and the actual filled position from the broker. The de-synchronization is usually caused by orders that are submitted but not filled. In such cases, the user may want to have the strategy adjust calculations based on the actual filled position instead of adjusting the calculations manually.
PowerLanguage keywords are available to track the actual filled positions during auto trading. The user can use these keywords to enable hands free trading.
The following keywords are available:
i_MarketPosition_at_Broker
i_MarketPosition_at_Broker_for_The_Strategy
MarketPosition_at_Broker
MarketPosition_at_Broker_for_The_Strategy
To use current strategy properties settings for all new charts of, check the Use as Default check box.