Average Price Movements Indicator for ThinkorSwim

HI @BenTen , Can I request for a small update? This script gives the high and low range of average ADR.
Based on current price value, I would like to show the following in the label. The current price and how much percentage of average ADR it has moved so far. If the price is above open, then the label can be green and vice versa. Thank you in advance


Label: the current price and how much percentage of average ADR it has moved so far.
zaeJIoF.png

Ruby:
# Average Price Movements
# Assembled by BenTen at useThinkScript.com
# Converted from TradingView version
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;

input aggregationPeriod = AggregationPeriod.DAY;
def o = open(period = aggregationPeriod);
def h = high(period = aggregationPeriod);
def l = low(period = aggregationPeriod);
def dayrange = (h - l);

def r1 = dayrange[1];
def r2 = dayrange[2];
def r3 = dayrange[3];
def r4 = dayrange[4];
def r5 = dayrange[5];
def r6 = dayrange[6];
def r7 = dayrange[7];
def r8 = dayrange[8];
def r9 = dayrange[9];
def r10 = dayrange[10];

def adr_10 = (r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8 + r9 + r10) / 10;
def adr_5 = (r1 + r2 + r3 + r4 + r5) / 5;

def hl1 = (o + (adr_10 / 2));
def ll1 = (o - (adr_10 / 2));
def hl2 = (o + (adr_5 / 2));
def ll2 = (o - (adr_5 / 2));

plot upper2 = if ShowTodayOnly and !Today then Double.NaN else hl1;
plot lower1 = if ShowTodayOnly and !Today then Double.NaN else ll2;
plot upper1 = if ShowTodayOnly and !Today then Double.NaN else hl2;
plot lower2 = if ShowTodayOnly and !Today then Double.NaN else ll1;

addCloud(if ShowTodayOnly == yes then upper2 else double.nan, upper1, Color.RED, Color.RED);
addCloud(if ShowTodayOnly == yes then lower1 else double.nan, lower2, Color.GREEN, Color.GREEN);

upper1.SetDefaultColor(Color.DARK_RED);
upper2.SetDefaultColor(Color.DARK_RED);
lower1.SetDefaultColor(Color.DARK_GREEN);
lower2.SetDefaultColor(Color.DARK_GREEN);

# ----------------------------------------------------------
# Label showing current price + % of ADR moved
# ----------------------------------------------------------
def price = close;
def moved = AbsValue(price - o);
def adrPercent = if adr_10 != 0 then (moved / adr_10) else 0;

AddLabel(
    yes,
    "Price: " + AsDollars(price) +
    " | ADR: " + AsPercent(adrPercent),
    if price > o then Color.GREEN else Color.RED
);
 

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
608 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