Advanced Analytics



Download 0.61 Mb.
Page20/20
Date29.01.2017
Size0.61 Mb.
1   ...   12   13   14   15   16   17   18   19   20

110.Entering External Trades


You can incorporate independent external positions into the active auto trade system by entering them on the External Trades window.

For example, you may have an open position, resulting from a discretionary trade, that would require significant manual management to liquidate. You can close this position by entering an external trade. The system considers this trade in the overall P&L calculation of the underlying trade system.

External trades remain active until they are deleted and are considered in the position calculation each time the auto trade is turned on.

To open the External Trades window, click the External Trades field. You can also open this window by right-clicking anywhere on the Auto Trade window. The Remember History field must be set to yes. See Setting Auto Trade Parameters for details about these fields.



To add a trade: click the Add button, then set the trade parameters.

To edit a trade: select it, click the Edit button, then change the trade parameters.

To delete a trade: select it, then click the Delete button.

Trade parameters

Parameter

Description

Order

Click the field, then select Buy or Sell.

Size

Enter the order size, either by typing a value or using the arrow buttons.

Symbol

Indicates the symbol associated with the auto trade.

Type

Choose and order type from the drop down menu.

This field is optional and has no impact on external trade processing, as an external trade is a filled order.



Price

Type the execution price.

This value is required by ATS and other order tracking studies, as it is necessary for the proper calculation of values such as OpenPositionAverageEntryPrice, EntryPrice, ExitPrice, and EntryProfit as well as for display of position on a chart.



ID

Type an order ID. This field is optional.

Date

Enter the date the order was executed. Type the date directly in the field, use the up and down arrows to move between dates, or click the down arrow to open a calendar.

Time

Enter the time the order was executed. Type the time directly in the field or use the up and down arrows to move between times.

Trade

Used with Entry/Exit field.

Click in the field, then select Buy or Sell.

This field, in conjunction with Entry/Exit, specifies which entry or exit in the trade system this external trade offsets.

For example, if the trade is part of a long trade entry, the value must be buy.



Entry/Exit

Required field that specifies whether the external trade is an entry or exit. Used with Trade field.

For example:

A trader has a trade system with an entry size of 10 and an exit size of 10.

The trader adds an entry external trade with a size of 5.

The system works the auto trade as if 5 of the 10 entry trades have been filled. (Either by continuing to work an entry for the remaining 5 lots, by working an exit, or by doing both depending on the signal trade system configuration.)

Click in the field, then select the entry and type of exit.




111.Monitoring Auto Trade Orders


Auto Trade signals and orders can be monitored on these applications:

Chart


Orders and Positions

Trading tools

You can also find information in the Auto Trade and chart tooltips.

Chart


Real-time and hypothetical historical orders and hypothetical performance can be monitored by applying a trade system on a chart. Right-click the chart, then click Add Study.

Orders can be monitored in real-time by applying the ATS study, which shows P&L and other performance statistics of actual orders since the start of the auto trade or some other time that you specify.



Orders and Positions

Monitor autotrading on Orders and Positions by filtering the view for Auto Trade only, using the Trade System drop down menu.

Trading applications

Monitor working orders on the DOM ladder on Order Ticket|topic=DOM area, DOMTrader|topic=DOMTrader Ladder, and Split DOMTrader|topic=Split DOMTrader Ladder.

112.How Auto Trade and Trade Systems Interact


You should be familiar with creating trade systems before starting autotrading.

A trade system provides Auto Trade with entry and exit signals and the price and size of orders. Auto Trade places, modifies, and cancels orders according to trade system parameters.

Auto Trade also monitors order state (partial fills, open and closed positions, etc.) and communicates this information to the trade system. Auto Trade and trade systems are always in sync.

Frequency


A trade system evaluates trade signals and price and size functions continuously in real time according to the frequency that you set. Trade systems and Auto Trade are allowed to execute one entry order per bar, even if the entry signal may be true multiple times within the bar.

Sequencing


CQG supports three ways of sequencing parent entry and exit orders per bar, which can be specified in trade systems (on the Entry tabbed window in the Allow field):

No selection (default) = allows only one entry and one exit per bar

Multiple entries before exit (Pyramid) = allows entry positions to accumulate without being closed with the exit signal.

