Summary:
This commission script calculates the constant commission paid for each executed order, denominated in the account currency.

                    
#region Namespaces using System; using System.IO; using System.Linq; #endregion namespace ScriptCode { /// <summary> /// Commission scripts are used for calculating the commission paid to a broker for each executed order, /// based on the broker's exact commission schedule. /// </summary> public partial class MyCommission : CommissionScriptBase // NEVER CHANGE THE CLASS NAME { #region Variables // Use for the commission amount paid for each executed order. private double _commissionPerOrder; #endregion #region OnInitialize /// <summary> /// This function is used for accepting the script parameters and for initializing the script prior to all other function calls. /// Once the script is assigned to a desktop, its parameter values can be specified by the user and can be selected for optimization. /// </summary> /// -------------------------------------------------------------------------------------------------- /// PLEASE USE THE SCRIPT WIZARD (CTRL+W) TO ADD, EDIT AND REMOVE THE SCRIPT PARAMETERS /// -------------------------------------------------------------------------------------------------- /// YOU MUST SET A PARAM TAG FOR EACH PARAMETER ACCEPTED BY THIS FUNCTION. /// ALL PARAM TAGS SHOULD BE SET IN THE 'OnInitialize' REGION, RIGHT ABOVE THE 'OnInitialize' FUNCTION. /// THE ORDER OF THE TAGS MUST MATCH THE ORDER OF THE ACTUAL PARAMETERS. /// REQUIRED ATTRIBUTES: /// (1) name: The exact parameter name. /// (2) type: The type of data to collect from the user: /// Set to "Integer" when the data type is 'int' /// Set to "IntegerArray" when the data type is 'int[]' /// Set to "DateTime" when the data type is 'long' /// Set to "DateTimeArray" when the data type is 'long[]' /// Set to "Boolean" when the data type is 'bool' /// Set to "BooleanArray" when the data type is 'bool[]' /// Set to "Double" when the data type is 'double' /// Set to "DoubleArray" when the data type is 'double[]' /// Set to "String" when the data type is 'string' /// Set to "StringArray" when the data type is 'string[]' /// OPTIONAL ATTRIBUTES: /// (3) default: The default parameter value is only valid when the type is Integer, Boolean, Double, String or an API Type. /// (4) min: The minimum parameter value is only valid when the type is Integer or Double. /// (5) max: The maximum parameter value is only valid when the type is Integer or Double. /// EXAMPLE: <param name="" type="" default="" min="" max="">Enter the parameter description here.</param> /// -------------------------------------------------------------------------------------------------- /// <param name="commissionPerOrder" type="Double" default="10">Use for the commission amount paid for each executed order.</param> public void OnInitialize(double commissionPerOrder) { // Set the parameter to a script variable. _commissionPerOrder = commissionPerOrder; } #endregion #region OnCommission /// <summary> /// This function is called to calculate the commission paid to a broker for a specified order fill. /// Note that the commission is denominated in the currency of the specified desktop strategy. /// </summary> /// <param name="strategyNumber" type="Integer">The strategy number to which the order belongs</param> /// <param name="orderIndex" type="Integer">The order index in the orders table to which the order fill belongs</param> /// <param name="orderFillIndex" type="Integer">The order fill index (0 being the first fill for the order, 1 being the next fill, etc.)</param> /// <param name="fillQuantity" type="Double">The quantity of the new order fill for the specified order</param> /// <param name="fillPrice" type="Double">The price of the new order fill for the specified order</param> /// <returns type="Double">The commission paid for the specified order fill, in the desktop strategy currency.</returns> public override double OnCommission( int strategyNumber, int orderIndex, int orderFillIndex, double fillQuantity, double fillPrice) { // Check whether this is the first order fill. if (orderFillIndex == 0) { return _commissionPerOrder; } return 0; } #endregion #region OnShutdown /// <summary> /// This function is called when the script is shutdown. /// </summary> public override void OnShutdown() { // OnShutdown Content } #endregion } }

The Algorithmic Trading Software for Hedge Funds and Quants