Strategy.doLong()

ICE Data Services -

Strategy.doLong() Back Testing Functions

doLong() is a method of the Strategy Object that submits an entry order to open or add to an existing long 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 .doLong( 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 short position is currently held when calling Strategy.doLong(), the short position will automatically be closed before the long position is entered and will be filled at the same price.

If a long position is currently held when calling Strategy.doLong(), the lot size of the trade will be added to the current long 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 long position at the open of the current bar.
// Trade condition should evaluate data on the 
previous bar.Strategy.doLong( "Long Signal", Strategy.MARKET, Strategy.THISBAR );

// Enters a long position at the open of the next bar.
// Trade condition should evaluate data at the close of the
current bar.Strategy.doLong( "Long Signal", Strategy.MARKET, Strategy.NEXTBAR ); 

// Enters a long position at the close of the current bar.
// Trade condition may evaluate data on the 
current bar.Strategy.doLong( "Long Signal", Strategy.CLOSE, Strategy.THISBAR );

// Enters a long position at the specified limit price on the current bar.
// Trade condition should evaluate data on the current bar.
var nLimit = hl2();
Strategy.doLong("Long Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, nLimit);

// or
Strategy.doLong("Long 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