If this option is not selected, Auto Trade does not place new entry parent orders until the entry order is fully exited, even if trading signal is true. Auto Trade does continue placing child orders in the case of partial executions.

Entry on exit = allows entry and exit to occur on the same bar

If the signal is true, the trade system tells Auto Trade to place an order with a certain price and size. If market conditions permit, an order is executed. While the order is working, a trade system may prompt the modification of size or price. If the signal is no longer true prior to the order being filled, the auto trade order is cancelled.


Entry and exit orders


Auto Trade places child entry and exit orders in sequence.

Auto Trade places exit orders only up to the size of the already filled entry positions. For example: if order size = 10 and partial fill = 5, Auto Trade places an exit order for 5 contracts. If there are multiple exit orders, the size of all individual exit orders is modified such that it is not larger than what was already filled.

Typically, trade systems have multiple entry and exit orders for different purposes to manage risk and maximize profit potential.

One entry order can be matched by multiple exit orders such as a standard exit, stop loss exit, profit exit, etc. So, the cumulative size of exit orders would likely be greater than the size of the entry order because they are not expected to be executed simultaneously.

Note: Some exit signals do not work correctly with Auto Trade unless they are wrapped inside SValPropagator. Examples:

LocalHour(@)=14 => SValPropagator(LocalHour(@)=14

LocalMinute(@)=0 => SValPropagator(LocalMinute(@)=0

BarIx(@,EndOfDay)=2 => SValPropagator(BarIx(@,EndOfDay)=2).

DomBid (@,3,Single,On_Every_Change) => (SValPropagator(DomBid(@,3,Single,On_Every_Change))

DomAsk(@,3,Single,On_Every_Change)=> (SValPropagator(DomAsk(@,3,Single,On_Every_Change))


Potential overfills with multiple exit orders


In the case of multiple exit orders with a cumulative size greater than the entry size, Auto Trade may overfill the entry order if more than one exit condition is met.

This can happen in fast moving markets where exit orders are placed relatively close to each other.

You can avoid this scenario by selecting the Restrict Exits Total Size to Open Position check box on the Exits panel of Formula Builder.

This option instructs Auto Trade to only work exits closest to the market up to the size of the total open position. Orders closer to the market are given higher priority when distributing the open position size between exit orders. The sum of working exit sizes is calculated separately for orders above market and for orders below the market to allow for profit taking opportunities and stop loss protection to be active at all times.

This example below demonstrates the logic:

Assume that we have a long trade with open position equal to 12 and six exits, three of which (A, B, C) are profit-taking limits and the other three (D, E, F) are stops. Let's assume their size formulas are the following:

A = OpenPosition / 2 = 6

B = OpenPosition / 3 = 4

C = OpenPosition / 2 = 6

D = OpenPosition / 2 = 6

E = OpenPosition / 2 = 6

F = OpenPosition / 2 = 6

At some point their price formulas yield values like this: A > B > C > Market > D > E > F.

Auto Trade places full exit C order (OpenPosition / 2 = 6), full exit B order (OpenPosition / 3 = 4), and only a part of exit A order ( OpenPosition / 6 = 2), even though exit A size formula is OpenPosition / 2. This is because the Open Position is fully covered (6+4+2=12). As for stops, the Auto Trade only places orders D and E even though exit F may also be active (6+6=12 to fully cover Open Position).

Later the values for price formulas change, so that B > C > A > Market > F > E > D.

In this case, Auto Trade places a full order A (OpenPosition / 2), keeps order C (OpenPosition / 2), and cancels the order B, since A and C orders are sufficient to cover the open position completely. As for orders below market, Auto Trade now has orders F and E working, and cancels the order D. If at any time the market price moves suddenly in any direction, the total size of executed exits will not exceed the Auto Trade open position.

Alternatively, you can avoid this scenario by formulating a trade system that explicitly instructs Auto Trade to work only one exit order at the time, based on order price closest to the market. Sample code:

A sell stop to exit a long trade that combines two stops into one, so that only one stop order works at a time:

a1:=( Low(@)[-1] WHEN BarsSinceEntry(@,0,All,ThisTradeOnly) = 0)-TickStop* TSize(@);

b1:=EntryPrice(@,0,All,ThisTradeOnly)-TickStop* TSize(@);

c1:=Max(a1,b1);

Where


a1 = low of the entry bar,

b1 = entry price less a set number of ticks

c1 = uses the higher of the 2 stops as its price.

Type this code in the Price window for Exits, and set the Signal value to 1.




Order type, price, and size


You can use five order types with trade systems and Auto Trade: market, limit, stop, limit stop, and pegging. A pegging order results from a formula using the Trade System functions DOM Bid and DOM Ask.

Price can be specified as a bar value, study value, or custom function:

Open(@) = market order at the open of the next bar

Close (@) = market order at the current market price

BHI(@,Sim,20,2.00) =limit order priced at Bollinger Band high

BLO(@,Sim,20,2.00) = limit order priced at Bollinger Band low

CLO(Low(@),LookBack) = limit order priced at Channel low

OpenPositionAverageEntryPrice(@,ThisTradeOnly) - Dollar2Price(@,300) / OpenPositionSize(@,ThisTradeOnly)

OpenPositionAverageEntryPrice(@,ThisTradeOnly) - ticksize(@) *1.5

The size of an order can be a fixed size or a function/formula that evaluates order size based on specific conditions. For example:

IF(EntryProfit(@,0,Closed,ThisTradeOnly) < 0, (OpenPositionSize(@,All)[-1] *2 when BarsSinceExit(@,0,All,All)=0),2)).

BarIx(@,EndOfSession)=0 = exit is triggered on the last bar of the trading session

OptimalF (@,95000,20,2,All,0) = Ralph Vince’s OptimalF study calculates optimal initial position size

OpenPositionSize(@) and OpenPositionEntrySize(@)

OpenPositionEntrySize is equal to the sum of all entry order fills, while OpenPositionSize is OpenPositionEntrySize minus the sum of all exit order fills. The table below illustrates the distinction:

Entry order fill

Exit order fill

OpenPositionEntrySize

OpenPositionSize

5

-

5

5

5

-

10

10

-

3

10

7

-

3

10

4

5

-

15

9

-

3

15

6

-

6

0

0

In case of partial fills, you are advised to use OpenPostionEntrySize rather than OpenPositionSize(@) formula to avoid unexpected results.

IF(EntryProfit(@,0,Closed,ThisTradeOnly) < 0, (OpenPositionSize(@,All)[-1] *2 when BarsSinceExit(@,0,All,All)=0),2)


Backtesting and autotrading


  • Backtesting results are evaluated at bar OHLC prices and so exclude signals that may have been true during the bars as in real time execution.

  • A trade system’s backtesting PNL results exclude trades where entry and exit signals are realized within the same bar because the system is not able to ascertain the order of the orders. Such trades, however, are correctly executed in real-time by Auto Trade. As such, backtesting results represent a more conservative estimate of the potential of the trading system.

You may have to modify trade system execution parameters in order to use a backtesting trade system for autotrading. Backtesting logic evaluates signals and assumes executions using historical OHLC values only, while autotrading works in real-time, potentially reacting to every tick change.

For example, consider a system that triggers an order at the cross of two moving averages and attempts to trade at the close of the bar, where signal was true.

In backtesting to evaluate historical performance of the system, you would set a signal without offset and set price to Close(@).

To achieve the same result in the autotrading, you should offset the same signal by -1 and set trading price Open(@).

This instructs Auto Trade to wait until the next bar open to execute on the signal.

Network connectivity


Network delays are indicated in milliseconds on the Auto Trade title bar.

In the case of a network disconnection, you receive a warning message notifying you of the connectivity issues. New positions are not initiated, but Auto Trade continues working open orders. You can manage these situations using a back-up trading system or by working with your broker directly. When Auto Trade restarts, you are prompted to check positions.

If Auto Trade is disconnected from the trading gateway during a trade, you must manually restart all systems once connectivity has been re-established.

If Remember History was off at the time of the disconnect, then Auto Trade starts a new trade (unless it has associated external trades) if turned on.



If Remember History was on at the time of the disconnect, then orders retain their state from the moment of disconnection, and Auto Trade continues working those orders.



Download 0.61 Mb.

Share with your friends:
1   ...   12   13   14   15   16   17   18   19   20




The database is protected by copyright ©ininet.org 2020
send message

    Main page