Skip to main content

BoH Risk Aversion Indicator for Amibroker (AFL)

genkumag over 14 years ago Amibroker (AFL)

  • Rating:
    4 / 5 (Votes 4)
  • Tags:
    oscillator, amibroker

Betting on Harmonics replicated RGE’s Risk Aversion Indicator which is a macro approach for measuring investors’ risk appetite. The indicator is computed by taking the correlation between rank of returns and volatility in the market over the past 21 days. Being a correlation, the indicator oscillates between -1 and 1.

This is an excellent addition to one’s tool box for gauging risk appetite using market volatility.

http://genkumag.wordpress.com/

Screenshots

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN( "BoH Risk Aversion Indicator" );

//MyPercentRank Function as Coded by Ramon Cummins
function MyPercentRank( Data, Periods )
{
    Count = 0;
    for( i = 1; i < Periods + 1 ; i++ )
    {
        Count = Count + IIf( Ref( Data, 0 ) > Ref( Data, -i ), 1, 0 );
    }
    return 100 * Count / Periods;
}

function RAI( Length )
{
    PCHG		= ( C / Ref( C, -1 ) );
    xRR		 	= MyPercentRank( PCHG, 252 );
    Vol			= StDev( PCHG, 252 ) * 3.1;
    xRAI		= Correlation( xRR, Vol, Length );
    return xRAI;
}

//RAI Plot
Length	= Param( "Correlation Period", 21, 1, 300, 1 );
xRAI	= RAI( Length );
Plot( xRAI, "", colorGreen, styleThick );
Plot( 0, "", colorDarkRed, styleThick | styleNoLabel );
Plot( 0.2, "", colorDarkRed, styleDashed | styleNoLabel );
Plot( -0.2, "", colorDarkRed, styleDashed | styleNoLabel );

_SECTION_END();

6 comments

over 14 years ago

Values above 0.20 correspond to RISK TAKING
Values below -0.20 correspond to RISK AVERSE
Values between -0.20 and 0.20 correspond to RISK NEUTRAL

2. ole
over 14 years ago

Get error unless change name of PercentRank() which is a built-in function but it is not needed as it is exactly the same result as the built-in.

over 8 years ago

@admin

dear sir, can you please correct the code…it ain’t working sir.

i’ll be very grateful of you .

thanks.

over 8 years ago

Try it now. I have renamed the rank function from ‘PercentRank’ to ‘MyPercentRank’. If your Amibroker version is not ancient you can remove the function altogether and use the built in version.

Leave Comment

Please login here to leave a comment.