Determinate a specific script for a specific candle.

niklashark13

New member
Hi everyone.

I want to know if there´s a way to develop an indicator that shows the candle size (Calculate from its Higher price to its Lower price), and specify the amount (dollars or cents) of this bar.

To be more accurate on my requirement let’s suppose in the 2 minutes price chart, the first candle at the very beginning of market have this characteristic:

-Opened: 13,5

-Higher: 14,41

-Lower: 13,34

-Closed: 14,34

What I need, is an indicator than show me that the first bar has a length of 1,07 usd (difference between 14,41-13,34) but all in the graphic chart.


I´ve used this example:

¨declare lower;

input length = 1;

plot AverageBodyHeight = Average(BodyHeight(), length);¨



But in this case, first of all, it takes the close and open price of the bar and second, it is a study and I want to see this information on the first candle as a script on the chart price.

Thank you!
 
Am I reading this right; you want the high-low range of just the first bar in a graph?

nt38mUw.png


For some reason, I don't think this is what you're truly after.
Could you please clarify?
 

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

Thank you for your participation.

The pic below shows my requirement exactly how I need.

example.jpg

But the second image is what i have ring know, so i´m stuck. 1-It doesn’t take the High and low, and 2- is in a study space.
example-2.jpg

Rgds
 
Thank you for your participation.

The pic below shows my requirement exactly how I need.

example.jpg

But the second image is what i have ring know, so i´m stuck. 1-It doesn’t take the High and low, and 2- is in a study space.
example-2.jpg

Rgds

See if this works how you would like it.

Capture.jpg
Ruby:
def bn    = BarNumber();
def first = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
            then bn
            else first[1];

def h     = if bn == HighestAll(first) then high else Double.NaN;
plot xh   = if Between(bn, HighestAll(first) - 5, HighestAll(first))
            then HighestAll(h)
            else Double.NaN;
xh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xh.setdefaultColor(color.gray);

def l     = if bn == HighestAll(first) then low else Double.NaN;
plot xl   = if Between(bn, HighestAll(first) - 5, HighestAll(first))
            then HighestAll(l)
            else Double.NaN;
xl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xl.setdefaultColor(color.gray);

