Strategy.doCover()

ICE Data Services -

Strategy.doCover() Back Testing Functions

doCover() is a method of the Strategy Object that submits an order to close or cover a portion of an existing short position for back testing analysis through the Strategy Analyzer (Tools-->Back Testing).  The Strategy Object is for back testing purposes only and is not intended for real time trading.

Syntax
Strategy.doCover( sDescription , FillType , FillBar [, nLotSize ][, nStopOrLimit ] )

Parameters
Parameter: Description:Default:
sDescription Required.  String describing the type of signal for the trade.

 

n/aFillType Required.  Constant that specifies the type of fill for the trade (see Notes).

 

n/aFillBar Required.  Constant that specifies the bar where the fill for the trade will be recorded (see Notes).

 

n/anLotSize [Optional]  Number of contracts/shares for the trade or lot size constant (see Notes).

 

Back Testing
Preferences
defaultnStopOrLimit [Optional]  Number for the Stop or Limit price of the trade if the fill type constants .STOP or .LIMIT are specified.

 

n/a
Return Value(s)
Boolean true if filled, false if not filled.

Notes
Strategy must be short in order to use Strategy.doCover().


Fill Type Constants: Description:
Strategy.MARKET
Records the fill price at the open of the bar.Strategy.CLOSERecords the fill price at the close of the bar.Strategy.STOPRecords the fill price at the specified stop.Strategy.LIMITRecords the fill price at the specified limit.
If the Fill Type of Strategy.LIMIT or Strategy.STOP is specified, the nStopOrLimit price parameter must be specified.  Also, the formula logic used to determine the stop or limit price should ensure that the price is realistic.  For example, if the price used is outside the range of the fill bar, the trade will still be recorded with that price, which will produce unrealistic back testing results.

 

Fill Bar Constants: Description:
Strategy.THISBAR Records the trade on the current bar.
Strategy.NEXTBAR
Records the trade on the next bar.

 

Lot Size Constants: Description:
Strategy.DEFAULT Specifies the lot size for the trade based on the default used in the Strategy Analyzer's Back Testing Preferences.
Strategy.ALL
Specifies the position's entire lot size for closing trades.

 

Starting with version 10.5 Strategy.doCover() will no longer reverse a position if the defined number of shares/contracts exceeds those held in a short position. If for example the strategy is short 200 shares/contracts and the amount set in Strategy.doCover() is for 600 shares/contracts the strategy object will now close the short position of 200 shares/contracts and discard the remainder instead of creating a long position of 400 shares/contracts.
Code Examples
// Exits a short position at the open of the current bar. 
// Trade condition should evaluate data on the previous bar.
Strategy.doCover( "Exit Short Signal", Strategy.MARKET, Strategy.THISBAR ); // Exits a short position at the open of the next bar.
// Trade condition should evaluate data at the close of the current bar.
Strategy.doCover( "Exit Short Signal", Strategy.MARKET, Strategy.NEXTBAR ); // Exits a short position at the close of the current bar.
// Trade condition may evaluate data on the current bar.
Strategy.doCover( "Exit Short Signal", Strategy.CLOSE, Strategy.THISBAR ); // Exits a short position at the specified stop price on the current bar.
// Trade condition should evaluate data on the current bar.
var nStop = hl2();
Strategy.doCover( "Exit Short Signal", Strategy.STOP, Strategy.THISBAR , Strategy.ALL, nStop);
// or the following, which assumes the position has at least 200 shares/contracts.
Strategy.doCover( "Exit Short Signal", Strategy.STOP, Strategy.THISBAR , 200, nStop);



See Also
Back Testing Functions
EFS Library:  Back Testing
Strategy Analyzer
eSignal Bulletin Board Search Engine
Help Guides
Tutorials