Discussion of article "Mathematics in trading: Sharpe and Sortino ratios" - page 3

 

Read the logarithm of price

You'll find other references yourself

 
Rashid Umarov #:

Read the logarithm of price

You'll find other references yourself

Another extremely important nuance is that in this script, only those bars where there was a change in equity are taken into account in the calculation of the Sharpe:

     
      //--- add only if equity has changed
      if(m_equities[i] != prev_equity)
        {  
         log_return = MathLog(m_equities[i] / prev_equity); // increment logarithm
         aver += log_return;            // average logarithm of increments
         AddReturn(log_return);         // fill the array of incremental logarithms
         counter++;                     // counter of returns
        }
      prev_equity = m_equities[i];

The average change is then found by dividing by the number of such bars:

//--- average value of the increment logarithm
   aver /= counter;

However, the transition to the annual sharps is based on the timeframe ratio, as if all bars of the current tf were counted in the calculation:

//--- recalculate the Sharpe ratio to annual value in all other cases
//--- how many periods of the current timeframe fit into D1
   double factor = double(PeriodSeconds(PERIOD_D1)) / PeriodSeconds(timeframe);
   sharpe = sharpe * MathSqrt(factor);     // recalculate to daily value
   sharpe = sharpe * MathSqrt(252);        // get annual from daily

I.e., once again: the script finds the averaged sharps per 1 bar with equity change, and then, to find the annual one, multiplies it not by the number of such bars in a year, but by the total number of bars of this tf in a year (its root, of course). Which is erroneous and overestimates the final figure.

Apparently, the Sharpe is calculated in the same way in the tester?

 
Kristian Kafarov #:
the script finds the average Sharpe per 1 bar with equity change, and then, to find the annual one, multiplies it not by the number of such bars in a year, but by the total number of bars of this tf in a year (its root, of course). Which is erroneous and overestimates the final figure

I also noticed that. That's why in my version I added an option to take into account zero bars.