Saturday, September 04, 2010

Commission Per Order and Per Unit [CPOPU]

Descripton
Summary:
This commission script calculates the commission paid for an executed order, determined by a constant amount in addition to a variable amount based on the order quantity.


Variables
TypeIdentifierDescription
Number_commissionPerOrderUse for the commission amount paid for each executed order.
Number_commissionPerUnitUse for the commission amount paid for each unit (share / contract / lot) of the executed order.

OnInitialize
Function Parameters
TypeIdentifierDescription
NumbercommissionPerOrderUse for the commission amount paid for each executed order. [Default 10]
NumbercommissionPerUnitUse for the commission amount paid for each unit (share / contract / lot) of the executed order. [Default 0.01]
Implementation
	 ' Assign the parameters to script variables.
	_commissionPerOrder = commissionPerOrder
	_commissionPerUnit = commissionPerUnit

OnCommission
Function Parameters
TypeIdentifierDescription
IntegerorderIndex
IntegerorderFillIndex
Numberquantity
Numberprice
Implementation
	 ' Return the commission being paid for the executed order.
	If (orderFillIndex = 0) Then
		Return _commissionPerOrder  + (_commissionPerUnit * quantity)
	End If
	Return _commissionPerUnit * quantity

Copyright © 2010 IQBroker, LLC. All rights reserved.