Repaints Rotation Factor: Buy/Sell Pressure For ThinkOrSwim

Repaints

VP7

New member
VIP
Greetings,

In the book "Mind Over Markets" Dalton mentions an objective measure of "what is the market trying to do" using a quick calculation. Essentially, this is counting higher high/lows and lower highs/lows on the 30min period. For example, on a 30 min candle chart, if price makes a higher high, we add +1. If it's a lower high, it's a -1. On a lower low it's a -1, and a higher low, +1.

Is there a script that measures this, or something like it. I was hoping to find some measure of "what the market is trying to do" that relies less on subjective interpretation and more on being as objective as possible.

For reference, it's on page 112.

I've attached a picture of the system. I don't need anything to be displayed, just some form of the result.

I did find this on TradingView which is very similar.
https://www.tradingview.com/script/...-Buy-Sell-Pressure-for-Market-Volume-Profile/


Any help is much appreciated.
 

Attachments

  • RotationFactor.png
    RotationFactor.png
    15.4 KB · Views: 392
Last edited:
Greetings,

In the book "Mind Over Markets" Dalton mentions an objective measure of "what is the market trying to do" using a quick calculation. Essentially, this is counting higher high/lows and lower highs/lows on the 30min period. For example, on a 30 min candle chart, if price makes a higher high, we add +1. If it's a lower high, it's a -1. On a lower low it's a -1, and a higher low, +1.

Is there a script that measures this, or something like it. I was hoping to find some measure of "what the market is trying to do" that relies less on subjective interpretation and more on being as objective as possible.

For reference, it's on page 112.

I've attached a picture of the system. I don't need anything to be displayed, just some form of the result.

I did find this on TradingView which is very similar.
https://www.tradingview.com/script/...-Buy-Sell-Pressure-for-Market-Volume-Profile/


Any help is much appreciated.
check the below

CSS:
#// Original calculation and indicator by OasisTrading
#// PineScript V5 conversion by Baus Benchmarks © joebaus
#indicator(title = "Rotation Factor: Buy/Sell Pressure", shorttitle = "Rotation Factor",
# -- Converted by Sam4Cok@Samer800    - 12/2023
declare lower;

input colorBars = yes;
input resetInterval = {"Intraday",Default "Daily", "Weekly", "Monthly"}; #title     = "Reset Interval"
input timeframForIntraday = AggregationPeriod.TWO_HOURS;
input style = {Default "Histogram", "Line", "Area"};
input mergeGaps = no;     # "Merge Gaps"

def na = Double.NaN;
def last = isNaN(close);
def bar = BarNumber();
def chartAgg = GetAggregationPeriod();
def day = GetDay();
def week = GetWeek();
def moth = GetMonth();
def hist = style==style."Histogram";
def line = style==style."Line";
def area = style==style."Area";
def int = timeframForIntraday / chartAgg;
def resetIntra = floor(bar % int) == 1;
def interval;
Switch (resetInterval) {
Case "Intraday" :
    interval = resetIntra;
Case "Weekly" :
    interval = week != week[1];
Case "Monthly" :
    interval = moth != moth[1];
Default :
    interval = day != day[1];
}

DefineGlobalColor("up", CreateColor(76,175,80));
DefineGlobalColor("dn", CreateColor(255,82,82));

script f_plotColor {
    input _rotationFactor = 0;
    def sinRF = sign(_rotationFactor);
    def f_plotColor = if isNaN(sinRF) then 1 else if sinRF < 0 then -1 else 1;
    plot out = f_plotColor;
}

def subscriptIntervalBool = interval;
def h = high;
def l = low;
def one     = (h > h[1])  and (l > l[1]);
def two     = (h < h[1])  and (l < l[1]);
def three   = (h > h[1])  and (l < l[1]);
def four    = (h < h[1])  and (l > l[1]);
def five    = (h == h[1]) and (l > l[1]);
def six     = (h > h[1])  and (l == l[1]);
def seven   = (h < h[1])  and (l == l[1]);
def eight   = (h == h[1]) and (l < l[1]);

def onex    = +2;
def twox    = -2;
def threex  = 0;
def fourx   = 0;
def fivex   = +1;
def sixx    = +1;
def sevenx  = -1;
def eightx  = -1;

def rotationFactor;

if subscriptIntervalBool {
    rotationFactor = if one   then onex else
                     if two   then twox else
                     if three then threex else
                     if four  then fourx else
                     if five  then fivex else
                     if six   then sixx else
                     if seven then sevenx else
                     if eight then eightx else rotationFactor[1];
    } else {
    rotationFactor = if one   then rotationFactor[1] + onex else
                     if two   then rotationFactor[1] + twox else
                     if three then rotationFactor[1] + threex else
                     if four  then rotationFactor[1] + fourx else
                     if five  then rotationFactor[1] + fivex else
                     if six   then rotationFactor[1] + sixx else
                     if seven then rotationFactor[1] + sevenx else
                     if eight then rotationFactor[1] + eightx else rotationFactor[1];
}
def RF = if mergeGaps then if rotationFactor then rotationFactor else RF[1] else rotationFactor;
def plotColor = f_plotColor(RF);
def RF_ = if RF then RF else 0.1;
#// Plots {
plot RotFactorHist = if hist then RF_ else na; # "Rotation Factor"
RotFactorHist.SetLineWeight(4);
RotFactorHist.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
RotFactorHist.AssignValueColor(if plotColor >= 0 then GlobalColor("up") else GlobalColor("dn"));

plot RotFactorLine = if line then RF else na; # "Rotation Factor"
RotFactorLine.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
RotFactorLine.AssignValueColor(if plotColor >= 0 then GlobalColor("up") else GlobalColor("dn"));

plot RotFactorArea = if area then RF else na; # "Rotation Factor"
RotFactorArea.AssignValueColor(if plotColor >= 0 then GlobalColor("up") else GlobalColor("dn"));

AddCloud(if area then RF_ else na, 0, Color.GREEN, Color.RED);

plot zeroLine = if !last and line then 0 else na;
zeroLine.SetDefaultColor(Color.DARK_GRAY);
zeroLine.SetStyle(Curve.SHORT_DASH);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if plotColor > 0 then GlobalColor("up") else GlobalColor("dn"));
#-- END of CODE
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
381 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top