Strategy.doShort() Back Testing Functions
doShort() is a method of the Strategy Object that submits an entry order to open or add to 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 .doShort( sDescription , FillType , FillBar [, nLotSize ][, nStopOrLimit ] )
Parameters
Parameter: | Description: | Default: |
sDescription | Required. String describing the type of signal for the trade. | n/a |
FillType | Required. Constant that specifies the type of fill for the trade (see Notes). | n/a |
FillBar | Required. Constant that specifies the bar where the fill for the trade will be recorded (see Notes). | n/a |
nLotSize | [Optional] Number of contracts/shares for the trade or lot size constant (see Notes). Back Testing | Preferences default |
nStopOrLimit | [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
If a long position is currently held when calling Strategy.doShort(), the long position will automatically be closed before the short position is entered and will be filled at the same price.
If a short position is currently held when calling Strategy.doShort(), the lot size of the trade will be added to the current short position.
Fill Type Constants: | Description: |
Strategy.MARKET | Records the fill price at the open of the bar. |
Strategy.CLOSE | Records the fill price at the close of the bar. |
Strategy.STOP | Records the fill price at the specified stop. |
Strategy.LIMIT | Records 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. |
Code Examples
// Enters a short position at the open of the current bar. // Trade condition should evaluate data on the previous bar.Strategy.doShort( "Short Signal", Strategy.MARKET, Strategy.THISBAR ); // Enters a short position at the open of the next bar. // Trade condition should evaluate data at the close of the current bar.Strategy.doShort( "Short Signal", Strategy.MARKET, Strategy.NEXTBAR ); // Enters a short position at the close of the current bar. // Trade condition may evaluate data on the current bar.Strategy.doShort( "Short Signal", Strategy.CLOSE, Strategy.THISBAR ); // Enters a short position at the specified limit price on the current bar. // Trade condition should evaluate data on the current bar. var nLimit = hl2(); Strategy.doShort( "Short Signal", Strategy.LIMIT, Strategy.THISBAR , Strategy.DEFAULT, nLimit); // or Strategy.doShort( "Short Signal", Strategy.LIMIT, Strategy.THISBAR , 200, nLimit);
See Also
Back Testing Functions
EFS Library: Back Testing
Strategy Analyzer
eSignal Bulletin Board Search Engine
Help Guides and Tutorials