Documentation>Application Documentation>XMIM Documentation>XMIM Examples>LET, INITIALIZE, FINALIZE Examples

LET, INITIALIZE, FINALIZE Examples
 

LET

Let theVariable = <symbol> [, <symbol>]

Let ATTR theVariable = <attribute>[,<attribute>]


INITIALIZE

The INTIALIZE statement allows you to pre-assign values to a variable to be used later in the query. Anything that needs to be done once, and not over and over every period (depending on the execute units of the query) can be placed in the INITIALIZE block. This is a good place to initialize variables used to count to a starting value of zero.

Example:

   INITIALIZE
      
CSCO crosses above 200 day average of CSCO

    1: ORDER
      1.1: Buy 1 contract of CSCO

   EXIT
      
CSCO is down more than 2 %

 

FINALIZE

The FINALIZE statement block lets you perform calculations after a query has finished running. It can be used to calculate performance statistics on the results of P&L queries, etc.

Example:

INITIALIZE
isUp = 0 AND isNot = 0

FINALIZE
  
pctUp = isUp / ( isUp + isNot )

FINAL SHOW
  
1: pctUp * 100
  
2: isUp
  
3: isNot

LET theSym = GII.IBM.NYSE, DELL, DOW

DO every 1 unit
  
Date is theSym last data day
  
and if 1 day move of Close of theSym > 0 then isUp =  isUp + 1 ELSE isNot
= isNot + 1 ENDIF