Sets the quantity for an order to the specified amount. This function is only available to the Unit Size, Can Add Unit, and Can Fill Order Script script and is used to set the order quantity.

 

NOTE:

This function is only valid for Entry Orders and is ignored for Exit Orders.

 

Syntax:

order.SetQuantity( quantity )

 

Parameter:

Description:

quantity

Quantity to assign to the order.

 

Returns:

Integer quantity assigned.

 

Example:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Common Fixed Fractional Order sizing calculation.
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Calculate amount of equity available for order sizing.
riskEquity = system.tradingEquity * riskPerTrade
 
'  Convert instrument point risk into dollars.
dollarRisk = order.entryRisk * instrument.bigPointValue
 
'  Order quantity will be the integer portion division.
tradeQuantity = riskEquity / dollarRisk

 

'  If tradeQuantity is less than 1,...
If tradeQuantity < 1 THEN
  '  Order quantities less than 1.are rejected
  order.Reject( "Order Quantity less than 1." )
ELSE
  '  Order greater than 1 become order size amount.
  order.SetQuantity( tradeQuantity )
ENDIF '  tradeQuantity < 1
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Alternate Order Object:

Access to Order Object properties and functions in other scripts is made possible by using the AlternateOrder Object as the prefix ahead of the "." property or function. AlternateOrder Object is discussed below.

 

Notes:

Always check to be sure the order is available after a Broker function call using the system.orderExists() function prior to accessing it.

 

Using the alternateOrder object when orders are not in context will provide the same access as the Order object.  However, the alternateOrder object must be brought into context using the system.SetAlternateOrder object function prior to any attempt to use is properties and functions.

 

Once orders are brought into context their properties and function are available to reference and changes.

 

Links:

bigPointValue, entryRisk, Reject, tradingEquity

See Also:

Can Add Unit, Can Fill Order, Data Group and Types, Unit Size, AlternateOrder Object, AlternateSystem Object, Order Functions, Order Object, Order Properties

 


Edit Time: 9/21/2020 2:50:37 PM


Topic ID#: 550

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software