This item creates three metrics when analyzing a list of trading rules.
The object classify trading rules output or return into three categories.
The categories are:
Position whose holding period is below 10 bars
Position whose holding period is below 40 bars
Position whose holding period is above 40 bars
Of course these thresholds can be modified.
To do so, just update the two variables: threshold_1 and threshold_2.
As you may have noticed this item is of no use when using an N-Bars stop, because with this kind of stop the holding period is already known.
If you choose for example a trailing stop as positions exit, you will get three metrics where the first one will calculate the average output value for the positions where the holding period is below or equal to 10...
How it works: (Holding period return)
The object skims through all the generated positions and performs a test on each one.
It gets the number of bars value (NbBars) and compares it to the thresholds, then adds it to the appropriate variable (sum1, sum2 or sum3).
The sum1 contains the sum of all outputs, while count1 contains the sum of all holding periods.
The item then divides 'sum1' by 'count1' and creates the metric using the 'Functions.AddMetric' function.