HLC BARS NOT OHLC

MAGICO

New member
How can I use HLC bars in TOS like the pictures. Someone can help me with this. Thanks.

AmebsXv.jpg
 
Per @SleepyZ, who fancied-up my suggestion there to use AddChart in another thread (https://usethinkscript.com/threads/change-opacity-of-cloud.5721/post-54287), you can use the AddChart (though it is deprecated and wonky as all get out)
Code:
#addchart - up/down heiken ashi candle colors - workaround for the addchart() function not supported by TOS

def nan = double.nan;
def o = open;
def c = close;
def h = high;
def l = low;

AddChart(high = if c > o then h else nan,
         low = if c > o then l else nan,
         close = if c > o then c else nan,
         open = if c > o then nan else nan,
         ChartType.BAR, Color.dark_GREEN);
AddChart(high = if c < o then h else nan,
         low = if c < o then l else nan,
         open = if c < o then nan else nan,
         close = if c < o then c else nan,
         ChartType.BAR, Color.dark_RED);
AddChart(high = if c == o then h else nan,
         low = if c == o then l else nan,
         open = if c == o then nan else nan,
         close = if c == o then c else nan,
         ChartType.BAR, Color.GRAY);

See how the open is always a double.nan? That's how you can ignore the open price.

happy trading,
mashume


P.S. If you don't want to use the (c<o|c>o|c==o) set of operations -- if you want to ignore open prices entirely, you can replace the o in each of them with c[1] (c<c[1]|c>c[1]|c==c[1]).
 
Last edited:
@MAGICO I have no idea why you aren't satisfied with what Thinkorswim has to offer but if you aren't then it surely isn't our job to point you to a platform that better suits you... Go do your own research, plain and simple...!!! Or learn to live within Thinkorswims limitations... These forums are for traders who use and enjoy Thinkorswim... I'll go so far as to say that I'm appalled when members come here asking us to convert Thinkscripts to other platforms, and I'm not to keen on repetitive requests to convert scripts from other platforms to Thinkscript... This is a coding forum, to learn to use and write Thinkscript, not place for members to beg for others to do their work for them... I hope I've made myself clear...
thanks for your reply
Per @SleepyZ, who fancied-up my suggestion there to use AddChart in another thread (https://usethinkscript.com/threads/change-opacity-of-cloud.5721/post-54287), you can use the AddChart (though it is deprecated and wonky as all get out)
Code:
#addchart - up/down heiken ashi candle colors - workaround for the addchart() function not supported by TOS

def nan = double.nan;
def o = open;
def c = close;
def h = high;
def l = low;

AddChart(high = if c > o then h else nan,
         low = if c > o then l else nan,
         close = if c > o then c else nan,
         open = if c > o then nan else nan,
         ChartType.BAR, Color.dark_GREEN);
AddChart(high = if c < o then h else nan,
         low = if c < o then l else nan,
         open = if c < o then nan else nan,
         close = if c < o then c else nan,
         ChartType.BAR, Color.dark_RED);
AddChart(high = if c == o then h else nan,
         low = if c == o then l else nan,
         open = if c == o then nan else nan,
         close = if c == o then c else nan,
         ChartType.BAR, Color.GRAY);

See how the open is always a double.nan? That's how you can ignore the open price.

happy trading,
mashume


P.S. If you don't want to use the (c<o|c>o|c==o) set of operations -- if you want to ignore open prices entirely, you can replace the o in each of them with c[1] (c<c[1]|c>c[1]|c==c[1]).
how can i make the bar much thicker?
 
anyone know how i can make the opening horizontal line one color and the closing line a different color. or this?

q49Rfdx.png
You could, I suppose, modify the script above so that instead of a single bar for each block of trades, it generated two such that one was coloured green for the vertical bar and a different chart was coloured dependent on the movement of the bar to be red for down and green for up. Just depends on how important it is to you.

Take some the code above with no opens displayed, duplicate some parts of it and set the open and close to nan to plot just the verticals and then again with the high and low nan to plot the horizontals.

Of course, this may not work at all and you may get the vertical portion drawn between the open and close in that colour. I haven't tested it since it's rather a large piece of work for something I wouldn't myself use... but hopefully you get the idea.

happy trading,
mashume
 
Code:
#addchart - up/down heiken ashi candle colors - workaround for the addchart() function not supported by TOS

def nan = double.nan;
def o = open;
def c = close;
def h = high;
def l = low;

AddChart(high = if c > o then h else nan,
         low = if c > o then l else nan,
         close = if c > o then c else nan,
         open = if c > o then nan else nan,
         ChartType.bar, Color.black);
AddChart(high = if c < o then h else nan,
         low = if c < o then l else nan,
         open = if c < o then nan else nan,
         close = if c < o then c else nan,
         ChartType.bar, Color.black);
AddChart(high = if c == o then h else nan,
         low = if c == o then l else nan,
         open = if c == o then nan else nan,
         close = if c == o then c else nan,
         ChartType.bar, Color.black);
plot RealClose = close;
RealClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RealClose.HideBubble();
If anyone wants HLC candles similar to those of MarketSmith, I slightly modified the code above to make the close go across the whole bar and made the built in candles fully transparent.

HLCcandles.png
 
Code:
#addchart - up/down heiken ashi candle colors - workaround for the addchart() function not supported by TOS

def nan = double.nan;
def o = open;
def c = close;
def h = high;
def l = low;

AddChart(high = if c > o then h else nan,
         low = if c > o then l else nan,
         close = if c > o then c else nan,
         open = if c > o then nan else nan,
         ChartType.bar, Color.black);
AddChart(high = if c < o then h else nan,
         low = if c < o then l else nan,
         open = if c < o then nan else nan,
         close = if c < o then c else nan,
         ChartType.bar, Color.black);
AddChart(high = if c == o then h else nan,
         low = if c == o then l else nan,
         open = if c == o then nan else nan,
         close = if c == o then c else nan,
         ChartType.bar, Color.black);
plot RealClose = close;
RealClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RealClose.HideBubble();
If anyone wants HLC candles similar to those of MarketSmith, I slightly modified the code above to make the close go across the whole bar and made the built in candles fully transparent.

View attachment 20802
how did you do it, we can change the color?
 

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