% price of the last candle

Mcanabal

Member
Could somebody help me with a way to plot a series of % variation of price of the last candle in the graphic like a line or doted line (something similar to MMM indicator), but with predetermined %. Example: +/- 5%, +/-7% or +/- 10%

I mean both posibilities at the same time +% and -%
 
Thanks!!! Buddy but should be porcentage (%), because is for a strategy for earnings based in different fixed % movements ....... not dolar movements, in that case I already use the MMM indicator which is based in $ movements however in ranges of % also see that is working very nice
 
Thanks!!! Buddy but should be porcentage (%), because is for a strategy for earnings based in different fixed % movements ....... not dolar movements, in that case I already use the MMM indicator which is based in $ movements however in ranges of % also see that is working very nice

See if this helps

Screenshot-2022-10-26-140024.png
Ruby:
input percent1 = 5;
input percent2 = 7;
input percent3 = 10;
input showbubbles = yes;

def bubblemover   = 3;
def bm  = bubblemover;
def bm1 = bm + 1;
DefineGlobalColor("H", Color.GREEN);
DefineGlobalColor("L", Color.RED);
def lastprice  = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then close else Double.NaN);

plot hpercent1 = lastprice + (lastprice * percent1 / 100);
plot lpercent1 = lastprice - (lastprice * percent1 / 100);
hpercent1.SetDefaultColor(GlobalColor("H"));
lpercent1.SetDefaultColor(GlobalColor("L"));
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), hpercent1, percent1 + "%", hpercent1.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), lpercent1, percent1 + "%", lpercent1.TakeValueColor());

plot hpercent2 = lastprice + (lastprice * percent2 / 100);
plot lpercent2 = lastprice - (lastprice * percent2 / 100);
hpercent2.SetDefaultColor(GlobalColor("H"));
lpercent2.SetDefaultColor(GlobalColor("L"));
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), hpercent2, percent2 + "%", hpercent2.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), lpercent2, percent2 + "%", lpercent2.TakeValueColor());

plot hpercent3 = lastprice + (lastprice * percent3 / 100);
plot lpercent3 = lastprice - (lastprice * percent3 / 100);
hpercent3.SetDefaultColor(GlobalColor("H"));
lpercent3.SetDefaultColor(GlobalColor("L"));
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), hpercent3, percent3 + "%", hpercent3.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), lpercent3, percent3 + "%", lpercent3.TakeValueColor());
 
This is amazing, now the question is: this % are based on the last price or last candle????? if it so that is all that I need!!!!, otherwise is perfect!!!!
 
Last edited:
This is amazing, now the question is: this % are based on the last price or last candle????? if it so that is all that I need!!!!

The close on the last candle printed/showing on the chart. Just change the def lastprice to:

Code:
plot lastprice  = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then close else Double.NaN);
 
can you give me a little help with it???..... something like this.....

https://tinypic.host/i/new.giPk2

See if this helps

Screenshot-2022-10-28-145331.png
Ruby:
input percent1 = 5;
input percent2 = 7;
input percent3 = 10;
input showbubbles = yes;

def bubblemover   = 3;
def bm  = bubblemover;
def bm1 = bm + 1;
DefineGlobalColor("H", Color.GREEN);
DefineGlobalColor("L", Color.RED);
def bn = barnumber();
def lastbar   = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then bn else Double.NaN);
def lastprice = if isnan(close)
                then lastprice[1]
                else if bn >= lastbar
                then close
                else double.nan;

plot lprice   = lastprice;

plot hpercent1 = lastprice + (lastprice * percent1 / 100);
plot lpercent1 = lastprice - (lastprice * percent1 / 100);
hpercent1.SetDefaultColor(GlobalColor("H"));
lpercent1.SetDefaultColor(GlobalColor("L"));
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), hpercent1, percent1 + "%", hpercent1.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), lpercent1, percent1 + "%", lpercent1.TakeValueColor());

plot hpercent2 = lastprice + (lastprice * percent2 / 100);
plot lpercent2 = lastprice - (lastprice * percent2 / 100);
hpercent2.SetDefaultColor(GlobalColor("H"));
lpercent2.SetDefaultColor(GlobalColor("L"));
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), hpercent2, percent2 + "%", hpercent2.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), lpercent2, percent2 + "%", lpercent2.TakeValueColor());

plot hpercent3 = lastprice + (lastprice * percent3 / 100);
plot lpercent3 = lastprice - (lastprice * percent3 / 100);
hpercent3.SetDefaultColor(GlobalColor("H"));
lpercent3.SetDefaultColor(GlobalColor("L"));
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), hpercent3, percent3 + "%", hpercent3.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(close[bm1]) and IsNaN(close[bm]), lpercent3, percent3 + "%", lpercent3.TakeValueColor());
 

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