|Top Previous Next|
MEMORY = 0
~POSITION 'initialize the category
IF (RISK / TOTALEQUITY) > MEMORY THEN MEMORY = _
(RISK / TOTALEQUITY)
~POSITION 'reinitialize the category and run through all
'the positions again; reduce the one with the highest risk if >10%
IF MEMORY > .1 AND RISK / TOTALEQUITY = MEMORY THEN MULTIPLIER = .9
The first line of code, MEMORY = 0, clears the memory variable at the start of each day.
The second line of code under the Position category checks the risk in each position, and if it is the highest risk yet seen, saves it (assigns it's value to MEMORY). Once all the positions have been processed the one whose risk is the largest % of equity has it's % stored in MEMORY
The value of MEMORY persists across categories, and in the second position category, if the position with the highest risk, indeed risks more than 10% of equity, then reduce it's size by 10%.
For instance, you may wish to “pyramid” into an existing position when it reaches a certain level of profitability. In this case, for example, use SIZING[n] as a “flag,” and set it equal to 1 when the condition is true, and zero when the condition is false. Then, use that information like this:
IF SIZING = 1 THEN MULTIPLIER = 1.25