This risk manager allows you to select a maximum amount of risk you want at any given time, and then a method of reducing positions if your risk is too great.  If you choose "Reduce Positions" this block will sell a portion of your units to reduce to below the maximum.  If you select "Move Stops" the system will set new stops based on the maximum risk and place orders accordingly.

 

Total Risk Limiter Parameters:

Total Risk Limiter Parameters

 

Parameters:

Descriptions:

Maximum Risk Threshold %

Enter the maximum amount of risk as a percentage that this blox should limit.

Reduction Algorithm

Blox provide two methods for reducing the percentage of risk being publised by the open risk to current trading equity amount.

 

Option 1:  Reduce Position:

This option will reduce the position's current quantity using the percentage value entered into the "Maximum Risk Threashold %."

 

Option 2:  Move Stops:

Distance between the current close and the position's protective risk price determines how many position points are at risk.  Risk points are converted to a monetary value so that it can be expanded by the number of quantity contained in the position.  Once the amount of risk in monetary terms is understood it is divided by the System's Trading Equity series element for the each trade day so that a current open risk rate can be determined.

Note:

The following expression determines the amount by which risk is reduced when the threshold is breached:

 

                Reduction Amount = (Portfolio Risk - Max Risk Threshold) / Portfolio Risk

 

Example:

When current risk is 40% and the maximum threshold is 30%, then risk will be reduced by: (40% - 30%) / 40% = 25%.

 

Reducing all current position sizes by 25%, or reducing each stop offset distance (current price to the current exit) by 25% brings the position risk back to 30%.

 

 

 

Total Risk Manager Control Logic - INITIALIZE RISK MANAGER:

  '  ==============================================================
  '  Total Risk Limiter
  '  INITIALIZE RISK MANAGER SCRIPT - START
  '  ==============================================================
  '  Clear Total Risk Accumulator
  totalRisk = 0
  '  ==============================================================
  '  INITIALIZE RISK MANAGER SCRIPT - END
  '  Total Risk Limiter
  '  ==============================================================

COMPUTE INSTRUMENT RISK

  '  ==============================================================
  '  Total Risk Limiter
  '  COMPUTE INSTRUMENT RISK SCRIPT - START
  '  ==============================================================
  ' Add the instrument risk to the total risk.
  totalRisk = totalRisk + instrument.currentPositionRisk
  '  ==============================================================
  '  COMPUTE INSTRUMENT RISK SCRIPT - END
  '  Total Risk Limiter
  '  ==============================================================

COMPUTE RISK ADJUSTMENTS:

  '  ==============================================================
  '  Total Risk Limiter
  '  COMPUTE RISK ADJUSTMENTS SCRIPT - START
  '  ==============================================================
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  If system.tradingEquity > 0 THEN
    '  Compute the current risk.
     riskPercent = totalRisk / system.tradingEquity
 
    '  If the risk is above our threshold...
    If riskPercent > maximumRiskThreshold THEN
        reductionPercent = (riskPercent - maximumRiskThreshold) _
                                / riskPercent
    ELSE
        reductionPercent = 0.0
    ENDIF
  ELSE
     reductionPercent = 0.0
  ENDIF
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  ==============================================================
  '  COMPUTE RISK ADJUSTMENTS SCRIPT - END
  '  Total Risk Limiter
  '  ==============================================================

ADJUST INSTRUMENT RISK:

  '  ==============================================================
  '  Total Risk Limiter
  '  ADJUST INSTRUMENT RISK SCRIPT - START
  '  ==============================================================
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  REDUCE POSITION QUANTITY
  '  --------------------------------------------------------------
  '  If we need to reduce risk
  If reductionPercent > 0.0 THEN
    If reductionAlgorithm = REDUCE_POSITIONS THEN
        '  Reduce the position by this amount.
        broker.AdjustPositionOnOpen( 1.0 - reductionPercent )
    ENDIF
    '  -----------------------------------------------------------
    '  LONG POSITION - MOVE STOP CLOSER
    '  -----------------------------------------------------------
    If reductionAlgorithm = MOVE_STOPS THEN
        If instrument.position = LONG THEN
          '  Adjust the stops for each unit.
          For index = 1 TO instrument.currentPositionUnits
              '  Determine the current risk.
              risk = instrument.close - instrument.unitExitStop[ index ]
              '  Determine the stop that corresponds with the reduced risk.
              newStop = instrument.close - ((1 - reductionPercent) * risk)
              '  Set the new stop.
              instrument.SetExitStop( index, newStop )
              broker.ExitUnitOnStop( index, newStop )
          Next
        ENDIF ' Long
    '  -----------------------------------------------------------
    '  SHORT POSITION - MOVE STOP CLOSER
    '  -----------------------------------------------------------
        If instrument.position = SHORT THEN
          '  Adjust the stops for each unit.
          For index = 1 TO instrument.currentPositionUnits
              '  Determine the current risk.
              risk = instrument.unitExitStop[index] - instrument.close
              '  Determine the stop that corresponds with the reduced risk.
              newStop = instrument.close + ((1 - reductionPercent) * risk)
              ' Set the new stop.
              instrument.SetExitStop( index, newStop )
              broker.ExitUnitOnStop( index, newStop )
          Next
        ENDIF '  Short
    ENDIF '  Algorithm Move Stops
  ENDIF '  There is a reduction required
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  ==============================================================
  '  ADJUST INSTRUMENT RISK SCRIPT - END
  '  Total Risk Limiter
  '  ==============================================================

 


Edit Time: 9/20/2017 07:56:26 AM


Topic ID#: 227

 

 

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