Skip to main content

Rotation Factor for Amibroker (AFL)

mohitjohar almost 8 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 2)
  • Tags:
    amibroker

R Factor is a sentimental indicator used in Market Profile to Indicate who is control (Buyers/Sellers) in the market for the day. If the r factor prints positive values every day then it mean buyers are in control in the market. Negative Values indicates sellers are in control. Same principle can be applied to investing as well.

Screenshots

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN( "R Factor - Market Profile" );

RF = 0;
NewDay = day() != Ref( day(), -1 );

for( i = 1; i < BarCount; i++ )
{
    if( NewDay[i] == True )
    {
        BarsUp[i] = 0;
        BarsDown[i] = 0;
        RF[i] = 0;

    }

	//If Current Bar Makes HH and HL
    if( H[i] > H[i - 1] AND L[i] > L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] + 2;
    }

	//If Current Bar Makes LH and LL
    if( H[i] < H[i - 1] AND L[i] < L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] - 2;
    }

	//If Current Bar Makes HH and LL
    if( H[i] > H[i - 1] AND L[i] < L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1];
    }

	//If Current Bar Makes LH and HL
    if( H[i] < H[i - 1] AND L[i] > L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1];
    }

    if( H[i] == H[i - 1] AND L[i] > L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] + 1;
    }

    if( H[i] > H[i - 1] AND L[i] == L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] + 1;
    }

    if( H[i] < H[i - 1] AND L[i] == L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] - 1;
    }

    if( H[i] == H[i - 1] AND L[i] < L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] - 1;
    }

}

Plot( 0, "", colorred, styleline );
Plot( RF, "Rotational Factor", IIf( RF > 0, colorGreen, colorRed ), styleHistogram | stylethick );

_SECTION_END();

6 comments

2. soigau
almost 8 years ago

Chart does not appear and nothing seems to happen.Plz check. Thanks.

3. yuvi
almost 8 years ago
_SECTION_BEGIN( "R Factor - Market Profile" );

RF = 0;
NewDay = day() != Ref( day(), -1 );

for( i = 1; i < BarCount; i++ )
{
    if( NewDay[i] == True )
    {
        BarsUp[i] = 0;
        BarsDown[i] = 0;
        RF[i] = 0;

    }

	//If Current Bar Makes HH and HL
    if( H[i] > H[i - 1] AND L[i] > L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] + 2;
    }

	//If Current Bar Makes LH and LL
    if( H[i] < H[i - 1] AND L[i] < L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] - 2;
    }

	//If Current Bar Makes HH and LL
    if( H[i] > H[i - 1] AND L[i] < L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1];
    }

	//If Current Bar Makes LH and HL
    if( H[i] < H[i - 1] AND L[i] > L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1];
    }

    if( H[i] == H[i - 1] AND L[i] > L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] + 1;
    }

    if( H[i] > H[i - 1] AND L[i] == L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] + 1;
    }

    if( H[i] < H[i - 1] AND L[i] == L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] - 1;
    }

    if( H[i] == H[i - 1] AND L[i] < L[i - 1] AND !NewDay[i] )
    {
        RF[i] = RF[i - 1] - 1;
    }

}

Plot( 0, "", colorred, styleline );
Plot( RF, "Rotational Factor", IIf( RF > 0, colorGreen, colorRed ), styleHistogram | stylethick );

_SECTION_END();
almost 8 years ago

original author and source link – https://www.marketcalls.in/amibroker/rotation-factor-amibroker-afl-code.html

almost 8 years ago

yuvi – I’m confused, what are you saying? Your post just repeats the original formula, no added value.

almost 8 years ago

the code writen above for intraday. To use it in daily chart, change

day() with
month()

Leave Comment

Please login here to leave a comment.