# Rotation Factor Label

#### Whizz

##### New member
Hello does anyone have or can make a script that calculates the rotation factors in a 30 min TPO?

If the high of the current time period is higher than the previous period’s high, then the rotation is given a +1. If the high is lower than the previous period’s high, then it is assigned a -1. Similarly, if a time period’s low is higher than the previous period’s low, then a value of +1 is added. An auction bottom that is lower than the previous period’s low receives a -1. And if both periods’ highs or lows come out even, then no value, or 0, is assigned.
With 3 labels Top Total(TT), Bot Total(BT), Overall RF(ORF), and if the labels are positive they will be green, negative red, and white for even

Solution
Hello does anyone have or can make a script that calculates the rotation factors in a 30 min TPO?

If the high of the current time period is higher than the previous period’s high, then the rotation is given a +1. If the high is lower than the previous period’s high, then it is assigned a -1. Similarly, if a time period’s low is higher than the previous period’s low, then a value of +1 is added. An auction bottom that is lower than the previous period’s low receives a -1. And if both periods’ highs or lows come out even, then no value, or 0, is assigned.
With 3 labels Top Total(TT), Bot Total(BT), Overall RF(ORF), and if the labels are positive they will be green, negative red, and white for even

i think this...
Hello does anyone have or can make a script that calculates the rotation factors in a 30 min TPO?

If the high of the current time period is higher than the previous period’s high, then the rotation is given a +1. If the high is lower than the previous period’s high, then it is assigned a -1. Similarly, if a time period’s low is higher than the previous period’s low, then a value of +1 is added. An auction bottom that is lower than the previous period’s low receives a -1. And if both periods’ highs or lows come out even, then no value, or 0, is assigned.
With 3 labels Top Total(TT), Bot Total(BT), Overall RF(ORF), and if the labels are positive they will be green, negative red, and white for even

i think this will do what you are asking,
count the stats during 2nd aggregation time periods. default is 30 minutes

high > high[1] , +1
high < high[1] , -1
low > low{1] , +1
low < low[1] , -1
high = high[1] , 0
low = low[1] , 0

Code:
# hilo_chg_rotation_factor_01

#Rotation Factor Label
#Whizz  Jul 31, 2022

#does anyone have or can make a script that calculates the rotation factors in a 30 min TPO?

# If the high of the current time period is higher than the previous period’s high, then the rotation is given a +1.
# If the high is lower than the previous period’s high, then it is assigned a -1.
# if a time period’s low is higher than the previous period’s low, then a value of +1 is added.
# if a current low is lower than the previous period’s low receives a -1.
#  And if both periods’ highs or lows come out even, then no value, or 0, is assigned.

# high > high[1] , +1
# high < high[1] , -1
# low > low{1] , +1
# low < low[1] , -1
#  high = high[1] , 0
#  low = low[1] , 0

# With 3 labels
#  Top Total(TT),
#  Bot Total(BT),
#  Overall RF(ORF)

# if the labels are positive they will be green, negative red, and white for even

def bn = barnumber();

input agg = AggregationPeriod.thirty_min;
def close_agg = close(period = agg);
def high_agg = high(period = agg);
def low_agg = low(period = agg);

def highcnt = if high_agg > high_agg[1] then highcnt[1] + 1 else if high_agg < high_agg[1] then highcnt[1] -1 else 0;
def lowcnt = if low_agg > low_agg[1] then lowcnt[1] + 1 else if low_agg < low_agg[1] then lowcnt[1] - 1 else 0;
def total = highcnt + lowcnt;

def periods = if bn == 1 then 1 else if close_agg != close_agg[1] then periods[1] + 1 else periods[1];

addlabel(1, "High count " + highcnt, (if highcnt > 0 then color.green else if highcnt < 0 then color.red else color.gray));
addlabel(1, "Low count " + lowcnt, (if lowcnt > 0 then color.green else if lowcnt < 0 then color.red else color.gray));
addlabel(1, "Total count " + total, (if total > 0 then color.green else if total < 0 then color.red else color.gray));
addlabel(1, "Periods " + periods, color.yellow);
#

notehalcyonguy: thanks, I changed it to a 3 minute aggregation label on a 1 day TOS chart ( for options charts) along with some momentum indicators- it makes for a nice visual label to easily follow new highs and lows. suggest others pay attention to this count script. Again Halcyonguy your creativity is quite evident, and U seem to keep your code very straightforward. Best to all !

87k+ Posts
117 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?