Strategy.isInTrade() Back Testing Functions
isInTrade() is a method of the Strategy Object that returns a Boolean (true/false) value to indicate that the strategy is currently holding either a long or short position. The Strategy Object is for back testing purposes only and is not intended for real time trading.
Syntax
Strategy .isInTrade( )
Parameters
N/A
Return Value(s)
Boolean (true/false)
Notes
Strategy.isInTrade() returns true if a long or short position is currently being held. This method is a logic function used to control back testing logic within conditional statements. For example, a user may want to check to see if the strategy is currently in a position before evaluating exit conditions. Alternatively, a user may want to check to see that the strategy is not in a position before evaluating new entry conditions.
Code Examples
function main() { if (Strategy.isInTrade() == true) { // Evaluate exit conditions if (/* Your Exit Condition */) { //Strategy.doSell(...); // or //Strategy.doCover(...); } } else if (Strategy.isInTrade() == false) { // Evaluate new Entry conditions if (/* Your Entry Condition */) { //Strategy.doLong(...); // or //Strategy.doShort(...); } } }
See Also
Back Testing Functions
EFS Library: Back Testing
Strategy Analyzer
eSignal Bulletin Board Search Engine
Help Guides and Tutorials