OMX_F_MSRatio (Series Function)
Previous  Top  Next

Summary:
OMX_F_MSRatio is a fitness function that measures the consistency of returns over time. Call this function in the Epilog to compute a fitness value.

Prototype:
 
OMX_Fitness = OMX_F_MSRatio( PeriodTypePeriodsBackbDoComputation ) ;  

Parameters:

Name
Type
Possible Values
Description
PeriodType
NumericSimple
1, 2, 3
The type of period used. 1=daily, 2=weekly, 3=monthly
PeriodsBack
NumericSimple
1-10,000
The number of periods to use. If less than 2 it uses all periods in the back test.
bDoComputation
TrueFalseSimple
True/False
When true the computation is performed; usually passed the value LastBarOnChart
 

Function Type: Series
This is a series function - it executes every bar.

Returns (Double)
This function returns a floating-point value from 0 to 1, with values approaching 1 indicating consistency and approaching 0 meaning inconsistency in returns.

Description and Use:
This is a modified Sharpe Ratio function. Like the original Sharpe Ratio, this is a time-based measure of consistency of equity returns. It will assess the consistency of your gains over a period of days, weeks or months. Like the original Sharpe, the higher the return value from this function, the more consistent the returns are over the given set of periods. The lower the value, the more inconsistent the returns are.

Use this function when you want your strategy to achieve consistent returns and it does not exhibit large draw downs (for example, due to tight stops.)

Formula:
sharpratioformula  
where  
RI
Return for period I
MR
Mean of return set R
N
Number of Periods
SD
Period Standard Deviation
RRF
Period Risk Free Return
 


Examples:
On the last bar of the chart, compute the MSRatio based on daily returns over all periods in the back test:

OMX_Fitness = OMX_F_MSRatio( 1, 0, LastBarOnChart ) ;  

On the last bar of the chart, compute the MSRatio based on weekly returns for the last 52 weeks in the back test:

OMX_Fitness = OMX_F_MSRatio( 2, 52, LastBarOnChart ) ;  
 
On the last bar of the chart, compute the MSRatio based on monthly returns for all months in the back test:

OMX_Fitness = OMX_F_MSRatio( 3, 0, LastBarOnChart ) ;  

Bar Validity:
Valid on intraday, daily, weekly and monthly bars. Invalid on tick, volume and point & figure charts.

Notes:
This Sharpe calculation is a variant of the original - it is not the standard Sharpe ratio. Since this number is to be used as a fitness value, the objective of this calculation is only to determine how consistent the returns are over a given period of time. It purposefully leaves out the risk-free return portion of the original Sharpe calculation, as that is much less relevant to the requirement for determining fitness, and is only an approximation and varies from month to month in reality.

Do not pass the constant True
as the last parameter. Doing so will cause the calculation to be computed on every bar and significantly slow down your optimization.