EnterLongLimit()

View as Markdown

Definition

Generates a buy limit order to enter a long 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

EnterLongLimit(double limitPrice)

EnterLongLimit(double limitPrice, string signalName)

EnterLongLimit(int quantity, double limitPrice)

EnterLongLimit(int quantity, double limitPrice, string signalName)

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

EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, 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.
limitPriceThe limit price of the order.
quantityEntry order quantity (if 0 is passed in, will be set to 1, except for stocks 100).
isLiveUntilCancelledThe order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force is reached.
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 EnterLongLimit(GetCurrentBid(), "SMA Cross Entry");
9}