Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Rotation Factor – Amibroker AFL Code

1 min read

The rotation Factor is a sentimental indicator used in Market Profile to Indicate who is controlling (Buyers/Sellers) the market for the day. If the rotational factor prints positive values every day then it means buyers are in control of the market. Negative Values indicate sellers are in control. The same principle can be applied to investing as well.

How Rotation Factor is Calculated?

1)Rotational Factors Starts with Zero on the first bar

2)In the next bar onwards the Rotational Factor is calculated as shown below

ConditionPoints
Current Bar makes High High and Higher Low+2 points
Current Bar makes Low High and Lower Low-2 Points
Current Bar makes Higher High and Lower Low0 Points
Current Bar makes Lower High and Higher Low0 Points
Curr High and Prev High is Equal and Higher Low+1 Points
Current Bar Makes Higher High but Curr and Pre lows are equal+1 Points
Current Bar Makes Lower High and Current and Prev Equal Lows-1 Points
Current Bar Makes Equal Curr and Prev High and Lower Lows-1 Points

So the rotation factor for each and every bar takes values ranging from +2 to -2. And During the day you should keep tracking of the running (cumulative) total of the rotation factors.

3)cumulatively Rotational Factor is calculated and plotted in 30min timeframe as shown below

Nifty Futures 30min

Rotational Factor – Amibroker AFL Code

///////////////////////////////////
//Coded by Rajandran R
//Date : 05th July 2015
//www.marketcalls.in
///////////////////////////////////

_SECTION_BEGIN("Rotation 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();

Sample Principle Can be applied to Monthly Charts also. Here in this case Rotational Factors Start with Zero on the first day of the month and vary cumulatively for each and every day.

RCOM Futures
RCOM Futures – EOD Charts

Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

CUSUM Filter Strategy in AmiBroker AFL: A Practical Implementation

Detecting meaningful shifts in price trends while filtering out market noise is a challenge many traders face. Inspired by Jakub Polec’s blog, which applies...
Rajandran R
2 min read

Diffusion Innovation Theory and Market Profile

The Diffusion of Innovation Theory and Market Profile are two powerful frameworks that, when combined, can provide traders with deeper insights into market behavior...
Rajandran R
3 min read

Long-Term Auctions vs. Intermediate-Term Auctions in Market Profile

In Market Profile analysis, both long-term and intermediate-term auctions help traders identify market trends, though they represent different timeframes and scales of market activity....
Rajandran R
5 min read

34 Replies to “Rotation Factor – Amibroker AFL Code”

  1. hello

    really good idea. but it doesn’t incorporate spread ( high – low ) and or volume in the above equation .

    either spread may be incorporated or diff in consecutive closes may also be incorporated.

    also the process of starting every month afresh doesnt seem logical instead ( for eod only ) a better idea would
    to specify no of bars like 220 ( for longer term ) and 70 for medium term . and 20 for shorter term in that way the above may be more logical .

    rgds

    amit

    1. Rotation Factor is a concept in Market Profile. You can bend it with your own market experience. There are no rules here!

    1. For the current bar it is always recommended to check after bar closing. However it doesn’t repaints for previous bars.

    2. You can convert the code the non repainting by modifying the code on line no 69 as

      Plot(ref(RF,-1),”Rotational Factor”, IIf(RF>0,colorGreen,colorRed),styleHistogram | stylethick);

  2. Hi, Can you please share any websites where we can view live NSE futures both Index and stock futures charts with technical indicators to analyse? I saw the futures charts in your site as well but there is no option to add technical indicators here and that is why I ask you to refer some other sites as well. Thanks

      1. Thank you. are the charts in the above mentioned link are live or delayed? if delayed then howmuch delay?

  3. hi, Sorry, you can ignore my previous comment except “Thank you” Because you had already mentioned in your comment that as “… live charts..” I noted it now. Thanks again

      1. Hi Thank you.
        Could you please guide on creating an afl to scan/explore and plot trendlines and trendline breakout in closing price. It would be of great help if you could guide me on that

  4. Hi Mr.Rajendran,

    Iam new to tradin. I have gone through your articles its awsome.Could you please tell me what minute we have to follow in order to understand the Rotational Factor. And if its +2 can we buy from the second candle or vice versa. Could you please give me a reply on this.
    Thank You,

    Manoj George

        1. Hi I am not able to view Nifty option contracts and stock option contracts. I followed the instructions provided in the charts page but nifty and stock option contracts are not displayed. Please help me in getting the option contract charts. Thanks

          1. You can get the Nifty Options and Stock Option Contacts here live marketcalls.in/charts
            we are not providing EOD charts at this point.

          2. Hi,
            Nifty options contract symbols are not available. You may please check it.

            NIFTY15FEB8500CE- This is the format that is suggested in that charts page. But No Nifty options contracts are there. Check for NIFTY15JUL8300CE contract and let me know if you can find it. Or correct me if I am wrong. Thanks in advance

          3. Dear Rajendran, That is how I tried. I am not able to fine the Nifty options charts. If you want I can share the screen shot. I dont know why it is not displaying it for me. Could you please check it again as normal user instead of admin.
            I really wonder why it is not displaying it for me.

          4. Hi,
            It is working now. Thanks.
            I need your guidance on something.
            Say based on my analysis I feel if Nifty breakouts @ 8500 it might hit 8600 So here my entry point is 8500 and exit/target is 8600. How to convert this in to option contracts for various strike prices? Hope you get my point.
            (This is just an example)

          5. Hi Rajendran,
            I have a small doubt in Options Open interest. How to find out howmany number of Longs are in place, howmany number of shorts in place and howmany contracts have been transfered from old buyer/seller to new seller/buyer , by looking at the OI and volume? Is it possible to find out? if so please share how?
            Thanks

          6. Hi Yeah I have seen that. It doesnt have information about shorts covered and longs closed

  5. I need your guidance on something.
    Say based on my analysis I feel if Nifty breakouts @ 8500 it might hit 8600 So here my entry point is 8500 and exit/target is 8600. How to convert this in to option contracts for various strike prices? Hope you get my point.
    (This is just an example)

  6. Hi Rajendran,
    Where can we get historical Option contract charts with technical indicators? both lower time like 5 min 30 min and daily, weekly chart. Please through some light. Thanks

  7. Hi Could you please explain about “Long unwinding” with an example. I read about this in internet but I could not find the the meaning of “unwinding” in “Long unwinding” definition. It would be great if you could explain about Long unwinding

    Regards

  8. Sir.. Can you please share the AFL for calculating yday POC and day before yday POC? . Tks for your help

  9. hi.sir. i like your ROTATIONAL FACTOR idea very much. it is really very good and dont need any other market study or chart study. it is depend on live rate not on trend. i like it very much. thank you much for giving such idea.

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More