This property returns the value of the margin required for all of the active open entry orders placed with the broker object and not canceled.  

 

Syntax:

x = system.openOrderMargin

 

Parameter:

Description:

none

 

 

Returns:

Amount added if all the orders are filled.  

 

 

Notes:

A common problem with trading  some systems that use less restrictive conditional rules to generate orders on lots of symbols is the overload of entry orders on the first day of order generation.  A huge amount of orders means a run on available cash right at the beginning of trading, or at any time when a lot of instruments qualify with the rules for creating an order.

 

An example of a less restrictive rule is the use of greater than ">" and or less than "<", instead of a restrictive method like CrossOver.   When used to acknowledge that one price is above or below another price without some regard as to when that transition happened, means any qualifying relationship of the two or more prices will enable the instrument to generate an order.

 

Order generation without the concern for available Cash will cause the test results to be unrealistic.  Test results will unreliable because they will be based upon the system that exceeded available Cash, or exceeded Futures margin loading.  Results based on any violation of account restrictions like excessive margin load percentages, which can also exceed available Cash, or the use of more cash than what is available is a test failure.

 

Value returned by this System property for stock systems will be the incremental amount that will be deducted from available Cash for stock type systems, or the incremental amount of margin used for Futures type systems.

 

Futures margin is based upon the margin value of each instrument in the Futures Dictionary.

 

This script example is for a Suite with one system.

 

If the Suite is using multiple systems where the early systems can consume an excessive amount available equity, a more inclusive script will be required so that the equity being used by each of the systems can be analyzed and adjusted as needed.  By expanding the range of information need to consider the dynamic interactions between margin/purchase equity, total/closed equity, and cash need the process will able to further explored the accounts changes.

 

Example:

'  --------------------------------------------------------------
'  FUTURES
'  --------------------------------------------------------------
If instrument.IsFuture THEN
  '  Create a Currency Converted value of this
  '  order's need for equity
  newMarginValue = order.quantity _
                    * instrument.margin _
                    * instrument.conversionRate
 
  If ( test.totalMargin _
        + system.openOrderMargin _
        + newMarginValue ) > ( test.totalEquity _
                                * maxMarginEquity ) THEN
    '  Send the user a rejection message
     message = "Cannot add " + AsString( newMarginValue, 2 ) _
                + " additional margin to " _
                + AsString( test.totalMargin, 2 ) _
                + " existing with total equity of " _
                + AsString( test.totalEquity, 2 ) _
                + " and max margin equity threshold of " _
                + AsString( maxMarginEquity, 2 )
 
    '  Reject This Order
    order.Reject( message )
     
    '  Send the message to Log Window & Print Ouput.csv log
    PRINT message
  ENDIF '  > available equity
ENDIF '  i.IsFuture
 
'  --------------------------------------------------------------
'  STOCKS
'  --------------------------------------------------------------
If instrument.IsStock THEN
  '  Create a Currency Converted and Split adjust value
  '  of this order's need for equity
  newMarginValue = order.quantity _
                    * order.orderPrice _
                    * instrument.conversionRate _
                    * instrument.stockSplitRatio
 
  If ( test.totalMargin _
        + newMarginValue _
        + system.openOrderMargin ) > ( test.totalEquity _
                                      * maxMarginEquity THEN
    '  Create a Currency Converted value of this
    '  order's need for equity
     message = AsString( test.currentDate ) _
              + " Symbol " _
              + instrument.symbol _
              + " Cannot add " _
              + AsString( newMarginValue, 2 ) _
              + " additional purchase equity with cash of " _
              + AsString( test.cash, 2 ) _
              + " max threshold of " _
              + AsString( maxMarginEquity, 2 ) _
              + " and open orders of " _
              + AsString( system.openOrderMargin, 2 )
    '  Reject This Order
    order.Reject( message )
 
    '  Send the message to Log Window & Print Ouput.csv log
    PRINT message
  ENDIF '  > available equity
ENDIF '  i.IsStock

 

 


Edit Time: 4/6/2017 02:16:44 PM


Topic ID#: 443

 

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