Charted % levels

mjvdet13

New member
I apologize if this is a repeat because it probably has but is there an available code that will automatically chart +/- .5%, 1%, 2% etc levels both up and down from previous close on any given symbol? It's tedious doing the mental math every day and it would be an extrodinary help
 
Solution
I apologize if this is a repeat because it probably has but is there an available code that will automatically chart +/- .5%, 1%, 2% etc levels both up and down from previous close on any given symbol? It's tedious doing the mental math every day and it would be an extrodinary help

1. The mode_timeframe allows you to use the aggregation of the chart displayed or the one input
2. Based upon the start_percent input, there are 7 levels, up/down. More can be easily added.
3. Optional bubbles can be moved sideways.

Screenshot 2024-02-24 104908.png

Code:
# HorizonalLines_Multiple_Percentage

input mode_timeframe    = {default input_agg, chart_agg};
input start_percentage  = .5;
input price             = FundamentalType.CLOSE;
input offset            =...
I apologize if this is a repeat because it probably has but is there an available code that will automatically chart +/- .5%, 1%, 2% etc levels both up and down from previous close on any given symbol? It's tedious doing the mental math every day and it would be an extrodinary help

1. The mode_timeframe allows you to use the aggregation of the chart displayed or the one input
2. Based upon the start_percent input, there are 7 levels, up/down. More can be easily added.
3. Optional bubbles can be moved sideways.

Screenshot 2024-02-24 104908.png

Code:
# HorizonalLines_Multiple_Percentage

input mode_timeframe    = {default input_agg, chart_agg};
input start_percentage  = .5;
input price             = FundamentalType.CLOSE;
input offset            = 1;
input aggregationPeriod = AggregationPeriod.DAY;

def mode_price = if mode_timeframe == mode_timeframe.input_agg
                 then Fundamental(price, period = aggregationPeriod)[offset]
                 else Fundamental(price)[offset];

def zero_price = if IsNaN(close) then zero_price[1] else mode_price;

plot zero = if !IsNaN(close) then Double.NaN else zero_price;

plot pz1  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 1;
plot pz2  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 2 ;
plot pz3  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 3;
plot pz4  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 4;
plot pz5  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 5;
plot pz6  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 6;
plot pz7  =  if !IsNaN(close) then Double.NaN else zero_price + Round(zero_price * (start_percentage / 100)) * 7;

plot pz1_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 1;
plot pz2_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 2 ;
plot pz3_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 3;
plot pz4_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 4;
plot pz5_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 5;
plot pz6_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 6;
plot pz7_  =  if !IsNaN(close) then Double.NaN else zero_price - Round(zero_price * (start_percentage / 100)) * 7;

input bubble = yes;
input bubblemover = 3;
def   mover = bubble and IsNaN(close[bubblemover]) and !IsNaN(close[bubblemover + 1]);
AddChartBubble(mover, zero,  "0%",  zero.TakeValueColor());
AddChartBubble(mover, pz1, AsPercent(start_percentage / 100 * 1), pz1.TakeValueColor());
AddChartBubble(mover, pz2, AsPercent(start_percentage / 100 * 2), pz2.TakeValueColor());
AddChartBubble(mover, pz3, AsPercent(start_percentage / 100 * 3), pz3.TakeValueColor());
AddChartBubble(mover, pz4, AsPercent(start_percentage / 100 * 4), pz4.TakeValueColor());
AddChartBubble(mover, pz5, AsPercent(start_percentage / 100 * 5), pz5.TakeValueColor());
AddChartBubble(mover, pz6, AsPercent(start_percentage / 100 * 6), pz6.TakeValueColor());
AddChartBubble(mover, pz7, AsPercent(start_percentage / 100 * 7), pz7.TakeValueColor());

AddChartBubble(mover, pz1_, AsPercent(-start_percentage / 100 * 1), pz1_.TakeValueColor());
AddChartBubble(mover, pz2_, AsPercent(-start_percentage / 100 * 2), pz2_.TakeValueColor());
AddChartBubble(mover, pz3_, AsPercent(-start_percentage / 100 * 3), pz3_.TakeValueColor());
AddChartBubble(mover, pz4_, AsPercent(-start_percentage / 100 * 4), pz4_.TakeValueColor());
AddChartBubble(mover, pz5_, AsPercent(-start_percentage / 100 * 5), pz5_.TakeValueColor());
AddChartBubble(mover, pz6_, AsPercent(-start_percentage / 100 * 6), pz6_.TakeValueColor());
AddChartBubble(mover, pz7_, AsPercent(-start_percentage / 100 * 7), pz7_.TakeValueColor());

#
 
Solution

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