Super Simple Mid Point Value

Trigun1127

Member
I just need to display at the top of the screen where it shows the OHLC what the Midpoint of a candle is. I did see this code below on the think or swim website.



plot CandleBodyTop = MidBodyVal() + 0.5 * BodyHeight();
plot CandleBodyBottom = MidBodyVal() - 0.5 * BodyHeight()

Ah I forgot also for it display the price 5 points below the Low of that candle as another value. This is for futures btw
 
Solution
I just need to display at the top of the screen where it shows the OHLC what the Midpoint of a candle is. I did see this code below on the think or swim website.



plot CandleBodyTop = MidBodyVal() + 0.5 * BodyHeight();
plot CandleBodyBottom = MidBodyVal() - 0.5 * BodyHeight()

Ah I forgot also for it display the price 5 points below the Low of that candle as another value. This is for futures btw

The midpoint of a candle is measured from high to low, known as HL2, unless you want the Mid candle body you provided. If mid candle body, then replace HL2 with ((CandleBodyTop + CandleBodyBottom)/2).

Also, I don't trade futures, so I used 5 ticks for computing your revised Low value. If you did not mean ticks, then just edit the...
I just need to display at the top of the screen where it shows the OHLC what the Midpoint of a candle is. I did see this code below on the think or swim website.



plot CandleBodyTop = MidBodyVal() + 0.5 * BodyHeight();
plot CandleBodyBottom = MidBodyVal() - 0.5 * BodyHeight()

Ah I forgot also for it display the price 5 points below the Low of that candle as another value. This is for futures btw

The midpoint of a candle is measured from high to low, known as HL2, unless you want the Mid candle body you provided. If mid candle body, then replace HL2 with ((CandleBodyTop + CandleBodyBottom)/2).

Also, I don't trade futures, so I used 5 ticks for computing your revised Low value. If you did not mean ticks, then just edit the label to be (low - 5) instead of as displayed (low - TickSize() * 5)

Code:
AddLabel(1, "M: " + hl2, Color.WHITE);
AddLabel(1, "L - 5ticks: " + (low - TickSize() * 5), Color.PINK);

Here is mid candle body and no ticksize()
Code:
plot CandleBodyTop = MidBodyVal() + 0.5 * BodyHeight();
plot CandleBodyBottom = MidBodyVal() - 0.5 * BodyHeight();

AddLabel(1, "M: " + ((CandleBodyTop + CandleBodyBottom) / 2), Color.WHITE);
AddLabel(1, "L - 5: " + (low - 5), Color.PINK);
 
Last edited:
Solution
This is great thank you. However, Its not displaying the candle that I have my cursor on to display its values. it seems to only do the current candle on the screen. I would like to see the values for any candle that I place my crosshair on.

I just read this is not a possibility elsewhere. Is there any other way that I can quickly view if a candle closed above its midpoint? the Low-5 is actually fine, it would still be nice for it show its value on any candle. Is there a potentially another method?
 
# Plots the Mid value of each candle

declare upper;

def candleMid = (high + low)/2;

plot midCandle = candleMid;
midCandle.SetPaintingStrategy(PaintingStrategy.DASHES);
midCandle.SetLineWeight(1);
midCandle.setDefaultColor(GetColor(9));
 
This is great thank you. However, Its not displaying the candle that I have my cursor on to display its values. it seems to only do the current candle on the screen. I would like to see the values for any candle that I place my crosshair on.

I just read this is not a possibility elsewhere. Is there any other way that I can quickly view if a candle closed above its midpoint? the Low-5 is actually fine, it would still be nice for it show its value on any candle. Is there a potentially another method?

Sorry, I did not see this until baTrader's response.

This will place your choice of HL2 or Midbodyvalue at the top line as shown in the image below. As you move your cursor, the value will be of the candle where you place your cursor.

Name the study with a 1 character name so that the plot x code will hide it by coloring it black.

Move this study within your upper panel to be displayed first.

Screenshot-2022-10-17-081319.png
Ruby:
plot x=double.nan;
x.setdefaultColor(color.black);

input choice = {default hl2, mb};#mb=midbodyValue

def CandleBodyTop = MidBodyVal() + 0.5 * BodyHeight();
def CandleBodyBottom = MidBodyVal() - 0.5 * BodyHeight();

plot "HL2" = if choice==choice.mb
             then ((CandleBodyTop + CandleBodyBottom) / 2)
             else hl2 ;
"HL2".setpaintingStrategy(PaintingStrategy.POINTS);
"HL2".assignvalueColor(if close>open 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
362 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