Market On Close Order

Add-On

#region Namespaces
using System;
using System.IO;
using System.Linq;
#endregion 

namespace ScriptCode 
{
    /// <summary>
    /// Add-On scripts are used for adding functionality to the platform.
    /// </summary>
    public partial class MyAddOn : AddOnScriptBase // NEVER CHANGE THE CLASS NAME
    {
        #region Variables
		// The action type for the order.
		private C_ActionType _actionType;
		// The order quantity.
		private double _quantity;
		// The order TIF.
		private C_TIF _timeInForce;
		// The order comment.
		private string _comment;
        #endregion

        #region OnInitialize
        /// <summary>
        /// This function is used for accepting the script parameters and for initializing the script prior to all other function calls.
        /// </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="actionType" type="C_ActionType" default="BUY">The action type</param>
		/// <param name="quantity" type="Double" default="0">The order quantity</param>
		/// <param name="timeInForce" type="C_TIF" default="DAY">The order TIF </param>
		/// <param name="comment" type="String" default="">The order comment</param>
        public void OnInitialize(
			 C_ActionType actionType,
			 double quantity,
			 C_TIF timeInForce,
			 string comment)
        {
			_actionType = actionType;
			_quantity = quantity;
			_timeInForce = timeInForce;
			_comment = comment;
        }
        #endregion

        #region OnTriggered
        /// <summary>
        /// This function is called when the add-on is triggered by the user.
        /// </summary>
        /// <param name="strategyNumber" type="Integer">The strategy number on which the add-on was called (or -1 if none is available)</param>
        /// <param name="symbolIndex" type="Integer">The symbol index of the symbol on which the add-on was called (or -1 if none is available)</param>
        /// <param name="index" type="Integer">The item index of the item on which the add-on was called, such as the order index, trade index and position index (or -1 if none is available)</param>
        public override void OnTriggered(
            int strategyNumber,
            int symbolIndex,
            int index)
        {
            BrokerMarketOnClose(strategyNumber, symbolIndex, _actionType, _quantity, _timeInForce, _comment);
        }
        #endregion
    }
}