|
Strategy Object
The Strategy Object allows EFS scripts to communicate with the eSignal Strategy Analyzer and perform backtests of trading systems.
Strategy Methods
doLong()
|
enter a long position
|
doSell()
|
exit a long position
|
doCover()
|
exit a short position
|
doShort()
|
enter a short position
|
isInTrade()
|
returns true if system is currently in a trade
|
isLong()
|
returns true if system is currently long
|
isShort()
|
returns true if system is currently short
|
setStop()
|
set a stop value
|
clearStop()
|
clear a stop value
|
getPositionSize()
|
returns the position size
|
getDefaultLotSize()
|
returns the default lot size
|
Strategy.doLong(Description, Fill Type, Fill Bar, LotSize, StopOrLimit)
Strategy.doSell(Description, Fill Type, Fill Bar, LotSize, StopOrLimit)
Strategy.doCover(Description, Fill Type, Fill Bar, LotSize, StopOrLimit)
Strategy.doShort(Description, Fill Type, Fill Bar, LotSize, StopOrLimit)
Strategy.isInTrade()
Strategy.isLong()
Strategy.isShort()
Strategy.setStop(dStop)
Strategy.clearStop()
Strategy.getPositionSize()
Strategy.getDefaultLotSize()
Fill Type Constants
Strategy.CLOSE
|
uses the closing price as the fill price
|
Strategy.LIMIT
|
uses the StopOrLimit price as the fill price
|
Strategy.MARKET
|
uses the open price as the fill price
|
Strategy.STOP
|
uses the StopOrLimit price as the fill price
|
Fill Bar Constants
Strategy.THISBAR
|
uses the OHLC values of the current bar to determine the fill price in conjunction with the Fill Type
|
Strategy.NEXTBAR
|
uses the OHLC values of the next bar to determine the fill price in conjunction with the Fill Type
|
LotSize Constants
Strategy.DEFAULT
|
uses the Default LotSize as the number of shares
|
Strategy.ALL
|
typically used with Strategy.doSell or Strategy.doCover; specifies that all shares being held to be sold/covered
|
Notes
| · | If calling Strategy.doLong, Strategy.doShort, Strategy.doSell, or Strategy.doCover and a Fill Type of Strategy.LIMIT or Strategy.STOP is provided, the StopOrLimit price must be specified. |
|
| · | You must be long to use Strategy.doSell. |
|
| · | You must be short to use Strategy.doCover. |
|
| · | If a long position is currently held, calling Strategy.doShort will close the long position and enter a short position. |
|
| · | If a short position is currently held, calling Strategy.doLong will close the short position and enter a long position. |
|
Usage
//assume a default lot size of 100
//go long 100 shares at the closing value of the current bar.
Strategy.doLong( "Go Long", Strategy.CLOSE, Strategy.THISBAR );
//go long 100 shares at the closing value of the current bar.
Strategy.doLong( "Go Long", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT );
//Limit order to go long 100 shares @ $20 if the low of the current bar is <= 20.
Strategy.doLong( "Go Long", Strategy.LIMIT, Strategy.THISBAR, null, 20 );
//If long, issue a stop sell order if high of the current bar >= 30.
if( Strategy.isLong() ) {
Strategy.doSell( "Close Long", Strategy.STOP, Strategy.THISBAR, Strategy.ALL, 30 );
}
//Set a stop order to sell all shares if high of any bar at or after the current bar >= 30.
Strategy.setStop( 30 );
|