EnterShort()

View as Markdown

Definition

Generates a sell short market order to enter a short position.

Method Return Value

An Order read-only object that represents the order. Reserved for experienced programmers, additional information can be found within the Advanced Order Handling section.

Syntax

EnterShort()

EnterShort(string signalName)

EnterShort(int quantity)

EnterShort(int quantity, string signalName)

The following method variation is for experienced programmers who fully understand Advanced Order Handling concepts:

EnterShort(int barsInProgressIndex, int quantity, string signalName)

If using a method signature that does not have the parameter quantity, the order quantity will be taken from the quantity value set in the strategy dialog window when running or backtesting a strategy.

Parameters

ParameterDescription
signalNameUser defined signal name identifying the order generated. Max 50 characters.
quantityEntry order quantity (if 0 is passed in, will be set to 1, except for stocks 100).
barsInProgressIndexThe index of the Bars object the order is to be submitted against. Used to determine what instrument the order is submitted for. See the BarsInProgress property.

Examples

1protected override void OnBarUpdate()
2{
3 if (CurrentBar < 20)
4 return;
5
6 // Only enter if at least 10 bars has passed since our last entry
7 if ((BarsSinceEntryExecution() > 10 || BarsSinceEntryExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
8 EnterShort("SMA Cross Entry");
9}