AddCloud(xh, xl, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

AddChartBubble(bn == HighestAll(first - 5), xh, AsText(xh), Color.GRAY);
AddChartBubble(bn == HighestAll(first - 5), xl, AsText(xl), Color.GRAY, no);
AddChartBubble(bn == HighestAll(first - 5), (xh + xl) / 2, AsText(xh - xl), Color.GRAY);
 
That’s exactly what I need Sleepy, ty, but Is it possible to have this result without Premarket?

Visually, there is a change of position in the sma´s.

example-3.jpg

Sure, just substituted secondsfromtime(0930) == 0 instead of the gettime() definition.

Capture.jpg
Ruby:
def bn    = BarNumber();
def first = if secondsfromTime(0930) == 0
            then bn
            else first[1];

def h     = if bn == HighestAll(first) then high else Double.NaN;
plot xh   = if Between(bn, HighestAll(first) - 5, HighestAll(first))
            then HighestAll(h)
            else Double.NaN;
xh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xh.setdefaultColor(color.gray);

def l     = if bn == HighestAll(first) then low else Double.NaN;
plot xl   = if Between(bn, HighestAll(first) - 5, HighestAll(first))
            then HighestAll(l)
            else Double.NaN;
xl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xl.setdefaultColor(color.gray);

AddCloud(xh, xl, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

AddChartBubble(bn == HighestAll(first - 5), xh, AsText(xh), Color.GRAY);
AddChartBubble(bn == HighestAll(first - 5), xl, AsText(xl), Color.GRAY, no);
AddChartBubble(bn == HighestAll(first - 5), (xh + xl) / 2, AsText(xh - xl), Color.GRAY);
 
I´m sorry, what am i doing wrong?
example-3.jpg

def bn = BarNumber();
def first = if SecondsFromTime(0930)== 0 crosses above RegularTradingStart(GetYYYYMMDD())
then bn
else first[1];

def h = if bn == HighestAll(first) then high else Double.NaN;
plot xh = if Between(bn, HighestAll(first) - 5, HighestAll(first))
then HighestAll(h)
else Double.NaN;
xh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xh.setdefaultColor(color.gray);

def l = if bn == HighestAll(first) then low else Double.NaN;
plot xl = if Between(bn, HighestAll(first) - 5, HighestAll(first))
then HighestAll(l)
else Double.NaN;
xl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xl.setdefaultColor(color.gray);

AddCloud(xh, xl, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

AddChartBubble(bn == HighestAll(first - 5), xh, AsText(xh), Color.GRAY);
AddChartBubble(bn == HighestAll(first - 5), xl, AsText(xl), Color.GRAY, no);
AddChartBubble(bn == HighestAll(first - 5), (xh + xl) / 2, AsText(xh - xl), Color.GRAY);
 
I´m sorry, what am i doing wrong?
example-3.jpg

def bn = BarNumber();
def first = if SecondsFromTime(0930)== 0 crosses above RegularTradingStart(GetYYYYMMDD())
then bn
else first[1];

def h = if bn == HighestAll(first) then high else Double.NaN;
plot xh = if Between(bn, HighestAll(first) - 5, HighestAll(first))
then HighestAll(h)
else Double.NaN;
xh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xh.setdefaultColor(color.gray);

def l = if bn == HighestAll(first) then low else Double.NaN;
plot xl = if Between(bn, HighestAll(first) - 5, HighestAll(first))
then HighestAll(l)
else Double.NaN;
xl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xl.setdefaultColor(color.gray);

AddCloud(xh, xl, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

AddChartBubble(bn == HighestAll(first - 5), xh, AsText(xh), Color.GRAY);
AddChartBubble(bn == HighestAll(first - 5), xl, AsText(xl), Color.GRAY, no);
AddChartBubble(bn == HighestAll(first - 5), (xh + xl) / 2, AsText(xh - xl), Color.GRAY);
I posted the code above along with the image. You just needed to copy and paste it.

Nonetheless, if you want to change def first it should be

Code:
def first = if secondsfromTime(0930) == 0
            then bn
            else first[1];
 
Thank you so much.
If i want to incorporate ¨result = (high-low)/ATR()¨, and see it in the script as a percentage like the below image:
example-3.jpg

How could you optimize the recent code?
God bless you Sleepy
 
Thank you so much.
If i want to incorporate ¨result = (high-low)/ATR()¨, and see it in the script as a percentage like the below image:
example-3.jpg

How could you optimize the recent code?
God bless you Sleepy

Try this

Capture.jpg
Ruby:
def bn    = BarNumber();
def first = if SecondsFromTime(0930) == 0
            then bn
            else first[1];

def h     = if bn == HighestAll(first) then high else Double.NaN;
plot xh   = if Between(bn, HighestAll(first) - 5, HighestAll(first))
            then HighestAll(h)
            else Double.NaN;
xh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xh.SetDefaultColor(Color.GRAY);

def l     = if bn == HighestAll(first) then low else Double.NaN;
plot xl   = if Between(bn, HighestAll(first) - 5, HighestAll(first))
            then HighestAll(l)
            else Double.NaN;
xl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
xl.SetDefaultColor(Color.GRAY);

AddCloud(xh, xl, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

def ATR = ATR();
AddChartBubble(bn == HighestAll(first - 5), xh, AsText(xh), Color.GRAY);
AddChartBubble(bn == HighestAll(first - 5), xl, AsText(xl), Color.GRAY, no);
AddChartBubble(bn == HighestAll(first - 5), ((xh + xl) / 2 ) - ticksize() * 3,
                     "H-L: " + AsText(xh - xl) +
                     "\nATR:" + astext(ATR) +
                     "\n" + aspercent((xh - xl) / ATR) , Color.GRAY);
 
Based on your pic, it seems that i´m refering other ¨ATR¨, it is in the studies section.
Please see the picture below.
Today for AAL the ATR was 0,68 and dont really know the reason of the 0.02.
So what im looking for, at this ultimate stage, is something like (0,17/0,68)= 25%
Is possible to use/add the one i´m referring there?
Thanks genious.

example-3.jpg
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
390 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