Support

Equilla Formula Language

SetDefaultQuantity

Set the default amount of shares/contracts to trade.

Inputs

Quantity
Numeric: Number of shares/contracts to trade.

Remarks

You can create entry orders (Buy or Short) without specifying the number of shares/contracts you want to trade. If the quantity is omitted, tradesignal is using the default quantity when processing the order. The default quantity is evaluated directly before the order is processed, so you may create the order first and control the quantity afterwards by setting the default quantity.

The default quantity is managed per instrument, so you can specify different values for the separate symbols.

The initial value of the default quantity is specified by the Default Quantity property.

The default quantity is evaluated for entry orders only (Buy and Short). For exit orders (Cover, ExitPosition and Sell) the current position will be closed if the quantity is omitted.

Examples

Dynamically set the trading quantity
Input: Price( Close ), Period( 10, 1 ), MinQuantity( 1, 1 ), MaxQuantity( 100000, 1 ); Variables: cash; If Average( Price, Period ) Crosses Price Then Buy Next Bar at Market Else If Price Crosses Average( Price, Period ) Then Sell Next Bar at Market; // Calculate the quantity cash = InitialCapital + ClosedEquity; SetDefaultQuantity( Int( cash / Price ) ); // Check the quantity boundaries If GetDefaultQuantity() <; MinQuantity Then SetDefaultQuantity( MinQuantity ) Else If GetDefaultQuantity() >; MaxQuantity Then SetDefaultQuantity( MaxQuantity );